Exercise · Marketplace & Booking

Flash Sale

Whiteboard exercise. Try the problem cold, then reveal the rubric to self-score.

Out of 10 points45 min whiteboardReference solution →
01

Prompt

100K users hit "Buy" at the exact same second for 1K limited items. No overselling. The hard parts: a waiting room that absorbs the thundering herd without crashing your backend, atomic inventory decrement that never goes negative even under 100K concurrent requests, and a payment pipeline that pre-authorizes cards before entering the queue so checkout is instant for winners. Amazon Prime Day, Xiaomi phone drops, Supreme releases — same pattern, different merch.

Time budget: 45 min whiteboard. Draw architecture, estimate numbers, discuss tradeoffs.

02

Hints (progressive — click to reveal)

Hint 1

Lead with the waiting room. "100K users → 500/sec admission rate → smooth backend load." This is the insight that separates good from great.

Hint 2

Redis Lua for atomic inventory. Name it explicitly — "single Redis key, Lua DECR-if-positive, no race." Shows you've actually built these systems.

Hint 3

Pre-auth payment in queue. This UX detail (checkout = one click, not "enter card") is the kind of production nuance interviewers love.

03

Rubric — 10 points

  • +2 Lead with the waiting room. "100K users → 500/sec admission rate → smooth backend load." This is the insight that separates good from great.
  • +2 Redis Lua for atomic inventory. Name it explicitly — "single Redis key, Lua DECR-if-positive, no race." Shows you've actually built these systems.
  • +2 Pre-auth payment in queue. This UX detail (checkout = one click, not "enter card") is the kind of production nuance interviewers love.
  • +2 Bot mitigation is load-bearing. Without it, bots take all 1K items. CAPTCHA + proof-of-work + device fingerprinting. Don't skip this.
  • +2 Distinguish from Ticketmaster. Ticketmaster = seat selection + hold pattern. Flash sale = single SKU + atomic counter. Simpler inventory model, harder contention model.

Self-score: tally the points you would have mentioned unprompted. 7+ is interview-ready on this problem.

04

Red flags (things that tank the interview)

  • SELECT stock FROM products WHERE id=X; if stock > 0 then UPDATE stock = stock - 1
  • Let all 100K users hit checkout simultaneously — "the server will handle it"
  • Checkout asks user to enter card info after winning the slot