Semicolony ELI5 · comic

Idempotency.

Pressing the elevator button twice does not call two elevators.

  1. Come on, come on…
    jab jab jab
    1

    You press the elevator button. Press it again, impatiently, and again — still one elevator comes.

  2. ×1 same effect, twice or once
    2

    That’s idempotent: doing it twice has the same effect as doing it once.

  3. add £10 ×1 → £10 ×2 → £20
    3

    Now the dangerous kind: “add £10 to the order.” Sent once, +£10. Sent twice, +£20.

  4. Did that go through?
    request reply lost
    4

    Networks are flaky. You send a request, the reply never comes — did it work? You can’t tell, so you retry.

  5. Why was I charged twice?!
    add £10 add £10 (retry) £20 charged twice
    5

    A naive retry of “add £10” charges you twice. That’s how people get double-billed.

  6. Seen this key — returning the first result.
    key: a1b2 key: a1b2 seen list a1b2 ✓
    6

    The fix: tag the request with a unique key. The server remembers it and ignores the duplicate.

Pressing the button twice changes nothing — the cure for retries on a flaky line.
Semicolony semicolony.dev/eli5/idempotency/comic
← All ELI5 explainers