简体   繁体   English

Java 1.5 Gc调整

[英]Java 1.5 gc tuning

We have a large application with allocated heap of 2 GB min & 8 GB max. 我们有一个大型应用程序,分配的堆最小为2 GB,最大为8 GB。 During load test we are finding some really long pause time the GC cycles are as large as 16+ secs. 在负载测试期间,我们发现暂停时间非常长,GC周期长达16+秒。 Initially we were using "-XX:+UseParNewGC" but switching to UseParallelGC gave us much needed performance boost, but we do have issue of longer pause time under load. 最初,我们使用的是“ -XX:+ UseParNewGC”,但是切换到UseParallelGC可以大大提高我们的性能,但是确实存在负载下更长的暂停时间的问题。

We tried few options such as increasing young generation but nothing seems to help any idea what else can be tried ? 我们尝试了一些选择,例如增加年轻一代,但似乎无济于事,还有什么可以尝试的呢? We have liberty to increase heap size if required but I am wondering that might worsen gc pause. 如果需要,我们可以自由增加堆大小,但是我想知道这是否会使gc暂停恶化。 If nothing can be done I am thinking of using cluster app servers with 5 GB heap instead of 1 larger heap. 如果什么也做不了,我正在考虑使用具有5 GB堆而不是1个较大堆的群集应用服务器。 snap shot of current gc logs is attached 随附了当前gc日志的快照

J  
J Thu Jun 23 12:40:56 2011
J  [GCJ  
J Thu Jun 23 12:40:57 2011
 [PSYoungGen: 2130792K->475247K(2084160K)] 7198716K->5543171K(7676608K), 1.3280110 secs] [Times: user=0.00 sys=1.88, real=1.33 secs] 
J  
J Thu Jun 23 12:41:00 2011
J  [GCJ  
J Thu Jun 23 12:41:01 2011
 [PSYoungGen: 1966319K->417801K(1908928K)] 7034243K->5546416K(7501376K), 0.7025950 secs] [Times: user=0.01 sys=1.89, real=0.71 secs] 
J  
J Thu Jun 23 12:41:12 2011
J  [GCJ  
J Thu Jun 23 12:41:13 2011
 [PSYoungGen: 1908873K->269608K(2155520K)] 7037488K->5523748K(7747968K), 1.3117340 secs] [Times: user=0.01 sys=1.44, real=1.31 secs] 
J  
J Thu Jun 23 12:41:33 2011
J  [GC [PSYoungGen: 1747432K->138147K(1616000K)] 7001572K->5593865K(7208448K), 0.4949960 secs] [Times: user=0.01 sys=1.40, real=0.50 secs] 
J  [Full GCJ  
J Thu Jun 23 12:41:50 2011
 [PSYoungGen: 138147K->0K(1616000K)] [PSOldGen: 5455718K->3456287K(5592448K)] 5593865K->3456287K(7208448K) [PSPermGen: 256273K->256273K(524288K)], 17.0259440 secs] [Times: user=0.00 sys=16.88, real=17.02 secs] 
J  
J Thu Jun 23 12:42:09 2011
J  [GC [PSYoungGen: 1477824K->85118K(2110848K)] 4934111K->3541406K(7703296K), 0.1437050 secs] [Times: user=0.00 sys=0.30, real=0.14 secs] 
J  
J Thu Jun 23 12:42:20 2011
J  [GC [PSYoungGen: 1573438K->71812K(2100352K)] 5029726K->3600767K(7692800K), 0.2477960 secs] [Times: user=0.00 sys=0.65, real=0.25 secs] 

Looking at your log, your largest collection (the 17 second one) is collecting the old (tenured) generation. 查看您的日志,最大的收藏(第17个第二收藏)正在收集旧的(使用期限的)图书。 Using the concurrent garbage collector on the Sun JVM should help (+XX:UseConcMarkSweepGC), as this will do the collection (mostly) concurrently, reducing the pause time). 在Sun JVM上使用并发垃圾收集器应该有所帮助(+ XX:UseConcMarkSweepGC),因为这将(主要)同时进行收集,从而减少了暂停时间)。

