Layer 3 · Go deeper · 12 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
How fast can one database row sell the stock?
How many Redis primaries does a 200,000-a-second race need?
How long do the orders and payments take?
How many phones come back, and how many stay unsold?
Build-up · 5 steps
Build the high-level design
One functional requirement at a time, with the stock as one row in a database. It works for a few hundred units.
Step 1 of 5
See the sale page
The page is the same for everyone, so the CDN serves it and caches a tiny status object for a second. The countdown runs on the phone, corrected by the server’s clock.
6 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 6
Interviewer
“No draw, just a race: 200,000 claims a second for 10,000 identical phones. How do you take one unit without overselling?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“Even eight buckets take a sixth of the 2 million claims a second. How do you keep 5 million people away from the counter?”
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“Ten thousand yeses arrive within about a second. The store’s order pipeline peaks at 1,200 orders a second. How do you create the orders?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“If 15% of winners don’t pay, 1,500 phones must come back. How do you return them without overselling or stranding them?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“A ₹9,999 phone resells for ₹15,000, so resellers bring patient, well-funded automation. How do you keep it to one per customer?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“In 2016 one merchant’s flash sale took down every store on its Shopify database shard. How do you protect the rest of the store?”
Your move. Pick an approach:
Build-up · 8 steps
Follow one claim through the sale
Everything that says no is at the edge, everything that says yes is one script on one bucket, and everything that makes the yes real is behind a queue.
Step 1 of 8
Register
Days before the sale, the passes service runs the identity checks and issues each shopper a signed sale pass, valid from 12:00 to 12:15. The slow checks happen while there’s time.