Idempotency
Subject: Computer and Technology noun /ˌaɪ.dəmˈpoʊ.tən.si/ 1 definition
- distributed-systems
- api-design
- software-engineering
- fault-tolerance
-
Definition (noun)
Entry #76 · UpdatedIdempotency is a computing property of an operation whereby executing it multiple times produces the same system state and side effects as executing it once. In distributed systems, web APIs, and infrastructure automation, it acts as a critical safeguard against duplicate mutations caused by network timeouts, message redeliveries, and automated client retries. While subsequent calls to an idempotent operation may yield a different status code or a cached response—such as deleting an already removed record—its core boundary is guaranteeing that repeated invocations never create unintended duplicate state changes.
Common Forms
Idempotent HTTP Methods: Protocol-level semantics for methods such as
GET,PUT, andDELETE, where repeating an identical request leaves server-side resource state identical to a single execution, unlike non-idempotentPOSTrequests.Idempotency Keys: Client-generated unique tokens sent with state-changing requests so servers can recognize duplicate retries, skip re-execution, and return the original stored response.
Conditional Writes and Upserts: Database operations—such as
UPSERTstatements, unique-constraint enforcement, or optimistic concurrency version checks—that ensure repeated inserts or updates converge to a single consistent record state.Declarative Configuration Management: Infrastructure-as-code and orchestration workflows that compare live system state against a desired specification and apply changes only when drift exists, making repeated runs yield identical environments.
Example
When a customer taps "Pay Now" on an unstable mobile network, the checkout app sends a
POST /chargesrequest with a unique UUID in theIdempotency-Keyheader and retries the identical request after a five-second timeout. Because the payment gateway already recorded that key during the initial request, it skips charging the card a second time and returns the original201 Createdtransaction receipt.