How to Limit the kafka server Memory?

7/20/2021

I want to set the Max and minimum memory value for the Kafka server 9092 port

Let say Max value is 2 GB, then memory usage should not exceeds the 2GB, but currently exceeds it.

I have link - https://kafka.apache.org/documentation/#java

Config From Apache site

-Xmx6g -Xms6g -XX:MetaspaceSize=96m -XX:+UseG1GC
-XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:G1HeapRegionSize=16M
-XX:MinMetaspaceFreeRatio=50 -XX:MaxMetaspaceFreeRatio=80 -XX:+ExplicitGCInvokesConcurrent

But I don't know how to configure it.

My goal is to setting a max memory limit value and Memory Value in Kubernetes Dashboard should not exceeds the max memory limit value.

Note - Setting max memory limit value should not be in Kubernetes POD Level and its should be like setting value while Starting zookeeper,Kafka Server and kafka connect.

enter image description here

-Xmx1G -Xms256M Proof enter image description here

-- Rabeesh
apache-kafka
jvm-arguments
kubernetes

1 Answer

7/20/2021

Depending on the Image you are using for kafka you can supply these settings via the environment variable KAFKA_OPTS.

The documentation you are referring to is supplying these options to the call of 'java'. Kafka, Zookeeper etc. are jars and there for stated via java.

-- PSchoe
Source: StackOverflow