Model Expiring Checkout Holds on Inventory Without Overselling
Last updated: November 29, 2026
Quick Overview
Design an inventory ledger where checkout places a temporary hold on units, holds expire if the order is not placed in time, and placing the order converts the hold into a real decrement, so available stock never goes negative.
Amazon
November 29, 20260
0
0 solved
Design an inventory ledger where checkout places a temporary hold on units, holds expire if the order is not placed in time, and placing the order converts the hold into a real decrement, so available stock never goes negative.
Amazon checkout reserves inventory while a customer confirms payment, especially for limited Lightning Deals, and abandoned carts must return stock quickly. The interviewer checks that you separate on-hand from reserved quantities, handle expiry deterministically, and make commit and release idempotent.
What the Interviewer Expects
- Separates on-hand, reserved, and available quantities
- Expires holds lazily using a heap of deadlines
- Makes commit after expiry fail cleanly
- Treats repeated release or commit of the same hold as a no-op
- Injects a clock so expiry is testable
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 would this work across many hosts backed by DynamoDB?
- How would you notify a customer whose hold expired during payment?
- Would you ever allow overselling deliberately, and how would you bound it?
- How would you choose the hold TTL?
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
hold(sku, qty, ttl)returns a hold id orNoneif not enough available.commit(hold)turns the hold into a permanent decrement;release(hold)returns units.- Expired holds return their uni...
High-Level Design
Track on_hand and reserved per SKU plus a dict of live holds. A min-heap of (expires_at, hold_id) lets every public method first sweep expired holds in deadline order. Commit removes the hold an...