What do at-most-once, at-least-once and exactly-once delivery mean?
MediumConceptMessage Queues & Event Streaming
Answer
They describe what a messaging system guarantees when producers, brokers or consumers fail: a message may be lost, duplicated, or take effect exactly once.
- At-most-once: the consumer acknowledges before processing, so a crash loses the message but never duplicates it. Acceptable for metrics or logs.
- At-least-once: the consumer acknowledges after processing, so a crash causes redelivery and possible duplicates. This is the most common default.
- Exactly-once: true exactly-once delivery over an unreliable network is not achievable in general; systems provide exactly-once processing by combining at-least-once delivery with idempotent consumers or transactions, as Kafka does within its own topics.
- Practical rule: assume duplicates and make consumers idempotent, for example by recording processed message IDs or using upserts.
More in Message Queues & Event Streaming
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | What is a message queue, and why would you use one? | Concept | Easy | Read the answer to What is a message queue, and why would you use one? | |||
| 2 | What is the difference between a message queue and a publish-subscribe system? | Concept | Medium | Read the answer to What is the difference between a message queue and a publish-subscribe system? | |||
| 3 | What do at-most-once, at-least-once and exactly-once delivery mean? | Concept | Medium | Read the answer to What do at-most-once, at-least-once and exactly-once delivery mean? | |||
| 4 | How does Kafka achieve high throughput, and how does it preserve message ordering? | Concept | Hard | Read the answer to How does Kafka achieve high throughput, and how does it preserve message ordering? |