简体   繁体   English

Linux使用运行Java GC的系统/内核CPU

[英]Linux using system/kernel CPU running Java GC

Som background info; 索姆背景信息;

The server; 服务器;

New SLES 12 server with 130 GB Ram intended to run MySQL for a large database (150G + data). 具有130 GB Ram的新SLES 12服务器旨在为大型数据库(150G +数据)运行MySQL。

The server will also host some Java applications. 服务器还将托管一些Java应用程序。

Java version (default from Oracle) - Java(TM) SE Runtime Environment (build 1.7.0-b147) - Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode) Java版本(默认来自Oracle) - Java(TM)SE运行时环境(版本1.7.0-b147) - Java HotSpot(TM)64位服务器VM(版本21.0-b17,混合模式)

We have stumbled into the following issue; 我们偶然发现了以下问题;

Running some spesific java applications makes the kerne/system cpu peak slowing down/halting the application for a periode of time. 运行一些特定的Java应用程序会使kerne / system cpu峰值减慢/暂停应用程序一段时间。 I have reproduced it by making a Java application that simply eats memory over time and uses some cpu. 我通过制作一个Java应用程序来重现它,它只是随着时间的推移而占用内存并使用一些cpu。

Investigations shows a hight number of interups during slowdown (10000-25000) . 调查显示在减速期间(10000-25000)有大量的中断。

After each slowdown Java has aquired some more memory. 每次放缓之后,Java都会获得更多内存。 Setting Java to start with a fixed memory also seems to reduce the issue (setting -Xmx and -Xms to the same value). 将Java设置为以固定内存开始似乎也可以减少问题(将-Xmx和-Xms设置为相同的值)。 Verbosing garbage collection also indicates that GC is kicking in and might be the trigger. 详细垃圾收集也表明GC正在开始并可能成为触发器。

The GC and memory allocation is for some reason is very expensive, and we're not sure where to look from here. 由于某种原因,GC和内存分配非常昂贵,我们不确定从这里查看。 Verbose from GC: 来自GC的详细信息:

[GC^C 1024064K->259230K(3925376K), 87,3591890 secs]

On a low-end linux server the same program running GC (running SLES, Java 1.6.0_11 from SUN); 在低端linux服务器上运行GC的同一程序(从SUN运行SLES,Java 1.6.0_11);

[GC 1092288K->253266K(3959488K), 3.0125460 secs]    

TOP during slowdown: 在减速期间TOP:

top - 11:23:33 up 87 days, 19:55,  5 users,  load average: 14.27, 4.50, 10.17
Tasks: 250 total,  39 running, 211 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us, 71.8%sy,  0.0%ni, 28.2%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    129033M total,   128576M used,      457M free,     1388M buffers
Swap:    32765M total,       13M used,    32752M free,   113732M cached

vmstat during slowdown (from the 3. row); 减速期间的vmstat(从3.行开始);

procs -----------memory---------- ---swap-- -----io---- -system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0  13552 1714328 1422268 116462260    0    0    10     9    0    0  0  0 100  0  0
 1  0  13552 1241780 1422268 116462292    0    0     0     0  240  353  1  0 99  0  0
 1  0  13552 695616 1422268 116462292    0    0     0    17  419  431  3  0 97  0  0
55  0  13552 486384 1422268 116462292    0    0     0     2 20228  458  1 57 43  0  0
75  0  13552 476172 1422268 116462300    0    0     0     8 12782  684  0 70 30  0  0
65  0  13552 470304 1422268 116462304    0    0     0     0 13108  792  0 72 28  0  0

Why is the GC so expensive on a high end server versus a low end server? 为什么GC在高端服务器上比在低端服务器上如此昂贵? Any ideas where to look for clues? 有什么想法寻找线索?

UPDATE - invoke params 2012-11-26 Invoke params; 更新 - 调用参数2012-11-26调用参数;

java -Xmx4g -Xms4g -verbose:gc -server -cp "./dest/" UseMemoryMain

Giving 给予

[GC^C 1024064K->259230K(3925376K), 87,3591890 secs]

Changed to; 变成;

java -Xmx4g -Xms4g -XX:+UseParallelGC -verbose:gc -cp "./dest/" UseMemoryMain

Giving 给予

[GC 1048640K->265430K(4019584K), 0,0902660 secs]

Changed to; 变成;

java -Xmx4g -Xms4g -XX:+UseConcMarkSweepGC -verbose:gc -cp "./dest/" UseMemoryMain

Giving 给予

[GC 1092288K->272230K(3959488K), 0,1791320 secs]

What is real funny is that rerunning today without telling which GC method to use gives this; 真正有趣的是, 今天重新运行而不告诉使用哪种GC方法给出了这个;

java -Xmx4g -Xms4g -verbose:gc -server -cp "./dest/" UseMemoryMain

Giving 给予

[GC 1024064K->259238K(3925376K), 0,0839190 secs]

Java has changed strategy for defaulting GC somehow... Java以某种方式改变了违约GC的策略......

Garbage Collection is indeed a tricky topic. 垃圾收集确实是一个棘手的话题。 To give best answer you should post the complete command line used to invoke java. 要给出最佳答案,您应该发布用于调用java的完整命令行。

As you said playing aground with the GC switches helps. 正如你所说,使用GC开关搁浅有帮助。 The reason for that is that the default settings are unfortunately not optimal for many applications used these days. 原因在于,对于目前使用的许多应用程序来说,默认设置不是最佳选择。 For many many applications, which are required to have fast responses, as they are interactive, the parameter 对于许多需要快速响应的应用程序,因为它们是交互式的,所以参数

-XX:+UseConcMarkSweepGC -XX:+ UseConcMarkSweepGC

will make a great difference. 会有很大的不同。

It is worth noting, that using the JVM you mentioned, using larger heaps (lets say greater 10GB) will always require some tuning. 值得注意的是,使用你提到的JVM,使用更大的堆(比如更大的10GB)总是需要一些调整。 Take the GC log you have and observe how behavior changes when you play with GC options. 获取您拥有的GC日志,并观察使用GC选项时行为的变化。 I would recommend trying different collector strategies (like CMS, or G1) and also playing with the configuration of the Eden Space (like Xmn). 我建议尝试不同的收集器策略(如CMS或G1),并尝试使用Eden Space的配置(如Xmn)。

Last, but not least, you could investigate what the application does with the memory using a profiler. 最后,但并非最不重要的是,您可以使用分析器调查应用程序对内存的作用。 Perhaps the code can be improved and thus a lot of GC can be avoided. 也许代码可以改进,因此可以避免很多GC。

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

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