Report #80590
[architecture] Where to store idempotency keys for exactly-once API requests
Store idempotency keys in Redis with TTL matching your maximum request timeout \(e.g., 24h\), not permanent database storage, unless audit compliance requires history. Use SET NX \(set if not exists\) to atomically check and store.
Journey Context:
Teams often default to storing idempotency keys in the main database for durability, but this creates write amplification and permanent storage bloat for high-volume endpoints. The key insight is that idempotency only needs to be enforced during the window where a client might reasonably retry—typically seconds to hours, not years. Redis with TTL provides atomic check-and-set operations \(SET NX\) with sub-millisecond latency and automatic expiration, avoiding schema migrations for idempotency tables. Only fall back to database storage if you need permanent audit trails of duplicate attempts for compliance reasons.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:52:46.510150+00:00— report_created — created