GC Config Suggestion

Xms and Xmx:

 

  1. The xms and xmx should be set as the same value which will be not re-allocate new memory and reduce the FullGC.
  2. If we do not set them as the same, when the load is not becoming higher, there will be a fullgc to allocate more data, if this fullgc take long time, will kill the system. 

  1.  
    • Suggestion Configuration:

 

-Xms1400m

-Xmx1400m

 

Young generation:

 

  • Points:
    • The Young generation is small when all the Heap size is not re-allocated, which is the 1/5 of the allocated heap.
    • If there is not enough space in the tenured generation to hold all the objects that require promotion from the young generation. (From my understanding that is why some times the young generation is decreased, and start gc although the Young generation size is 100m).
    • The Survivor is set as default, and JVM will allocate the Survivor which is very small.

 

  • Suggest Configuration:
    • Increase the size the Young generation, currently, the Ratio is 4 which means the Young: Tenured = 1:4, and the Young generation is 1/5 * 1400m = 280m. I think if we can set the Ratio to 3 will be better. (-XX:NewRatio=3)
    • I also google some articles about the Young generation, they said, only set the ratio of the Young generation cannot guarantee the allocation is right, if we can also set –Xmn350m which will be much better. 
    • How to set the survivor is good topic, and Sun also give some suggestions, (a lot of article also share a lot of suggestions), and the suggestions are separate two types,
      • No Survivor
        • -XX:MaxTenuringThreshold=0; I do not think that is good for our system because the Tenured generation is not so big for all the young objects.
      • Survivor is set as one number which is less than 32 (default setting is 32) -XX:SurvivorRatio=10
        • For our system, I think we can set it as less than 10. (Need testing, the survivor is not very important from the Sun documentation)
    • Set the Young generation use -XX:+UseParNewGC, if we use CMS as gc collector, the Young generation will use UseParNewGC as default, but we need set XX:ParallelGCThreads=n (n = CPU number).

 

Tenured Generation:

 

  • Point:
    • Long Pause Time now

 

  • Suggest Configuration:
    • Use -XX:+UseConcMarkSweepGC, beyond that, we also need set the -XX:CMSInitiatingOccupancyFraction=80 (when do the CMS collection), -XX:CMSFullGCsBeforeCompaction=5 (there will be fragment when doing the CMS collection, this configuration is used to define when do the fragment arrange).
    • About the GCTimeRatio and MaxGCPauseMillis, I do not think we need set them which will make the JVM do some judgment and re-allocate the memory.

 

Perm Generation:

 

  • Point:
    • Do we need un-load some classes?

 

  • Suggest Configuration:
    • As some documentation mentioned, if we do not use the un-load the classes, the performance will be better, which can be set as –Xnoclassgc, but if we use this point, we should set the perm generation as 256m. (Need prove with testing).
    • If we need un-load some classes, we can use +CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled, the CMS class unloader is still with good performance and the perm set as 128m should be working well.

If we can make the perf 15% better according the gc tuning, which will be a big success.

 

 

你可能感兴趣的:(suggest)