Messaging & Queues interview question · Most asked
Explain at-most-once, at-least-once and exactly-once delivery.
Summary
At-most-once may lose messages but never duplicates (ack before processing); at-least-once never loses messages but may deliver duplicates (ack after processing); exactly-once is achievable only within limited boundaries (e.g., Kafka transactions within Kafka) and in practice means at-least-once delivery plus idempotent processing.
Longer Answer
Most systems choose at-least-once and make consumers idempotent: deduplicate by message ID, use upserts, or record processed IDs in the same transaction as the side effect.
Key Points
- At-most-once: possible loss
- At-least-once: possible duplicates
- Exactly-once = at-least-once + idempotency
- Ack after processing