Corresponding JVM / GC setup for 4 MB JVM with 3 GB cache

I am looking for appropriate settings to configure JVM for web application . I read about generating old / young / perm, but I have problems using these parameters at best for this configuration.

Out of 4 GB, around 3 GB are used for the cache (application cache using EhCache ), so I am looking for the best setting given this. FYI, the cache is static during the life of the application (it loads from disk, never expires), but it is heavily used.

I have already profiled my application , and I have performed optimization with respect to database queries, application architecture, cache size, etc. I'm just looking for JVM configuration tips here . I rated 99% throughput for the garbage collector, and 6-8s pauses when the full GC is running (about once every 1/2 hour).

The following are the current JVM options:

-XX:+UseParallelGC -XX:+AggressiveHeap -Xms2048m -Xmx4096m -XX:NewSize=64m -XX:PermSize=64m -XX:MaxPermSize=512m -verbose:gc -XX:+PrintGCDetails -Xloggc:gc.log 

These options can be completely disabled because they were written a long time ago ... Before the application became so large.

I am using Java 1.5 64 bit.

Do you see any possible improvements?

Edit: The machine has 4 cores.

+7
source share
3 answers

-XX: + UseParallel * Old * GC should speed up Full GCs on a multi-core machine.

You can also profile various NewRatio values. Your cached objects will live on in a generation, so profile it with -XX: NewRatio = 7, and then again with some higher and lower values.

You may not be able to accurately reproduce realistic use during profiling, so make sure you control the GC when it is used in real life, and then you can make minor changes (for example, to the space for survivors, etc.) and see what effect they have.

The old tip was to not use AggressiveHeap with Xms and Xmx, I'm not sure if this is true.

Edit:. Let us know which OS / hardware platform you are deployed to.

Complete collections every 30 minutes show that the old generation is quite complete. High value for newRatio will give it more space at the expense of the younger generation. Can you give the JVM more than 4 g or are you limited to this?

It would also be helpful to know what your goals / non-functional requirements are. Do you want to avoid these 6/7 second pauses at the risk of lower bandwidth or are these pauses an acceptable compromise for the maximum bandwidth possible?

If you want to minimize pauses, try the CMS builder by removing both

 -XX:+UseParallelGC -XX:+UseParallelOldGC 

and adding

 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC 

Profile with this with various NewRatio values ​​and see how you do it.

One drawback of the CMS collector is that, unlike parallel old and serial collectors, it does not compact the old generation. If the old generation gets too fragmented and the secondary collection needs to push many objects into the old gene at once, a complete serial collection can be called up, which can mean a long pause. (I saw this once in prod, but with an IBM JVM that went out of memory instead of calling a collection of seals!)

This may not be a problem for you - it depends on the nature of the application, but you can insure it by restarting nightly or weekly.

+5
source

I would use an update for Java 6 30 or 7 update 2, 64-bit, since they are much more efficient. for example, they use 32-bit links by default.

I would also like to configure Ehcache to use direct memory or a memory mapped file, if possible. This should minimize the impact on the GC.

Using these options, you can virtually eliminate the printing of your heap. for example, I have an application that uses up to 180 GB of files with memory mapping on a machine with 16 GB of memory, and a heap size of 6 MB. Full GC takes up to 11 ms when started manually, not in GC .;)

If you need a simple example where I map an 8 TB file to memory and update it. http://vanillajava.blogspot.com/2011/12/using-memory-mapped-file-for-huge.html

+4
source

I hope you just deleted the server so you don’t inflate the message, otherwise you should enable it immediately. Besides a bit of longer startup time (which really is not a problem for a web application that should run for days), I see no reason to use anything other than c2. This can give good overall performance improvements. Return to the topic:

Unfortunately, the best I can come up with will not work with your ancient JVM. The G1 garbage collector was primarily designed to reduce latency. He not only tries to reduce pauses in general, but also offers some settings for setting goals and pause intervals. See this page .

There is an experimental backport for java6, although I doubt it has been constantly updated. And no one is wasting time optimizing the GC or anything else for Java 1.5, I'm afraid.

PS: There would also be an IBM JVM and, obviously, azul systems (normal, this was not a serious proposal;)), but this is obvious, there can be no question. Just wanted to mention them.

0
source

All Articles