Benchmarking Throughput vs Latency

Producer throughput is a four-dimensional knob. Measure, don't guess.

0/2 done

Measure all four knobs

The throughput / latency / durability triangle

Throughput in Kafka is governed by:

  • linger.ms — wait this long to fill a batch (latency cost, throughput win).
  • batch.size — bigger batches → bigger savings per fsync.
  • compression.typezstd ≈ best ratio, lz4 ≈ best speed, snappy ≈ default sweet spot.
  • acksall halves throughput vs 1 (typically).

Production benchmarking belongs in a real cluster with kafka-producer-perf-test.sh and the in-app code below — both. Don't tune blind.

Micro-benchmark a producer (Go)

Sweep linger.ms ∈ {0, 5, 20} × RequiredAcks ∈ {Leader, All} and report msgs/s and p99 latency. Skeleton below — extend the sweep loop.

Reflect

Tie the numbers back to product SLOs.

  • At what acks/linger combo does p99 latency cross your SLA?
  • Does Snappy → Zstd buy you enough throughput to justify the CPU?

Reading in progress · 0 of 2 activities done