Apache Kafka Streaming (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Exactly-Once Semantics (EOS) in Kafka Streams: Two-phase commit with transaction coordinator and marker messages.
senior LevelSystem DesignDatabases & SQLApache Kafka
In Simple Words: Kafka's "Read-Process-Write" loop achieves transactional Exactly-Once processing across multiple topics and state stores:
- Producer Transaction Coordinator: Allocates a unique
transactional.id. - Transaction Log (
__transaction_state): Records transaction state transitions (Ongoing,PrepareCommit,Committed). - Control Markers: The coordinator writes special commit marker messages directly into target topic partitions.
- Consumers set
isolation.level=read_committed. They automatically buffer uncommitted records and yield them to the application strictly after the commit marker is observed.