Skip to content
← All concepts

Reliability & correctness

Idempotency

Make an operation safe to repeat, so retries never cause double effects.

Networks fail after a request is processed but before the response arrives. The client retries — and without protection, a payment is charged twice or an order is created twice.

See it in action

Step through the scenarios on the diagram.

Laying out diagram…

1/4The client sends a charge with key abc-123.

Client
— Retries on timeout
Payments API
— Checks the idempotency key first
Idempotency store
— key → saved response
Card network
— Actually moves money

How it works

  • Clients send an idempotency key; the server stores key → result and returns the stored result on repeats.
  • Unique constraints (e.g. one like per user per post) make writes naturally idempotent.
  • Event consumers dedupe by event or entity id.

Trade-offs

  • Keys must be stored (with expiry) and checked atomically.

Seen in

Components involved

Related concepts