veda.ng
Back to Glossary

Idempotency

Idempotency infographic

Idempotency is the property where performing an operation multiple times produces the same result as performing it once, making the operation safe to retry without causing unintended side effects. HTTP GET requests are inherently idempotent: fetching data doesn't modify it, so fetching repeatedly returns the same state.

DELETE with a specific resource ID is idempotent: whether you delete once or ten times, the resource ends up deleted. PUT replacing a resource with specific content is idempotent: the final state is the same regardless of repetition. POST creating new resources is typically not idempotent: posting twice creates two resources. Network failures make idempotency critical for distributed systems.

If a server processes a request but the response is lost in transit, the client doesn't know if it succeeded. Without idempotency, retrying might duplicate the operation such as transferring money twice, creating duplicate orders, or sending duplicate emails.

Idempotency keys solve this for non-idempotent operations: the client generates a unique ID for each logical operation and sends it with every request. The server tracks completed operations by key; duplicate requests return the cached result instead of re-executing. Payment systems require idempotency keys. Message queues use them for exactly-once delivery guarantees.

Building reliable distributed systems requires thinking carefully about idempotency at every integration point.

Interactive Visualizer

HTTP Idempotency Interactive Demo

Click the HTTP method buttons below to see how idempotent operations produce the same result when repeated, while non-idempotent operations create different outcomes each time.

GETIdempotent ✓
Requests: 0
Response:
John Doe
john@example.com
DELETEIdempotent ✓
Requests: 0
Resource Status:
EXISTS
PUTIdempotent ✓
Requests: 0
Current Data:
John Doe
john@example.com
POSTNot Idempotent ✗
Requests: 0
Orders Created:
0 orders

Observation

Idempotent Operations:
  • • GET: Always returns same data
  • • DELETE: Resource stays deleted
  • • PUT: Same final state achieved
Non-Idempotent Operation:
  • • POST: Creates new resource each time
  • • Each request has side effects
  • • Repeated calls change system state