Make Checkout Order Placement Idempotent Under Client Retries
Last updated: November 29, 2026
Quick Overview
A mobile client retries the place-order call when the network drops, and some customers are being charged twice for the same sectional. Design and implement an idempotency-key mechanism so retries return the original result and never create a second order.
Wayfair
November 29, 20260
0
0 solved
A mobile client retries the place-order call when the network drops, and some customers are being charged twice for the same sectional. Design and implement an idempotency-key mechanism so retries return the original result and never create a second order.
Checkout is Wayfair's most revenue-critical path, and big-ticket furniture orders make a duplicate charge very visible to the customer. This fundamentals round checks whether you understand at-least-once delivery, atomic claims on a key, and what to return while a first attempt is still in flight.
What the Interviewer Expects
- Has the client generate one key per logical checkout attempt
- Claims the key atomically with a unique constraint, not a read-then-write
- Stores a request fingerprint and rejects reuse with a different body
- Replays the stored response for completed requests
- Handles the in-progress case and key expiry
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
- The payment call goes to an external processor. How do you keep the order and the charge consistent if the process crashes between them?
- How long should keys live, and what happens when one expires mid-retry?
- The orders service is sharded by customer. Where does the key table live?
- How would you test this under concurrent duplicate requests?
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
- Retries with the same
Idempotency-Keyheader must produce exactly one order and the same response. - Same key with a different body is a client bug: return 422.
- A retry that arrives while the fi...
High-Level Design
The client creates a UUID when the shopper taps Place Order and reuses it on every retry. The server keeps a table idempotency_keys(key PK, request_hash, status, response). Step one is an INSERT t...