Your young generation pauses are reasonably large too, for the volume of data that's being collected. 对于正在收集的数据量,年轻一代的停顿也相当大。 What spec of machine are you running on? 您在什么机器上运行? These pauses aren't very frequent too, so if your goal is lower pause times, try reducing the size of the young generation (-XX:NewRatio), which should lead to shorter, more frequent pauses. 这些暂停也不是那么频繁,因此,如果您的目标是减少暂停时间,请尝试减小年轻一代的大小(-XX:NewRatio),这将导致更短,更频繁的暂停。

You should also be sure that there's no swapping happening on your machine. 您还应该确保计算机上没有交换发生。 You don't say what OS you're runnning, but on Linux run: 您没有说要运行什么操作系统,而是在Linux上运行:

vmstat 5

and check the "si" and "so" columns while these large GCs are taking place. 并在发生这些大型GC时检查“ si”和“ so”列。 If they are non-zero, either reduce the memory usage on the machine, or tweak the "swappiness" tunable. 如果它们不为零,则减少计算机上的内存使用量,或调整“ swappiness”可调参数。

Consider making your -Xms and -Xmx values the same. 考虑使-Xms和-Xmx值相同。 if you are willing to give the heap a max size of 8GB, then make that the min as well. 如果您愿意为堆提供最大8GB的大小,那么也要使该最小值为8GB。 This way the JVM doesn't have to worry about allocating more memory. 这样,JVM不必担心分配更多的内存。

How frequent are the full GC's? 完整GC的频率如何? if they are occurring frequently, then you may need to profile the application rather then beating your head against tuning gc parameters that will not matter in the end. 如果它们经常发生,那么您可能需要对应用程序进行概要分析,而不是最后对最终无关紧要的gc参数进行调整。 Find out what is allocating all the memory for you and see if there is a way to reduce it. 找出为您分配所有内存的内容,然后查看是否有减少内存的方法。

On JDK 1.5 and JDK 1.6 you will see increasing GC pauses as you pass 2 to 4 GB Heap memory. 在JDK 1.5和JDK 1.6上,当您传递2到4 GB的堆内存时,GC暂停会增加。 Clustering applications that need larger data heaps is one option. 将需要更大数据堆的应用程序集群化是一种选择。 The other I know of is considering alternate JVM's. 我知道的另一个正在考虑使用替代JVM。 If you are at 8 GB heap you may see improvements on JDK 1.7. 如果您使用8 GB的堆,则可能会在JDK 1.7上看到改进。 There are some optimizations. 有一些优化。 Additionally, Sun / Oracle has several other JVM's to consider. 此外,Sun / Oracle还需要考虑其他几个JVM。

If you have not read this article, it is a very strong one and for Java 5.0 / JDK 1.5. 如果您还没有阅读过这篇文章,那么它对于Java 5.0 / JDK 1.5来说是非常强大的。 It may help. 它可能有所帮助。 Tuning Java 5.0 . 调优Java 5.0 I would go into more detail, but the comments above do cover some of the elements. 我会更详细地介绍,但是上面的注释确实涵盖了一些元素。

Alternatively there is one other JVM on the market that is from a private company called Azul Systems . 或者,市场上还有另一种JVM,它来自一家名为Azul Systems的私人公司。 They have some open source tools to check if their C4 collector can help. 他们有一些开源工具来检查其C4收集器是否可以提供帮助。 They have a JVM platform that runs in parallel while your application is running. 它们具有一个JVM平台,可在您的应用程序运行时并行运行。 If their JHiccup tool says you have GC issues then they can provide an enterprise JVM. 如果他们的JHiccup工具说您遇到GC问题,那么他们可以提供企业JVM。 Cost is not free, so if you are looking at small deployments (one server) and problems that are less than $10,000 in value then I would (1) consider alternate free JVM and (2) try a different JVM if you can run on it (eg JDK 1.6 / 1.7). 成本不是免费的,因此,如果您正在考虑小型部署(一台服务器)和价值低于10,000美元的问题,那么我会(1)考虑使用备用的免费JVM,(2)如果可以在其上运行,请尝试其他JVM (例如JDK 1.6 / 1.7)。 If none of these are an option try clustering but do so with Heaps below 4GB. 如果这些都不是可选项,请尝试群集,但请使用低于4GB的堆。

The only point I make here is that there "ARE" options on choice of JVM. 我在这里所做的唯一一点是,在选择JVM时有“ ARE”选项。 JRocket does help some apps. JRocket确实可以帮助某些应用程序。

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

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