liveBook · Manning

Producer idempotence

As explained in Kafka for Architects

enable.idempotence is a Kafka producer setting that enables broker-managed deduplication and ordering protection for producer retries.

Producer idempotence protects event delivery when asynchronous requests are retried. With enable.idempotence=true, Kafka prevents duplicate batches and preserves their order within each partition, addressing lost acknowledgments and delayed retries. section 3.2.5 section 7.4.1

Kafka assigns the producer a unique identifier and each batch a monotonically increasing sequence number per partition. The broker accepts the expected sequence, while an out-of-sequence batch produces a retriable error so the producer can resend it correctly. section 7.4.1

Use idempotence with the surrounding delivery settings:

  • Set retries to a positive value so transient failures can be recovered. section 7.4.1
  • Set acks=all so replicated in-sync brokers acknowledge the batch before delivery is considered successful. section 3.2.5
  • Keep max.in.flight.requests.per.connection at 5 or fewer to avoid concurrency issues while maintaining ordering. section 7.4.1

A failed acknowledgment

A producer sends batch 1, loses its acknowledgment, and sends batch 2, which succeeds. Without protection, retrying batch 1 could append it after batch 2. Idempotence lets Kafka detect the sequence mismatch and retry batch 1 in the correct order. section 7.4.1

The setting is useful in enterprise producer configurations such as a Customer 360 operational data store, where all acknowledgments, serializers, partitioning, and producer identifiers must be governed consistently. section 3.2.5

How Kafka for Architects covers it

How deep it goes
Explains broker-side producer identifiers, sequence numbers, retriable errors, and required settings without exposing them through the Kafka API.
Examples
Uses lost acknowledgments, reordered batches, and Customer 360 operational data store configuration as concrete examples.
What it assumes
Assumes familiarity with Kafka producers, batches, acknowledgments, retries, and partitions.
What you can do after
Apply it via Kafka producer configuration to preserve partition order and prevent duplicate batches during retries.
How it connects
Connects producer retries, acknowledgments, partitions, replication, and in-flight requests.

Also explained in

Compare how 3 books explain producer idempotence →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.