System Design
9. Message Queues and Event-Driven SystemsAnimated
Idempotency
Doing the same operation twice has the same effect as once.
The idea
Idempotent operations make retries safe. Use idempotency keys for non-idempotent actions.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- current message
- earlier
- failure or attack
The client attaches a unique key to a risky request.
- step:
- 1/6
- from:
- Client
- to:
- API
1/6
Time runs downward. Solid arrows are requests, dashed arrows are replies.
Step by step
- 1Client sends a unique key
- 2Server checks it
- 3First request is executed
- 4Repeats return the saved result
Where it is used
Payments and APIs.
Watch out for
Keys need expiry and storage.