SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 42
Design a giveaway for 6 million free items in one hour
A restaurant chain announces during a TV broadcast that the first 6 million people to claim in its app get a voucher for a free burger, redeemable at any of its 20,000 restaurants over the next 30 days. Claims open at noon. People will hammer the button, retry, reinstall and try every trick to get more than one.
Requirements
- A signed-in user can claim at most one voucher.
- Never issue more than 6 million vouchers in total; every voucher has a unique code.
- A user who got a voucher sees the same voucher after a crash, retry or reinstall.
- Users who miss out are told quickly and clearly instead of waiting on a spinner.
- Restaurants validate and redeem each voucher exactly once at the counter.
Constraints and assumptions
- 6,000,000 vouchers; about 30 million users expected to try in the first 10 minutes.
- Up to 500,000 claim requests per second in the first minute, including retries, then falling off.
- Claim responses within 2 seconds at p99, or an honest "you are in line" with a position.
- Expect organized abuse: scripts and farms of thousands of fresh accounts.
- Redemption peaks at about 3,000 per second during lunch hours over the following weeks.
Out of scope for the first sketch
The marketing landing page and TV integration · Restaurant point-of-sale internals beyond a redeem API · Follow-up marketing campaigns
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design a giveaway for 6 million free items in one hour
Finish your first sketch before answering these. Cross out freely.
- One "remaining stock" counter receives 500,000 decrement attempts per second. What happens, and how do you spread the load?
- A user taps Claim, the app times out, and they tap again. How do they end up with exactly one voucher?
- If stock is split across shards, one shard runs dry while others still have stock. How do you avoid saying "sold out" too early, and how do you end at exactly zero?
- What does "fair" mean here? Would a virtual queue or a lottery be fairer than first come, first served?
- A farm of 50,000 fresh accounts joins at noon. What do you do before, during and after the claim window?
Compare afterwards: worked approaches and reading at sketchbook /questions/limited-giveaway/review