Design Ticketmaster
hard 55 minSell numbered seats to far more people than there are seats.
How to approach it
What this question tests, where it gets hard, and how to spend the time.
Read the question
What this problem tests
Can you split it?
A crowd at the door, and one seat with two buyers.
Can you prove no oversell?
Show the statement that decides.
Can you handle money?
Unknown answers, retries, refunds.
Can you shape load?
Admission instead of more servers.
Think
Five questions before you draw
| Ask yourself | Here |
|---|---|
| Who does what? | Fans look, wait, hold and pay; organisers publish events |
| What must never go wrong? | One seat sold twice, or money without a seat |
| What is the hardest thing? | A payment that takes minutes while others want the seat |
| What breaks first as it grows? | Reads of popular pages, then the first minute of a sale |
| What am I giving up? | People wait outside, and the map is a little old |
The interview, in order
Spend the 45 minutes
| Minutes | Do | Leave with |
|---|---|---|
| 0 to 5 | Browse, hold, buy; one huge sale | Targets and a hold time |
| 5 to 10 | Normal day and sale minute | 280 to 1, 83 holds a second |
| 10 to 15 | Hold and checkout requests, seat states | available, held, paying, sold |
| 15 to 25 | Version 1, then holds, caches, room | A working purchase |
| 25 to 40 | Seat contention, then waiting room | A statement and a public number |
| 40 to 45 | Payment timeout, recap | A clear last sentence |
Lines you can open with
- 1
Start
"There are two problems here: a crowd and a seat. I will make the seat correct first, then protect it from the crowd."
- 2
Park something
"Search is a known shape. I will draw the box and come back if you want."
- 3
When stuck
"Which row decides, and what state must it be in?"
- 4
Close
"A steady door, one conditional update, authorise then sell then capture."
Do
- Draw the seat's states
- Count what is left after admission
- Say what happens on a timeout
- Keep the map a hint
Traps
- A distributed lock before any number
- Charging inside a database transaction
- Autoscaling as the answer to 14 million
- Random places for latecomers