Request arrives with Idempotency-Key: key-xyz Exists Check key-xyz Not found in storage Key found Atomic Insert key with status `processing` (UNIQUE constraint) completed Key status? processing Yes Insert suceeded? No (duplicate insert (affected rows = 1) Status: completed Return 409 Conflict (still being processed) Execute business logic Return 409 Concurrent duplicate Matches Request hash Doesn't match matches the stored one? Save response + update status to Return cached response Return 422 `completed` (don't reprocess) Different payload for the same key Return response