Design Inventory for a Flash Sale
Twice a year we run a two-day sales event where the best deals open at a set time with a limited number of units. Last year the most popular deals sold more units than we had, and we had to cancel thousands of orders the next morning. We need the inventory side of these deals redesigned before the next event.
This brief is incomplete on purpose, as it would be in a real interview. Ask the interviewer about the users, the features, the targets and the traffic. Whatever you uncover is added below.
Nothing uncovered yet.
Nothing uncovered yet.
Nothing uncovered yet.
- The API for claiming, paying for and releasing a unit
- The data model for deals, holds and orders
- The request path for a claim in the first second of a popular deal
- The capacity estimate behind your choices
Every claim takes a unit with a single atomic conditional operation on the authoritative stock (compare-and-decrement, a conditional update, or popping a pre-created unit token), so two concurrent claims can never both take the last unit; the per-shopper count is checked in the same atomic step.
The design works out that a top deal sees tens of thousands of claims a second on one item (66 million visitors, 5% in 60 seconds is about 55,000 per second) and splits its units across several shards or sub-pools that are claimed independently, while their total still equals the allocation.
A hold records its expiry; expiry is driven by a delayed queue or TTL and returns the unit to the pool exactly once, and a payment that arrives after expiry is rejected or must claim again.
Page loads read a cached or pushed count refreshed about once a second (hundreds of thousands of reads a second before a popular opening), never the authoritative stock.
Each deal's stock (or each shard of it) is owned by exactly one region at a time under a lease with fencing, so a region that comes back cannot keep selling units another region has taken over.
Every functional requirement in the brief is visibly served by something on the board, and the non-functional targets are addressed rather than ignored.
Components are labelled, data flows are drawn as connections between them, and the direction of each flow is unambiguous.
Focus on claiming, holding and selling deal units. Payment processing, fraud checks and shipping are out of scope: assume a payment service that confirms or declines within a few seconds. Product pages and search exist already.
- Views
- 2