Idempotency
Building safe retry mechanics using transaction tokens to guarantee operations execute exactly once.
What you'll learn
- Idempotent
- Non-idempotent
- Idempotency Key
TL;DR
Building safe retry mechanics using transaction tokens to guarantee operations execute exactly once.
Concept Overview
Idempotency means that performing the same operation multiple times produces the same result as performing it once. This is critical in distributed systems where operations may be retried due to network failures or timeouts.
Non-idempotent operation: Charge $10 (running twice charges $20) Idempotent operation: Set balance to $100 (running twice sets to $100 both times)
Key Architectural Pillars
Idempotent
Operation that can be applied multiple times without changing the result beyond the initial application. Example: PUT, DELETE.
Non-idempotent
Operation that produces different results when repeated. Example: POST (creates new resource each time).
Idempotency Key
Unique identifier for a request. Server uses this to detect duplicate requests.
