Make HTTP API calls safe to retry with idempotency keys
8 steps · about 1 h 29 min · Intermediate
- Understand why retries need idempotent APIs (article, Amazon Web Services, 15 min)
Lays out the duplicate-request problem from real large-scale services.
- Send an Idempotency-Key header on create requests (reference, Stripe, 5 min)
A clear production example of the key-based pattern.
- Design a robust API around idempotency keys (article, Stripe, 15 min)
Explains server-side key storage, retries and failure modes.
- Follow the IETF Idempotency-Key header draft (reference, IETF, 15 min)
Gives the emerging standard semantics and error responses.
- Set timeouts and retry limits on the client side (article, Amazon Web Services, 15 min)
Shows how to retry without overloading a struggling service.
- Add exponential backoff with jitter to retries (article, Amazon Web Services, 10 min)
Compares backoff strategies with simulated results.
- Decide which errors and operations are safe to retry (reference, Google Cloud, 10 min)
A concrete matrix of retryable status codes and idempotent calls.
- Respect the Retry-After header in a retry loop (reference, MDN Web Docs, 4 min)
Lets the server tell clients when to come back.