Integration / Apache Kafka Interview questions
What is the difference between at-least-once, at-most-once, and exactly-once delivery semantics?
These describe what a consumer can be guaranteed about duplicate or missed processing, and the difference comes down entirely to when offsets are committed relative to when the message is actually processed.
| At-most-once | At-least-once | Exactly-once |
| Commit offset BEFORE processing. | Commit offset AFTER processing. | Producer writes and offset commit happen atomically via transactions. |
| A crash after commit but before processing means the message is silently lost. | A crash after processing but before commit means the message is reprocessed. | No loss and no duplicate processing, even across a crash. |
| Simplest, lowest overhead, rarely used for anything that matters. | Most common default; requires idempotent downstream processing to handle duplicates safely. | Highest overhead and setup complexity, but strongest guarantee. |
Exactly-once in Kafka specifically means exactly-once within Kafka's own read-process-write cycle (using idempotent producers and transactions) — if the processing step also writes to an external system outside Kafka's transactional boundary, that external write still needs its own idempotency handling to preserve the same guarantee end to end.
More Related questions...