📨 Apache Kafka Intermediate

What is Kafka's exactly-once semantics (EOS) implementation?

Answer

Kafka's exactly-once semantics (EOS) for stream processing consists of three components working together. 1. Idempotent producer: prevents duplicate messages from producer retries using sequence numbers and Producer IDs per partition. 2. Transactions: atomic multi-partition writes — consumers see either all or none of a transaction's messages (with read_committed isolation). 3. Transactional consumer-processor-producer: in Kafka Streams, the atomic pattern is: consume from input partition + process + produce to output partition + commit input offset — all in one transaction. If any step fails, the entire transaction is aborted; on retry, the input offset is back to its pre-transaction position. Kafka Streams handles this automatically with processing.guarantee=exactly_once_v2. EOS adds ~20–40% latency overhead. Use for financial transactions, billing, and any domain where duplicate processing has monetary or compliance consequences.