System Design: Ticketmaster (Walnut Tix: Seat Maps, Seat Holds, a Fair Waiting Room, Bots, Rotating Ticket Codes, Offline Gates, Resale)
We design a ticket service for concerts and sports, like Ticketmaster, and call it Walnut Tix.
Fans find an event and pick seats on a map. Then they pay and get tickets on their phones.
At the venue, a scanner at the gate reads each ticket. Fans can also pass a ticket to a friend, or sell it to another fan.
Most of the year this is easy: a few tickets a second. The hard day is the on-sale, when millions of fans arrive at 10:00 for a few thousand seats each. This post covers that day, and the show days after it.
As in any system design interview, every number here is our own assumption for planning, and the design is our own.
All times are in US Eastern Time unless a line says otherwise. Phoenix is two hours behind.
How to read this post. It takes about 67 minutes in full, so it is built to be read in parts:
1. Requirements
1.1 What we are building
Walnut Tix does four jobs:
- Sell each seat once. Show every seat on a map, and hold the seats a fan picks while they pay. Never sell one seat to two fans.
- Survive the rush, fairly. Take millions of fans at 10:00 and put them in a fair order nobody can choose. Let them shop a few thousand at a time.
- Keep bots out. Stop people who use thousands of accounts to buy tickets and sell them at higher prices.
- Let the right person in. Put tickets on phones in a form a screenshot cannot copy. Scan them at the gate even without internet, and let fans pass or sell tickets safely.
The story. The pop singer Luna Hart puts a stadium tour on sale: 40 shows, each with 60,000 seats.
- Thu 29 Oct, 10:00. The presale opens for fans who registered weeks ago and got a code. It sells 40,000 of the 60,000 seats of each show. In Boston, Hannah Lee joins the queue for the Boston show at Harbor Stadium. The queue's draw puts her at position 4,812.
- 10:07:56. Hannah's turn comes. At 10:10:30 she picks two seats in block 112, and they are held for her for 8 minutes.
- 10:12. Her card is declined. She pays with a second card at 10:13:10, and the order is done.
- Fri 30 Oct, 10:00. The general sale opens for 20 shows; the other 20 go on sale the next week. From 09:00, 3 million fans join queues. In the first minute after 10:00, 15 million phones, computers and browser tabs ask for their turn: about 5 for each fan.
- 10:00 to 11:00. A bot operation called SeatSnatch tries to buy tickets with 50,000 accounts.
- 10:04:21. In Phoenix it is 08:04. Tyler Scott gets his turn, at position 2,950 for the Phoenix show. He buys four tickets at 10:08.
- 10:16. The Phoenix show sells out.
- 10:20. One zone of our US East region fails. Megan Diaz, our on-call engineer, watches the sales go on from the other zones.
- Mon 2 Nov. Josh Turner buys a resale ticket for the Phoenix show from a fan who cannot go.
- Sat 13 Mar 2027. A storm on the way cancels the second Phoenix show, set for the next day. 60,000 tickets are refunded.
- Sat 20 Mar 2027. At 17:00 Hannah passes one ticket to her friend Amy Chen. The gates open at 18:00. At 18:30 the stadium's internet link fails for 20 minutes.
What happens to each person:
- Hannah gets her turn at a time she could have worked out herself, and keeps her seats while she fixes her card.
- Tyler's place in the queue did not depend on how fast his computer was.
- SeatSnatch buys about 300 tickets instead of thousands.
- During Megan's failure, no event's sales stop for more than about 15 seconds.
- Josh pays at most the price cap, and gets a ticket that only he can use.
- Amy enters at 18:41 with her ticket, while the internet is still down. Hannah's old code for that seat no longer works.
- The Phoenix fans get their money back within minutes of the cancellation.
The hard part has four sides:
- At 10:00, 15 million devices arrive within a minute. Each show has 60,000 seats.
- Thousands of fans want the same few seats at once, and none may be sold twice.
- Fair order matters as much as speed: nobody, not even our staff, may choose who goes first.
- A ticket must work at a gate with no internet, and must not work twice.
1.2 Words we use
Words used in only one place are explained there. Each word below is used all through the post.
Events and seats.
| Word | Meaning here |
|---|---|
| Event | One show at one venue on one date, such as Luna Hart at Harbor Stadium on 20 March |
| Venue | The place of the event, such as a stadium |
| Block, row, seat | Where a seat is: block 112, row F, seat 7. Many venues call a block a section |
| Seat map | The drawing of the venue that shows which seats are free |
| General admission | Tickets with no seat, for a standing area. Interviewers say GA |
| Face value | The price Walnut Tix first sold the ticket at |
Buying.
| Word | Meaning here |
|---|---|
| On-sale | The moment tickets go on sale, such as Friday at 10:00 |
| Presale | A sale before the on-sale, for fans with a code |
| Queue | The line of fans waiting for their turn to shop, kept by the Waiting room |
| Turn | The moment a fan is let in to shop |
| Now serving | The last queue position let in to shop, such as 2,950. Every fan's app reads it to know how close its turn is |
| Hold | Seats kept for one fan while they pay. A hold ends by itself after 8 minutes |
| Order | A paid purchase of one or more tickets |
| Ticket limit | The most tickets one buyer may buy for one event: 6 |
Tickets and entry.
| Word | Meaning here |
|---|---|
| Ticket secret | A private key that the fan's phone makes once for its tickets. It never leaves the phone, and it signs each ticket's code |
| Signed ticket | The ticket ID, its version and the phone's public key, signed by Walnut Tix. A scanner checks it with our public key |
| Rotating code | A code on the ticket screen that changes every 15 seconds, so a screenshot stops working |
| Scanner | A handheld device at a gate that reads ticket codes |
| Valid list | The list of an event's tickets with their current versions, kept on every scanner |
| Transfer | A fan passes a ticket to another fan. The ticket gets a new secret |
| Resale | A fan sells a ticket to another fan through Walnut Tix |
The system.
| Word | Meaning here |
|---|---|
| Region | One of our two groups of data centers: US East in Virginia, and US West in Oregon |
| Zone | One building or group of buildings inside a region, with its own power |
| Shard | One slice of a store, holding some keys. Each shard has copies in three zones |
| Primary | The one copy of a shard that takes writes. If it fails, another copy is promoted to primary |
| Lease | A claim that ends by itself after a set time unless it is renewed |
| Owner | The one server that does a job for one event, under a lease. The Hold service's owner applies every hold of its event |
| Epoch | A number that goes up by one each time a new owner takes over. Writes with an older epoch are refused |
| p99 | The time 99 of every 100 requests finish within |
| CDN | Content delivery network: servers in many cities that keep copies of files near users |
| Fingerprint | A hash of a value, such as SHA-256. The same value always gives the same fingerprint, and nobody can work the value back from it |
IDs in this post. Every ID below is made up.
| ID | What it names | Example from the story |
|---|---|---|
| ev_BOS20 | An event ID | Luna Hart at Harbor Stadium, Boston, 20 March |
| ev_PHX13 | An event ID | Luna Hart in Phoenix, 13 March |
| ev_PHX14 | An event ID | The second Phoenix show, canceled |
| u_2207 | A user ID | Hannah Lee |
| u_8840 | A user ID | Tyler Scott |
| q_7Q31 | A queue ticket ID | Tyler's place in the Phoenix queue |
| h_51K | A hold ID | Hannah's hold on two seats |
| o_51K | An order ID | Hannah's order |
| t_51K1, t_51K2 | A ticket ID | Hannah's two tickets; t_51K2 goes to Amy |
| l_7730 | A listing ID | The resale ticket Josh buys |
1.3 Every kind of request and change
Walnut Tix handles more than the story shows. This table lists every kind. Each part it names is explained where it first appears in the design.
| Kind | What it is | How big or how often | Part that handles it | Outside company that takes part |
|---|---|---|---|---|
| Search | A fan looks for an artist, a venue or a city | about 3,000 a second on a normal day | Search service | none |
| Event page | Dates, prices, the seat map | about 250,000 requests a second in the rush, mostly cached | Event service, CDN | A CDN company |
| Queue | A fan joins the line, and checks their place | 3 million fans; 100,000 checks a second | Waiting room | A public random number service, for the draw |
| Hold | Seats kept for a fan while they pay | about 30 writes a second per event in the rush | Hold service, Inventory store | none |
| Order | A payment turns a hold into tickets | 500 a minute per event | Order service | A card payment company |
| Ticket | Tickets appear in the fan's app | 3 tickets per order on average | Ticket service | Phone wallet companies, for wallet passes |
| Entry | A scanner reads a ticket at the gate | 60,000 in 90 minutes per event | Scanners, Gate hub | none |
| Transfer | A ticket goes to another fan | thousands a day | Ticket service | none |
| Resale | A fan sells a ticket | thousands a day | Resale service | The card payment company |
| Refund | Money back for a canceled event | 60,000 per canceled event | Refund job | The card payment company |
1.4 Functional requirements
- Find events. Search events by artist, venue, city and date. Show each event's page.
- Seat map. Show which seats are free, updated within a few seconds.
- Hold. Keep the seats a fan picks for 8 minutes while they pay. Never let two fans hold or buy one seat.
- Queue. On a big on-sale, put fans in a fair order and let them shop a few at a time.
- Limits. At most 6 tickets per buyer per event, and checks that stop bots.
- Pay. Take payment and turn the hold into an order and tickets.
- Tickets. Put tickets on phones with codes a screenshot cannot copy, and offer other ways for fans with no smartphone.
- Entry. Scan tickets at the gates, also when the venue has no internet, and let each ticket in once.
- Transfer and resale. Let fans pass tickets to others and sell them, at most at a price cap.
- Refund. Refund every ticket of a canceled event.
Out of scope: setting prices, seat layout tools for venues, and how artists are paid.
1.5 Non-functional requirements
- Never sold twice. No seat is held by two fans or sold to two fans, in any failure.
- Fair order. A fan's place in the queue does not depend on device speed, and nobody can choose it.
- The rush. 15 million devices in the first minute without the site going down.
- Hold speed. A hold answers in 300 ms at p99.
- Seat map. A seat taken by someone else shows as taken within 5 seconds.
- Entry. A scan answers in under 1 second, with or without internet at the venue.
- Refunds. All tickets of a canceled event are refunded within 1 hour.
- Availability. If a zone fails, sales go on within 30 seconds. If a whole region fails, they go on within 1 minute.
1.6 The numbers
These are rough sums, the kind a candidate does at a whiteboard in a few minutes. Every number is our own assumption.
Walnut Tix sells 500 million tickets a year. We plan for the busiest moment of the year: a big tour's general sale.
| Number | How we get it | Result | What it decides |
|---|---|---|---|
| A normal day | 500 million tickets a year ÷ 365 = 1.4 million a day. ÷ 86,400 | About 16 tickets a second | Normal days are easy. Everything below is about the rush |
| The rush | 3 million fans have about 5 devices or tabs each. The 15 million devices each ask for the queue's "now serving" number every 5 seconds | 3 million requests a second | That number is a small file served by the CDN, cached for 1 second; almost none of these requests reach our servers |
| Queue checks | Only the one app holding a fan's queue ticket asks for its place: 3 million fans, every 30 seconds | 100,000 a second | The Waiting room is built for 150,000 a second, apart from the sale itself |
| Shoppers | Each event lets 1,500 fans shop at once. A fan shops for about 3 minutes, so 500 finish a minute | 500 orders a minute per event | The order a fan's turn comes in is worked out from these two numbers |
| Seat writes | 500 orders a minute × about 3.5 writes each: the hold, the sale and the buyer's count, plus freed seats from holds that end unpaid = 1,750 a minute, about 30 a second per event. × 20 events | About 600 writes a second | One owner per event can apply every hold in order; a relational store is enough |
| Seat map | 60,000 seats × 2 bits each, for free, held or sold | 15 KB per event | The whole map's state goes to each shopper every 2 seconds |
| Shopper requests | 20 events × 1,500 shoppers, each with one request every 2 seconds | 15,000 a second | The shopping part is small next to the waiting |
| Gate | 60,000 fans in 90 minutes through 120 lanes | About 5.6 scans a minute per lane | The lanes limit entry, not our servers |
| Valid list | 60,000 tickets × 40 bytes | 2.4 MB per event | Every scanner keeps the whole list, so it works without internet |
What these numbers tell us. The writes are few: 600 a second at the worst moment. The hard parts are elsewhere:
- 3 million requests a second at 10:00, almost all of them asking the same question;
- thousands of fans wanting the same seats, with no seat sold twice;
- a fair order that a computer's speed or a staff member cannot change.