bbaugher / confluent

A Chef cookbook to install the Confluent Platform
MIT License
15 stars 7 forks source link

Allow configuring java settings #3

Closed bbaugher closed 9 years ago

gregorskii commented 7 years ago

Can you provide an example in the readme about how to set the java arguments for one of the services? In other cookbooks I have used the arguments are provided as a string.

When I set the arguments in this book they are not applied to the running tasks.

MIN_HEAP_MEMORY = node['MIN_HEAP_MEMORY']
MAX_HEAP_MEMORY = node['MAX_HEAP_MEMORY']

opts = "-Xms#{MIN_HEAP_MEMORY}m -Xmx#{MAX_HEAP_MEMORY}m"

node.default["confluent"]["kafka"]["env_vars"] = {
  '_JAVA_OPTIONS' => opts
}
conflue+ 25416  6.9  4.7 4299520 377084 ?      Sl   00:58   0:02 java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+D
conflue+ 25503  9.7  3.1 4259460 255608 ?      Sl   00:59   0:03 java -Xmx256M -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+Disabl
conflue+ 25568 12.2  3.2 4255248 261332 ?      Sl   00:59   0:03 java -Xmx512M -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+Disabl
conflue+ 25654 95.1 14.7 4251696 1178788 ?     Sl   00:59   0:19 java -Xmx256M -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+Disabl

The tasks seem to have their default memory settings.

bbaugher commented 7 years ago

You are correct that the environment variables config is the best way to set java options. The next is what environment variables to set. This is provided by kafka and its run/start server scripts. You can see an example here where its using $KAFKA_JVM_PERFORMANCE_OPTS and provides the value -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -Djava.awt.headless=true by default. There are others for heap ($KAFKA_HEAP_OPTS).

I'd assume these environment variables are the same as the ones in confluent's kafka package but you may need to verify in its package/distribution.

bbaugher commented 7 years ago

I'll see if I can add a small bit in the README about this

gregorskii commented 7 years ago

Perfect thank you for pointing that out, appreciate it.

I didn’t know if it was global java options or per argument ones on Kafka, great to have clarity.

👍