Design BookMyShow / Ticketmaster (ticket booking)
Design a system for booking seats at events. Seats are specific and numbered. Popular events sell out in under a minute, with far more people trying than there are seats. Nobody may ever end up with a seat somebody else also has.
About this problem
“Design BookMyShow / Ticketmaster (ticket booking)” is a core-level problem in the contested inventory family. A fixed number of things and more people who want them than there are things.
The key challenge: Almost everything here has generous slack. One operation has none at all, and that operation is the problem.
Time budgets: Browsing: minutes. Holding a seat: minutes. The commit: zero.
The worked solution for Ticket booking goes through why those budgets shape the design, stage by stage.
Before you start
You will work this in five timed stages. Here is what each one asks you to think about. None of it is the answer; the answers unlock in the workspace below once you have written your own.
- Stage 1 · Requirements · 5 min
- What is the one question that decides whether you need locking at all?
- Assigned seats versus general admission — does it change the design?
- What is the traffic shape? It is not steady.
- Stage 2 · Actors and lifecycle · 6 min
- Follow the seat, not the user. The seat is the contended thing.
- What expires, and who expires it?
- What happens if payment succeeds but the confirmation write fails?
- Stage 3 · Numbers · 6 min
- What does the traffic graph look like in the first minute?
- How many seats actually exist? Compare that to how many people want them.
- What fraction of requests are reads?
- Stage 4 · High-level design · 12 min
- Which parts can be stale, and which cannot? Draw that line first.
- What makes it impossible for two people to get one seat?
- How do you stop 100,000 people hitting the database at once?
- Stage 5 · Deep dive and tradeoffs · 14 min
- What happens when 20,000 people all try for the same front-row seat?
- The hold expires while the card is being charged. Walk through it.
- Is a distributed lock needed here? Justify your answer either way.
Work it through
Five stages, gated. You write your answer for each stage before its model answer unlocks. That is the core of the method.
Done all five? The diagrams, numbers, trade-offs and follow-ups for this problem are on the worked solution page, to check your own design against.
How it is really built
Write your own answer first. Then read how teams who run this at scale describe it. Their constraints were real, and the write-ups often say what their choices cost.
- PostgreSQL — Transaction Isolation ↗The isolation levels that decide whether you can sell the same seat twice.