liveBook · Manning

Idempotency

As explained in Grokking Software Architecture

Idempotency is the property of an operation whose repeated application has the same effect as applying it once.

Idempotency is a reliability guarantee: repeating the same action has the same effect as doing it once. The first request changes the system; identical retries become no-ops, and the server can return the successful result again. section 6.3.2

The payment retry

A mobile app sends “Pay $50,” but the connection drops before success arrives. The app retries; idempotency ensures the customer is charged only once. section 6.3.2

The implementation depends on the kind of request:

  • REST builds idempotency into verbs such as PUT and DELETE. section 6.11
  • GraphQL requires developers to design idempotency into mutations, for example with an idempotencyKey. section 6.11 section 6.3.2
  • For at-least-once event delivery, consumers can check a database or tracking table for processed event IDs so duplicates become no-ops. section 7.4.2

Retries can still cause duplicate work: if a shipping service prints a label but crashes before acknowledging the message, the broker may send it again. Idempotency makes that repeat harmless. section 7.4.3

How Grokking Software Architecture covers it

How deep it goes
Defines retry behavior and gives implementation approaches, but does not provide code-level implementation details.
Examples
Uses a retried payment, duplicate OrderPlaced events, and a shipping label printed twice.
What you can do after
Apply the guarantee through REST verbs, GraphQL mutation keys, or consumer-side checks of processed event IDs.
How it connects
Connects idempotency to REST, GraphQL mutations, at-least-once delivery, and message consumers.

Also explained in

Compare how 20 books explain idempotency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.