«Пришло время обновить java11» настройки параметров JVM виртуальной машины

Java

Каталог столбцов

  1. Пришло время обновить преимущества java11-01-jdk11 и опции jdk
  2. Пора обновить java11-02-Upgrade jdk11 и шагнуть на яму
  3. Пришло время обновить настройки параметров JVM виртуальной машины java11-03
  4. Пришло время обновить Java11-04 HTTP2 Clear Text (H2C) для связи http2 в пределах микросервисов
  5. Пришло время обновить java11 - 05 Препятствие и решение проблем связи h2c внутри микросервисов

предисловие

Сразу после первых двух статей давайте поговорим о изменениях параметров записи JVM после обновления Java11. Java11 удалил сборщик мусора CMS. Если вы обновляете до Java11, но параметры JVM все еще используют параметры сборщика мусора CMS, консоль сообщит об ошибке или даже не запускается.

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Unrecognized VM option 'ParallelCMSThreads=2'
Did you mean 'ParallelGCThreads=<value>'? Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

JAVA11 Параметры запуска JVM

Элементы конфигурации G1GC:

Option and Default Value Description
-XX:+UseG1GC Use the Garbage First (G1) Collector
-XX:MaxGCPauseMillis=n Sets a target for the maximum GC pause time. This is a soft goal, and the JVM will make its best effort to achieve it.
-XX:InitiatingHeapOccupancyPercent=n Percentage of the (entire) heap occupancy to start a concurrent GC cycle. It is used by GCs that trigger a concurrent GC cycle based on the occupancy of the entire heap, not just one of the generations (e.g., G1). A value of 0 denotes 'do constant GC cycles'. The default value is 45.
-XX:NewRatio=n Ratio of old/new generation sizes. The default value is 2.
-XX:SurvivorRatio=n Ratio of eden/survivor space size. The default value is 8.
-XX:MaxTenuringThreshold=n Maximum value for tenuring threshold. The default value is 15.
-XX:ParallelGCThreads=n Sets the number of threads used during parallel phases of the garbage collectors. The default value varies with the platform on which the JVM is running.
-XX:ConcGCThreads=n Number of threads concurrent garbage collectors will use. The default value varies with the platform on which the JVM is running.
-XX:G1ReservePercent=n Sets the amount of heap that is reserved as a false ceiling to reduce the possibility of promotion failure. The default value is 10.
-XX:G1HeapRegionSize=n With G1 the Java heap is subdivided into uniformly sized regions. This sets the size of the individual sub-divisions. The default value of this parameter is determined ergonomically based upon heap size. The minimum value is 1Mb and the maximum value is 32Mb.

Детали конфигурации журнала G1GC:

G1GC -Xlog:gc Log messages with gc tag using info level to stdout, with default decorations.
G1GC -Xlog:gc,safepoint Log messages with either gc or safepoint tags (exclusive), both using 'info' level, to stdout, with default decorations.
G1GC -Xlog:gc+ref=debug Log messages with both gc and ref tags, using debug level, to stdout, with default decorations.
G1GC -Xlog:gc=debug:file=gc.txt:none Log messages with gc tag using debug level to file gc.txt with no decorations.
G1GC -Xlog:gc=trace:file=gc.txt:uptimemillis, pids:filecount=5,filesize=1m Log messages with gc tag using trace level to a rotating logs of 5 files of size 1MB, using the base name gc.txt, with uptimemillis and pid decorations.
G1GC -Xlog:gc::uptime,tid Log messages with gc tag using info level to output stdout, using uptime and tid decorations.
G1GC -Xlog:gc*=info,safepoint*=off Log messages with at least gc using info level, but turn off logging of messages tagged with safepoint.

Пример конфигурации

-server
-Xmx4g
-Xms4g
-Xss256k
-XX:MaxDirectMemorySize=256m
-XX:+UseG1GC 
-XX:+UseCompressedOops 
-XX:+UseCompressedClassPointers
-XX:+SegmentedCodeCache 
-verbose:gc
-XX:+PrintCommandLineFlags
-XX:+ExplicitGCInvokesConcurrent
-Djava.security.egd=file:/dev/./urandom
-Xlog:gc*,safepoint:/data/log/${SERVICE_NAME}/gc.log:time,uptime:filecount=100,filesize=50M

G1GC не нужно явно задавать размер молодого поколения, а его автоматическая настройка также очень надежна, а время паузы часто позволяет добиться ожидаемого эффекта после длительного прогона. Не рекомендуется делать слишком много настроек. Автор считает, что это все же необходимо для gc log. Вы можете настроить его в соответствии с вашими реальными потребностями.

утверждение

Эта серия статей издательстваСлюда основного компонента микросервисаавтортехнология мечтыОрганизовать написание, Если есть какая-либо ссылка или перепечатка, пожалуйста, сохраните оригинал автор и укажите источник.

image