Exactly-once Semantics is Possible: Here's How Apache Kafka Does it

This post introduces and explains exactly-once semantics (EOS) in Apache Kafka, detailing how the 0.11 release and Confluent Platform 3.3 enable this capability. It elaborates on the challenges of achieving EOS in distributed systems and breaks down Kafka's solution into two key components: 1. Idempotent Producers: This feature ensures that retried sends of the same message batch only result in a single write to the Kafka log per partition, preventing duplicates due to producer or broker errors. It works by persisting sequence numbers to the replicated log. 2. Transactions API: This allows for atomic writes across multiple partitions, ensuring that either all messages in a batch are visible or none are. It also enables committing consumer offsets within the same transaction for end-to-end EOS. The post also explains how the Kafka Streams API leverages these features with the `processing.guarantee=exactly_once` configuration for exactly-once stream processing, guaranteeing that each received record's processed results are reflected once, even under failures.
More from the Kafka Producer and Consumer API Enhancements trail
- How a Tier‑1 Bank Tuned Apache Kafka® for p99 Latency for Trading
- Kafka Producer Internals: The Producer Request Lifecycle
- Inside the Kafka Black Box—How Producers Prepare Event Data for Brokers
- Apache Kafka Message Compression
- How to Make Apache Kafka Clients Go Fast(er) on Confluent Cloud | Confluent How to Make Apache Kafka Even Faster