System Design
9. Message Queues and Event-Driven SystemsAnimated
Exactly-Once Processing
Each message affects state exactly once.
The idea
Achieved with idempotent consumers, transactions or deduplication, since delivery itself can repeat.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- current message
- earlier
- failure or attack
The broker deduplicates retries by producer id and sequence number.
- step:
- 1/6
- from:
- Producer
- to:
- Broker
1/6
Time runs downward. Solid arrows are requests, dashed arrows are replies.
Step by step
- 1Assign each message an id
- 2Process and record the id atomically
- 3Redeliveries are detected
- 4Effects happen once
Where it is used
Payments and counters.
Watch out for
Costs throughput, and only works within a controlled boundary.