简体   繁体   English

我在Java中利用大内存大小的最佳实践是什么?

[英]What is the best practice I utilize large memory size in java?

I have an application server server and 64 GB memory on it. 我有一个应用程序服务器服务器和64 GB内存。 And a java web application on it. 还有一个Java Web应用程序。 What is a best practice to utilize all these 64 GB? 利用所有这64 GB的最佳实践是什么? I need store a large set of objects (HashSet) Is it a best solution to use -Xms -Xmx ? 我需要存储大量对象(HashSet),这是使用-Xms -Xmx的最佳解决方案吗? But will GC working well? 但是GC会运作良好吗? Should I use 3rd party solutions like cache libraries (memcache and etc.) ? 我应该使用第三方解决方案,例如缓存库(memcache等)吗?

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. 尽管最近做得更好,但是“免费” JRE(Oracle,IBM)都不是支持大量内存的“著名”软件。 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. 如果你真的需要出于某种原因之一JVM,那么你可能要硬着头皮拿到产品,如查懋从Azuul。 zing allows you to use up to 2 TB per JVM, and it is also designed to minimize GC pausing. zing允许您每个JVM最多使用2 TB,它还旨在最大程度地减少GC暂停。 ( that is the real problem with the other VMs: at least some years back, their GC pauses would grow linear with memory size. ) (这是其他VM的真正问题:至少在几年前,它们的GC暂停将与内存大小成线性关系。)
  • But then, the better way in 2018: scale out instead of scale up. 但是,2018年更好的方法是:扩大规模而不是扩大规模。 Meaning: rather have multiple JVMs (maybe consuming 4, 8, 16 GB), and use things like load balancing to keep these JVMs busy. 含义:宁可拥有多个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. 换句话说:当然,如果您有一个大型的单片应用程序,只能通过添加更多的RAM来“扩展”,那么您必须忍受这一点。 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 ). 但是,如果您想了解更明智的支出方式,请研究微服务 ,以及如何使用它们将整体拆分成许多小部分(以及通过实例化更多这些小部分进行扩展的地方)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM