调优JVM(GC)以获得高响应的服务器应用程序 [英] Tuning JVM (GC) for high responsive server application

查看:104
本文介绍了调优JVM(GC)以获得高响应的服务器应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Linux 64位上运行带有8个核心CPU和6 GB内存的应用程序服务器。



服务器必须高度响应。



经过一番检查后,我发现运行在服务器上的应用程序创建了相当数量的短暂对象,并且只有大约200〜400 MB的长寿命对象(只要没有内存泄漏)



阅读 http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html
我使用这些JVM选项

  -server -Xms2g -Xmx2g -XX:MaxPermSize = 256m -XX:NewRatio = 1 -XX:+ UseConcMarkSweepGC 

结果:次要GC需要0.01〜0.02秒,主要GC需要1〜3秒
不断发生次要GC。



如何进一步改进或调整JVM?

更大的堆大小?但是它需要更多的时间用于GC?



更大的NewSize和MaxNewSize(适用于年轻一代)?其他b
其他集电极?平行GC?


是否让主要GC更经常发生是一个好主意?如何?

解决方案


结果:次要GC需要0.01〜0.02秒, 1〜3秒,小GC不断发生。


除非您报告暂停,否则我会说CMS收集器正在做您已经要求它这样做。根据定义,CMS将使用比串行和并行收集器更大比例的CPU。这是您为低停顿时间支付的罚款。



如果您看到1到3秒暂停次,我会说您需要做一些调整。我不是专家,但它看起来应该从减少 CMSInitiatingOccupancyFraction 的值从默认值92开始。



增加堆大小将提高GC的吞吐量。但是如果你的问题长时间停顿,增加堆大小可能会使问题变得更糟。


I am running an application server on Linux 64bit with 8 core CPUs and 6 GB memory.

The server must be highly responsive.

After some inspection I found that the application running on the server creates rather a huge amount of short-lived objects, and has only about 200~400 MB long-lived objects(as long as there is no memory leak)

After reading http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html I use these JVM options

-server -Xms2g -Xmx2g -XX:MaxPermSize=256m -XX:NewRatio=1 -XX:+UseConcMarkSweepGC

Result: the minor GC takes 0.01 ~ 0.02 sec, the major GC takes 1 ~ 3 sec the minor GC happens constantly.

How can I further improve or tune the JVM?

larger heap size? but will it take more time for GC?

larger NewSize and MaxNewSize (for young generation)?

other collector? parallel GC?

is it a good idea to let major GC take place more often? and how?

解决方案

Result: the minor GC takes 0.01 ~ 0.02 sec, the major GC takes 1 ~ 3 sec the minor GC happens constantly.

Unless you are reporting pauses, I would say that the CMS collector is doing what you have asked it to do. By definition, CMS will use a larger percentage of the CPU than the Serial and Parallel collectors. This is the penalty you pay for low pause times.

If you are seeing 1 to 3 second pause times, I'd say that you need to do some tuning. I'm no expert, but it looks like you should start by reducing the value of CMSInitiatingOccupancyFraction from the default value of 92.

Increasing the heap size will improve the "throughput" of the GC. But if your problem is long pauses, increasing the heap size is likely to make the problem worse.

这篇关于调优JVM(GC)以获得高响应的服务器应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