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
Software Engineering Fundamentals
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

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
reservations
invariants
lazy expiry
idempotency
dependency injection
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. 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 Problems
Sample Answer
Requirements
  • hold(sku, qty, ttl) returns a hold id or None if 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...


Submit Your Answer
Markdown supported