Design Inventory Reservations
HardSystem design · Commerce · Amazon
Design an inventory reservation service for scarce items (flash-sale products, seats, rooms): callers reserve a quantity, pay, then confirm, and abandoned holds expire and return stock. Scale: 500K SKUs, 5K reservations/s normally and 50K attempts/s on a single hot SKU with about 1,000 units. Zero oversell. Cover the atomic conditional decrement, hold records and expiry, idempotent confirm and release, hot-SKU contention, and reconciliation with the warehouse.
Requirements
- Available stock never goes below zero: the check and decrement are one atomic operation on the authoritative store
- Holds expire reliably, and an expired hold is treated as expired even if the sweeper is late
- Reserve, confirm and release are idempotent with clear states: held, confirmed, released, expired
- Handle contention on hot SKUs without losing the zero-oversell guarantee