指定 JBoss 的最佳最小和最大堆大小
我有一个 Web 应用程序,想要在 Linux 计算机上部署用于生产。该机器将在 JBoss 4.2.3 上运行,并且前面将是最新版本的 Apache Web Server(使用 mod_jk)。这是机器上仅有的两个应用程序。服务器有 1.7GB RAM。我希望获得一些有关如何在此生产环境中找到 JBoss 的最佳最小 (-Xms) 和最大 (-Xmx) 堆大小的信息或参考。
问候
I have a web application that I want to deploy for production on a Linux machine. The machine will run on JBoss 4.2.3 and in front of it will be the latest version of Apache Web Server (using mod_jk). That's the only two applications residing on the machine. The server has 1.7GB RAM. I would appreciate some information or reference on how can I find the optimal minimum (-Xms) and maximum (-Xmx) heap size for JBoss on this production environment.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
找到最佳堆大小的一个好方法是使用 VisualVM (http://hillert.blogspot.com/2010/01/remote-profiling-of-jboss-using.html) 和负载测试。这使您可以可视化负载下的堆使用情况以及垃圾收集发生的时间和频率。选择一个像这些人建议的数字(在您的情况下在 700mb 到 1024mb 之间)将您的实例置于负载状态并观察内存配置文件。我怀疑您会发现 1.7GB 对于大多数生产应用程序来说是不够的。这通常表现为由于大量 gc 颠簸、响应时间差和/或内存不足错误而导致的 cpu 图表线尖峰。关键是在测试之前你无法确定。
A good way to find optimal heap size is to use VisualVM (http://hillert.blogspot.com/2010/01/remote-profiling-of-jboss-using.html) and load test. This allows you to visualize your heap usage under load plus when and how often garbage collection is taking place. Pick a number like these gents have suggested(in your case somewhere between 700mb and 1024mb) put your instance under load and watch the memory profile. I'd suspect you'll find 1.7GB to be insufficient for most production applications. This usually manifests itself as a spiky cpu chart line from lots of gc thrashing, poor response times, and/or outofmemoryerrors. The point is you won't know for sure until you test.
好吧,这通常取决于每个应用程序以及操作系统的负载,但我将最大堆大小设置为 1024 或 1280。只需看看操作系统和 Apache 使用了多少 + 一些峰值缓冲区。
Well, that generally depends on the load of each application as well the OS, but I'd set the max heapsize to 1024 or 1280. Just have a look on how much the OS and Apache are using + some buffer for spikes.
每个应用程序都会有不同的要求,因此很难针对您的情况给出最佳答案。但一般来说,我发现当服务器仅运行 Apache 和 Java 时,将 60% 的服务器内存分配给 JVM 堆效果很好。
因此,我建议您的服务器使用
-Xms1g -Xmx1g
。这应该为操作系统开销、Apache 和超出堆范围的 Java 内存(即永久代和堆栈大小乘以线程数)留出足够的空间。您应该试验并分析您的应用程序以验证其稳定性。Every application is going to have different requirements, so it's going to be hard to give an optimal answer for your situation. Generally however I've found that allocating 60% of the server memory toward the JVM heap works well when the server is only running Apache and Java.
So I'd recommend
-Xms1g -Xmx1g
for your server. That should leave sufficient room for OS overhead, Apache and Java memory that goes beyond the heap (namely the permanent generation and the stack size times the number of threads). You should experiment and profile your application to verify it's stable.