在java中使用大内存大小的最佳实践是什么?

时间:2022-02-02 03:54:57

I have an application server server and 64 GB memory on it. And a java web application on it. What is a best practice to utilize all these 64 GB? I need store a large set of objects (HashSet) Is it a best solution to use -Xms -Xmx ? But will GC working well? Should I use 3rd party solutions like cache libraries (memcache and etc.) ?

我有一个应用程序服务器服务器和64 GB内存。还有一个java web应用程序。使用所有这64 GB的最佳做法是什么?我需要存储大量的对象(HashSet)它是使用-Xms -Xmx的最佳解决方案吗?但GC会运作良好吗?我应该使用第三方解决方案,如缓存库(memcache等)吗?

1 个解决方案

#1


2  

A pretty generic question, so a broad answer.

一个非常通用的问题,所以答案很广泛。

  • Albeit doing better lately, neither of the "free" JREs (Oracle, IBM) are "famous" for supporting large amounts of memory. If you really need one JVM for whatever reasons, then you probably should bite the bullet and get a product such as zing from Azuul. zing allows you to use up to 2 TB per JVM, and it is also designed to minimize GC pausing. ( that is the real problem with the other VMs: at least some years back, their GC pauses would grow linear with memory size. )
  • 虽然最近做得更好,但“免费”JRE(甲骨文,IBM)都没有“支持大量内存”。如果你出于某种原因真的需要一个JVM,那么你可能应该咬紧牙关并从Azuul那里获得zing等产品。 zing允许您为每个JVM使用高达2 TB,并且它还旨在最小化GC暂停。 (这是其他虚拟机的真正问题:至少在几年前,它们的GC暂停会随着内存大小呈线性增长。)

  • But then, the better way in 2018: scale out instead of scale up. Meaning: rather have multiple JVMs (maybe consuming 4, 8, 16 GB), and use things like load balancing to keep these JVMs busy.
  • 但是,2018年更好的方式是:向外扩展而不是向上扩展。含义:相当多的JVM(可能消耗4,8,16 GB),并使用负载平衡等方法来保持这些JVM的繁忙。

In other words: sure, if you have one large monolithic application that can only be "scaled" by adding more RAM, well, then you have to live with that. But if you are wondering about smarter ways to spend your money, then look into micro services, and how you can use them in order to break up that monolith into many small parts ( and where scaling happens by instantiating more of these small parts ).

换句话说:确定,如果你有一个大的单片应用程序只能通过添加更多RAM来“缩放”,那么你必须忍受它。但是如果你想知道更聪明的方式来花钱,那么看看微服务,以及如何使用它们以便将这些整体分解成许多小部分(以及通过实例化更多这些小部分来实现扩展)。

#1


2  

A pretty generic question, so a broad answer.

一个非常通用的问题,所以答案很广泛。

  • Albeit doing better lately, neither of the "free" JREs (Oracle, IBM) are "famous" for supporting large amounts of memory. If you really need one JVM for whatever reasons, then you probably should bite the bullet and get a product such as zing from Azuul. zing allows you to use up to 2 TB per JVM, and it is also designed to minimize GC pausing. ( that is the real problem with the other VMs: at least some years back, their GC pauses would grow linear with memory size. )
  • 虽然最近做得更好,但“免费”JRE(甲骨文,IBM)都没有“支持大量内存”。如果你出于某种原因真的需要一个JVM,那么你可能应该咬紧牙关并从Azuul那里获得zing等产品。 zing允许您为每个JVM使用高达2 TB,并且它还旨在最小化GC暂停。 (这是其他虚拟机的真正问题:至少在几年前,它们的GC暂停会随着内存大小呈线性增长。)

  • But then, the better way in 2018: scale out instead of scale up. Meaning: rather have multiple JVMs (maybe consuming 4, 8, 16 GB), and use things like load balancing to keep these JVMs busy.
  • 但是,2018年更好的方式是:向外扩展而不是向上扩展。含义:相当多的JVM(可能消耗4,8,16 GB),并使用负载平衡等方法来保持这些JVM的繁忙。

In other words: sure, if you have one large monolithic application that can only be "scaled" by adding more RAM, well, then you have to live with that. But if you are wondering about smarter ways to spend your money, then look into micro services, and how you can use them in order to break up that monolith into many small parts ( and where scaling happens by instantiating more of these small parts ).

换句话说:确定,如果你有一个大的单片应用程序只能通过添加更多RAM来“缩放”,那么你必须忍受它。但是如果你想知道更聪明的方式来花钱,那么看看微服务,以及如何使用它们以便将这些整体分解成许多小部分(以及通过实例化更多这些小部分来实现扩展)。