acks, Retries and Durability

Kafka · lesson 7 of 34 · 4 min read

Configure a producer that will not quietly lose messages, and see what each ack level really costs.

Open this lesson in the learning hub

Key points

  • acks=0 is fire and forget. acks=1 waits for the leader only, so the write dies with the leader.
  • acks=all waits for every in-sync replica. It has been the client default since Kafka 3.0, and it is the one you want.
  • acks=all on its own is not enough. Pair it with min.insync.replicas=2 on a topic with 3 replicas.
  • Without that, an ISR shrunk to one replica still satisfies acks=all. With it, the write fails loudly instead.
  • Retries are effectively infinite, bounded by delivery.timeout.ms (2 minutes). When that expires it is a real failure — handle it.
  • linger.ms trades a few milliseconds of latency for much bigger batches. On a busy topic that is nearly free throughput.

Example

# ---- producer ----
acks=all
enable.idempotence=true
delivery.timeout.ms=120000
request.timeout.ms=30000
max.in.flight.requests.per.connection=5
compression.type=lz4
linger.ms=10
batch.size=65536

# ---- topic side (kafka-configs.sh --alter --entity-type topics) ----
# min.insync.replicas=2   with replication.factor=3

acks=all plus min.insync.replicas=2 is the durable baseline. Anything weaker is a deliberate trade.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Kafka course, and every lesson in it is listed on the Kafka contents page.