Report #94880
[architecture] How to prevent duplicate processing in distributed systems with at-least-once delivery
Implement client-generated idempotency keys \(UUIDs\) stored in a deduplication window \(e.g., 24h\) on the server; reject or return cached response for duplicate keys rather than just inserting a database unique constraint.
Journey Context:
At-least-once delivery is the only practical guarantee in distributed systems \(network partitions make exactly-once delivery impossible\). Simple 'check if exists' logic fails under race conditions and doesn't handle the requirement to return the same response on retries \(idempotent APIs must return the same 200 OK with the same body, not an error\). Database unique constraints prevent duplicates but force the client to handle 'already exists' errors differently from success, breaking idempotency. The solution is a time-bounded key-value store \(often the same DB with a TTL\) that maps the idempotency key to the serialized response, returning the cached response for duplicates within the window.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:50:15.336799+00:00— report_created — created