An operation is idempotent if performing it multiple times produces the same result as performing it once. HTTP GET, PUT, and DELETE are idempotent by design. Idempotency is critical in distributed systems where network failures cause retries — you need to handle the same request twice without double-processing.

How Idempotency Works

Idempotent: SET balance = 100 — run it 10 times, balance is still 100. Not idempotent: INCREMENT balance BY 10 — run it 10 times, balance increases by 100. For payment APIs: include an idempotency key. If the client retries with the same key, the server returns the original result without charging again.

Key Concepts

  • Idempotency Key — A unique client-generated ID sent with requests — the server uses it to detect and deduplicate retries
  • Safe Retries — Idempotent operations can be safely retried after network failures without side effects
  • HTTP Methods — GET, PUT, DELETE are idempotent. POST is not — each POST may create a new resource

Frequently Asked Questions

Why does idempotency matter?

Network failures, timeouts, and retries are inevitable in distributed systems. Without idempotency, a payment might be charged twice, or a resource created multiple times. Idempotency makes systems reliable.