Idempotency.
Pressing the elevator button twice does not call two elevators.
- Come on, come on…1
You press the elevator button. Press it again, impatiently, and again — still one elevator comes.
- 2
That’s idempotent: doing it twice has the same effect as doing it once.
- 3
Now the dangerous kind: “add £10 to the order.” Sent once, +£10. Sent twice, +£20.
- Did that go through?4
Networks are flaky. You send a request, the reply never comes — did it work? You can’t tell, so you retry.
- Why was I charged twice?!5
A naive retry of “add £10” charges you twice. That’s how people get double-billed.
- Seen this key — returning the first result.6
The fix: tag the request with a unique key. The server remembers it and ignores the duplicate.
Semicolony semicolony.dev/eli5/idempotency/comic