Producer Acks, Retries & Performance Tuning
Master the trade-offs between durability and throughput by tuning acks, min.insync.replicas, linger.ms, batch.size, and payload compression algorithms.
Configuring a Kafka producer is not a matter of finding one magic setting. Every configuration choice represents a conscious trade-off between durability, latency, and throughput.
A producer configured for maximum durability will wait for multiple broker replicas to persist records to disk before acknowledging success. A producer configured for maximum throughput will accumulate dense batches in memory, accepting a small delay in exchange for high efficiency.
In this lesson, you will master producer acknowledgment guarantees, understand the retry lifecycle, and learn how to tune batching and compression parameters for production workloads.
01The Producer Acknowledgment Spectrum (acks)
The acks configuration controls how many broker replicas must acknowledge a record before the producer considers the write successful:
| Setting | Durability Guarantee | Latency | Risk of Data Loss |
|---|---|---|---|
acks=0 | None (Fire and Forget) | Lowest (< 1ms) | High (Broker down, network drop, or corrupt payload causes silent data loss) |
acks=1 | Leader only writes to disk | Medium (2-5ms) | Moderate (Leader crashes before followers replicate the write) |
acks=all (or -1) | All active ISR replicas write | Highest (10-25ms) | Zero (Guaranteed durability when combined with min.insync.replicas=2) |
Why acks=1 is Not Safe for Mission-Critical Data
Under acks=1, the partition leader acknowledges the write as soon as it writes the record to its local commit log, without waiting for follower replicas.
If the leader broker loses power or suffers a kernel panic a fraction of a millisecond later—before followers have fetched the new offset—a clean leader election promotes an in-sync follower that never received that record. The message is permanently lost, even though the producer received a successful acknowledgment.
Loading the rest of the lesson…