Explain like I'm five · SRE

What is Idempotency?

Idempotency, told as a story about a ticket booth that only honors a numbered ticket once.

huh, didn't it go? again!PAY20,00020,000money left twicethe payment stalls, so the guest taps 'pay' twice

The payment stalls, so the guest taps the button twice.Just a worried extra tap — but the money leaves twice.

PAYoh, another one — never seen this before!request Arequest Aboth get chargeda repeated request looks brand-new, so it gets processed again

A repeated request looks brand-new, so it gets processed again.Without a number, there's no way to tell them apart.

PAYNo.482No.482No.482? already done — only once!the same ticket number shows up again — count it just oncegive every ticket a number, and sending it twice still means one result

The same ticket number shows up again — count it just once.Thanks to the number, sending it twice still means one result.

Give each request a numbera unique one
Same number, counted onceit's processed only once
Safe to send twicethat's idempotency
No number means riskno way to know how many times
WITH A NUMBERNo.482 arrives twice-> charged onceNo.482charged onceNO NUMBERa request arrives twice-> charged twice??charged twicea request with no number is risky

This is the difference a number makes.With a number it's safe; without one, it just happens twice.

NUMBER STORAGENo.481, 482, 483...can't keep them foreverneeds an expirystoring numbers costs resources too, and it pairs with retrying after a wait

Storing those numbers costs resources too.You can't keep them forever, so they expire — and this always pairs with retrying.

In one breath

Idempotency = making sure the same request (same ticket number) arriving twice still produces the result only once.

A property where sending the same request multiple times produces the same result as sending it once. An idempotent key identifies each request, and already-seen keys are stored to filter out duplicates — especially important when a dropped connection triggers a retry.

When grown-ups say it

Idempotency
The property that sending twice gives the same result. Same as sending it just once.
Idempotent key
The unique number written on the ticket. This number is how you tell requests apart.
Deduplication
Filtering out a ticket with a number you've already seen. The second and later copies aren't processed.
Retry
Sending the request again after it's dropped. Retrying is only safe when the request is idempotent.
Duplicate payment prevention
The most common place idempotency shows up. The same payment number means money is taken only once.
At-least-once / Exactly-once
Names for how a message gets delivered. Just knowing the names is enough — a message may arrive more than once, or exactly once.
Naturally idempotent operations
An operation that gives the same result no matter how many times you do it. Like 'set the max to 10' — do it twice and it's still 10.
Ticket / Request ID
The unique number attached to each request. It plays the same role as the idempotent key.
Next story
Call In More Staff When the Line Grows →
Want another term as a picture book? Request →