Idempotent Order Placement When the App Retries Checkout
Last updated: November 29, 2026
Quick Overview
Mobile clients retry the place order call on timeouts, which can create duplicate orders and double charges. Implement an order placement wrapper that uses a client supplied idempotency key so each logical checkout creates at most one order, and explain how it behaves across concurrent retries and failures.
Coupang
November 29, 20260
0
0 solved
Mobile clients retry the place order call on timeouts, which can create duplicate orders and double charges. Implement an order placement wrapper that uses a client supplied idempotency key so each logical checkout creates at most one order, and explain how it behaves across concurrent retries and failures.
Coupang's checkout runs across many services (inventory reservation, Coupang Pay, order records), and flaky mobile networks in subways and elevators make retries routine. This question checks whether you understand idempotency as a contract with stored outcomes, not just a uniqueness check.
What the Interviewer Expects
- Scope keys per user and fingerprint the request body
- Return the stored response for a completed duplicate, reject a key reused with a different payload
- Handle the in-flight duplicate explicitly (409 or wait), not by running the work twice
- Decide what happens to the key when the operation fails
- Move the record to durable storage with a unique constraint in production
- Give keys a TTL
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How do you make this safe across many app servers instead of one process lock?
- The payment succeeded but the order write failed; how do you recover?
- How long should keys live, and what does the client do after expiry?
- How would downstream services (Coupang Pay, inventory) stay idempotent too?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
place_order(user_id, idem_key, payload) must create at most one order per (user, key). A retry with the same key and same cart returns the original result. Same key with a different cart is a clie...
High-Level Design
Keep an idempotency record per (user_id, key) with a payload hash, a state (in_progress or done), the stored response and an expiry. The check-and-insert happens atomically; the expensive work r...