Skip to content

Idempotency

Every system that retries to be reliable eventually does the same thing twice. A client times out and sends again, a queue cannot tell whether the work was done and delivers again, an operator replays a message. Idempotency is the property that makes this harmless: doing an operation again leaves things as they were after the first time. This module is about the duplicates that retries create, and the ways to make them safe.

You will run a failure lab where a slow link makes every write run twice, read the code of an idempotency key and of a transactional outbox, and open a queue where lost acknowledgements bring messages back.

  1. Duplicate requests (20 min). Why a timeout leaves the outcome unknown, how a retry turns it into a double write, and a failure lab with three fixes.
  2. Idempotency keys (20 min). How a client-chosen key lets the server do an operation once and replay the answer, and a sorting exercise on which operations need one.
  3. Duplicate messages (18 min). At-least-once delivery, lost acknowledgements, and the transactional outbox.
  4. Deduplication windows and idempotent consumers (18 min). Why keys are only kept for a window, and how a consumer stays safe either way.
  5. Recap and quiz (12 min). The module in one page, a checklist, and a quiz.
  • Explain why a retry can do an operation twice, and say what each fix for it costs.
  • Design an idempotency key: who makes it, what is saved with it, and what happens when it comes back changed.
  • Say why a queue delivers a message more than once, and how an outbox avoids losing events.
  • Choose a deduplication window and make a consumer safe when a duplicate arrives after it.

All the numbers in the labs are illustrative. They are for comparing choices, not for forecasting any real product.

Built by GhaziAlibi.

© ShardCraft. All rights reserved.