Idempotency

A payment request times out, the app retries, and the customer pays twice. Messages get repeated for many reasons: retries, broker restarts, switching to a backup server. You can’t stop that, so your code has to make a repeated message harmless. That property is called idempotency. You’ll learn when your logic already has it, and when you need to detect duplicates on purpose.

The first article covers handling commands: which operations are safe to repeat, and how to reject a duplicate with the same version check that protects against concurrent edits. The second explains where duplicates come from and where in a system you can filter them out. The third applies the same ideas to updating read models.

Start with the first one.

  1. Idempotent Command Handling

    2024-11-15“Is your command handling idempotent?” Sounds like a douchebag question to ask. Actually, that’s not a question but a statement that we want to sound smart. Maybe a…
  2. Deduplication in Distributed Systems: Myths, Realities, and Practical Solutions

    2024-11-25Last week, we discussed how to use queuing to guarantee idempotency. What’s idempotency? It’s when we ensure that no matter how often we run the same operation, we’ll…
  3. Dealing with Eventual Consistency and Idempotency in MongoDB projections

    2021-11-10Auditability, diagnostics, time travelling are usually the first mentioned features when speaking about Event Sourcing. All of them are great, but to me, projections are…