Skip to content
Veltoryx Technologies
ProLesson 9.2Intermediate5 min readUpdated 31 October 2026

Broker and Client Performance Tuning

Tune Linux OS kernel parameters, optimize broker JVM and page cache allocation, and configure high-throughput client network buffers.

Achieving gigabyte-per-second streaming throughput with sub-millisecond latencies requires understanding Kafka's hardware and operating system interactions.

Kafka was designed from the ground up to exploit modern Linux storage and networking subsystems. Unlike traditional databases that implement complex in-memory caching mechanisms inside the application process, Kafka relies on the Linux kernel page cache and zero-copy I/O.

Configuring high-throughput production clusters requires balancing Linux kernel settings, broker JVM heaps, and client socket buffers.

Broker OS Page Cache Tuning
Fig. 1 · Broker OS Page Cache Tuning

01The memory architecture paradox: Small JVM heaps

When engineers provision a physical server or VM with 64 GB or 128 GB of RAM, a common instinct is to give most of that memory to the Kafka broker's JVM heap (such as -Xmx60G).

In Kafka, this is an anti-pattern:

  • A 60 GB JVM heap will eventually trigger garbage collection cycles. Even with modern G1GC or ZGC collectors, managing tens of gigabytes of short-lived Java objects can induce stop-the-world pauses lasting several seconds.
  • Java objects carry high memory overhead, often doubling or tripling the raw byte footprint of stored records.
  • If the broker restarts, warming up a 60 GB in-memory cache takes a long time.

Kafka brokers require only 6 GB to 8 GB of JVM heap space. The heap is used strictly for connection state, metadata caches, and active request handling:

bash
# Optimal JVM options for Kafka Broker (64 GB Host)
KAFKA_JVM_PERFORMANCE_OPTS="-Xms8g -Xmx8g -XX:MetaspaceSize=96m \
  -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=45 \
  -XX:G1ReservePercent=15 -XX:MinMetaspaceFreeRatio=50 -XX:MaxMetaspaceFreeRatio=80"

The remaining 56 GB (85% of host memory) is deliberately left to the Linux operating system page cache.

When a producer writes messages, the OS writes them into page cache buffers. When consumers read those messages, the Linux kernel serves them directly out of the page cache via the sendfile() system call, transferring data from kernel memory to the network card without copying bytes into the JVM heap.

Loading the rest of the lesson…