title: Kafka Best Practices + how to set recommended setting for JVM
body: <p>A recommended setting for JVM looks like following</p>
  
  <pre><code>-Xmx8g -Xms8g -XX:MetaspaceSize=96m -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:G1HeapRegionSize=16M -XX:MinMetaspaceFreeRatio=50 -XX:MaxMetaspaceFreeRatio=80
  </code></pre>
  
  <p>my question is - How do I set the above Java options for Kafka?</p>
  
  <p>I know for sure that we can set </p>
  
  <pre><code>export KAFKA_HEAP_OPTS="-Xmx8G -Xms8G"
  </code></pre>
  
  <p>but not sure if we can append the whole line </p>
  
  <pre><code>"-Xmx8g -Xms8g -XX:MetaspaceSize=96m -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:G1HeapRegionSize=16M -XX:MinMetaspaceFreeRatio=50 -XX:MaxMetaspaceFreeRatio=80"
  </code></pre>
  
  <p>to <strong>KAFKA_HEAP_OPTS</strong> variable</p>
  
  <p>reference - <a href="https://community.hortonworks.com/articles/80813/kafka-best-practices-1.html" rel="nofollow noreferrer">https://community.hortonworks.com/articles/80813/kafka-best-practices-1.html</a></p>