docker production environment jvm performance optimization

1, xmx how suitable and provided xms

Size docker obtained mem_usage java process memory size is obtained from the outside, not just the size -Xmx settings, if -Xmx and docker assigned the same memory, then because of java application to other places also occupy a lot of memory , resulting in not yet reached when there is no memory -Xmx can use, so the docker container to get rid of, which appeared in the case of oom.

So what aspects of memory java program starts when the need for it?

  • Heap java program, the maximum value is set -Xmx
  • Garbage collection garbage collection when used in memory
  • JIT optimization of memory use
  • Off-heap java program used memory
  • Metaspace java program used memory
  • JNI Code memory occupied
  • jvm activated when the memory occupied.

How to use java process generally estimate the memory of it?

Max memory = [-Xmx] + [-XX:MaxPermSize] + number_of_threads * [-Xss]

Guess startup jvm parameters in setting this value -Xmx is generally less than docker limit the number of memory, through production test -Xmx: docker ratio of 2/3 - 3/4,

Generally are used in the production environment sunjdk, it is recommended that as large xmx and set xms

  1. Avoid application JVM memory to the OS during operation
  2. Delayed start for the first time after the occurrence of the timing of GC
  3. GC reduce the number of early start
  4. Avoid dynamic adjustment jvm heap size

2, xmn or disposed maxnewSize

xmn set the size of the young generation. If only some business simpler basic services recommended xmn set to half of xmx.

3, when the setting is greater than xmx 4G, the garbage collector is provided -XX: + UseG1GC

When the great heap memory if you still use the concurrent collector will cause gc collect long, then it can be collected into a parallel G1 collector

4, the container is preferably increased -XX: ParallelGCThreads set, the value may be set to audit cpu

Since the value ParallelGCThreads default is equal to the number of cpu core, but some get a production environment is the number of cpu core container host machine, which leads to too much cpu audit, poor efficiency, gc time will be extended.

发布了221 篇原创文章 · 获赞 9 · 访问量 13万+

Guess you like

Origin blog.csdn.net/lp19861126/article/details/103036000