Common Problems
Flash Sale
Understanding the Problem
👟 What is a flash sale system?
Unlike many system design interviews, where we design an entire product, this problem zooms in on one particularly challenging part of an e-commerce system: selling a very limited amount of inventory under extreme demand.
To make the problem concrete, imagine Nike is releasing 10,000 pairs of a limited-edition shoe at noon. Tens of millions of users may attempt to purchase them within seconds.
Our job is to design the system that allows those users to fairly compete for the available inventory and complete their purchases without ever overselling.
Functional Requirements
Core Requirements
- Users can view the flash sale item.
- Users can secure/reserve an available unit for a limited time while the sale is active.
- Users who secure a unit can complete payment to purchase it.
The second requirement is the one candidates most often miss. It's tempting to go straight from viewing the product to buying it, but payment runs through a third party and takes seconds, and you can't hold inventory in an open database transaction that whole time. The reservation is what lets you take a unit off the table immediately and settle the money afterward. If you skip it, most interviewers will point you back toward it, though arriving there yourself is better than being led.
Below the line (out of scope):
- Users can browse or search a broader product catalog.
- Users can manage shipping, returns, refunds, or order history.
- Administrators can create, configure, or manage flash sales.
Non-Functional Requirements
Unlike functional requirements, non-functional requirements describe the system qualities that matter to users. These are usually phrased as "the system should be able to..." statements.
The Set Up
Planning the Approach
Defining the Core Entities
API or System Interface
High-Level Design
1) Users can view the flash sale item
2) Users can secure/reserve an available unit for a limited time while the sale is active
3) Users who secure a unit can complete payment to purchase it
Potential Deep Dives
1) How do we maintain consistency under extreme contention?
2) How do we efficiently release expired reservations?
3) How do we handle millions of users arriving at once?
4) How do we make access to limited inventory fair?
Final Design
What is Expected at Each Level?
Mid-level
Senior
Staff+
Purchase Premium to Keep Reading
Unlock this article and so much more with Hello Interview Premium