Principle:Apache Kafka JVM Configuration
| Knowledge Sources | |
|---|---|
| Domains | Operations, JVM_Configuration |
| Last Updated | 2026-02-09 12:00 GMT |
Overview
A configuration process that assembles JVM runtime options for memory management, garbage collection, monitoring, and debugging.
Description
JVM Configuration assembles all the Java Virtual Machine options needed to run Kafka optimally. This includes heap size allocation, garbage collector selection (G1GC by default), GC logging configuration (adapting to Java 8 vs 9+ formats), JMX monitoring setup for remote management, Log4j logging configuration, and optional debug settings. Each concern is managed through a separate environment variable, allowing operators to override individual aspects.
Usage
Use this principle when tuning Kafka broker performance or enabling monitoring. Each JVM option category can be independently overridden via environment variables, allowing fine-grained control without modifying scripts.
Theoretical Basis
The configuration follows a layered-defaults pattern:
- Heap Options: KAFKA_HEAP_OPTS controls Xmx/Xms (default 256M for tools, overridden to 1G by broker start script).
- Performance Options: KAFKA_JVM_PERFORMANCE_OPTS configures G1GC and related settings.
- GC Logging: KAFKA_GC_LOG_OPTS adapts between Java 8 and 9+ GC log formats.
- JMX Options: KAFKA_JMX_OPTS enables remote JMX monitoring when JMX_PORT is set.
- Debug Options: KAFKA_DEBUG enables Java debug agent on a configurable port.