SteelReed

Search

Search posts, questions…

Messaging & KafkaQuestion 11 / 21

Middle

acks=0/1/all, retries and the idempotent producer: how do you configure Kafka to neither lose nor duplicate messages?

Short answer

No message loss: acks=all, a topic with RF=3 and min.insync.replicas=2, retries bounded by delivery.timeout.ms. Retries without duplicates or reordering: enable.idempotence=true (the default since Kafka 3.0).

BrokerProducerBrokerProducerSend batch PID 7, seq 5ACK lost on the networkRetry batch PID 7, seq 5Seq already seen, dropduplicate, ACK

3 points to say:

  1. acks=all + RF=3 + min.insync.replicas=2, and disable unclean leader election.
  2. Idempotence (default since 3.0, in-flight ≤ 5): the broker uses producer id + sequence number to drop duplicates.
  3. Bound retries by time, not by count; on the consumer side disable auto-commit, commit after processing, stay idempotent.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.