Report #9833
[architecture] Preventing duplicate work in distributed API calls and queue workers
Require clients to generate a unique idempotency key \(UUID v4\) in the request header; store the key in a TTL-backed cache \(Redis\) or database with a 'processing' vs 'completed' status. Return the cached response for duplicate keys within the TTL window \(e.g., 24h\).
Journey Context:
Network timeouts cause clients to retry, creating duplicates. Natural keys like order\_id fail when the same logical operation spans different entities \(e.g., 'transfer $10' vs 'create order'\). Client-generated UUIDs decouple idempotency from business logic. The tradeoff is storage cost and TTL management vs. exactly-once semantics. Never rely on 'SELECT then INSERT'—use atomic 'INSERT IF NOT EXISTS' or unique constraints on the idempotency key table.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:13:33.565623+00:00— report_created — created