1.What Idempotency Actually Means
An idempotent operation can be retransmitted or retried with no additional side effects. Running it twice leaves the system in the same state as running it once, and the caller gets the same answer either way. That property is what makes retries safe — and without it, every timeout becomes a choice between losing work and duplicating it.
Key features
- AWS defines an idempotent operation as one where a request can be retransmitted or retried with no additional side effects
- AWS's preferred approach is to incorporate a unique caller-provided client request identifier into the API contract — EC2 exposes this as `ClientToken`
- A retry must return a semantically equivalent response, so the caller cannot tell whether it was the first attempt or the fifth
- Recording the idempotency token and performing the mutation must be one atomic, consistent, isolated and durable operation, or partial state results
- The service has to keep request history beyond the lifetime of the resource, because a late retry can arrive after the resource is gone
- Idempotency is a property of the operation as a whole — a handler that writes two rows in two transactions is not idempotent even if each write is
Where the ambiguous timeout shows up
- A diagram showing one client request that times out, branching into three possible realities.
- The client sends a request and receives no response. From the client's side, all three of the following look identical.
- Reality one: the request never arrived. Retrying is necessary.
- Reality two: the request arrived and succeeded, but the response was lost. Retrying would duplicate the effect — unless the operation is idempotent.
- Reality three: the request arrived and is still running. Retrying may run it twice concurrently.
- Below, the conclusion: without idempotency the client must choose between losing work and duplicating it; with idempotency, retrying is correct in all three realities.
Signature
client-supplied key + atomic record-and-mutate + stored response on retry + retention beyond resource lifetime
An idempotent operation can be retried with no additional side effects, because the client cannot tell a lost response from a lost request. Take a client-supplied key, record it and perform the mutation in one atomic transaction, return the same stored response to every retry, and keep the record longer than the resource itself lives.