"Design Ticketmaster" is a question about a very specific day: the minute tickets for a popular show go on sale. On most days the system is idle. For a few minutes, millions of people arrive at once, all want the same 60,000 seats, each seat can be sold exactly once, and a good share of the traffic comes from bots.
The interviewer is testing whether you design for that spike and not the average day. Two ideas carry the answer: a seat hold that expires on its own, so a seat is neither double-sold nor stuck forever, and a waiting room, so the surge is admitted at a rate the booking system can survive. The nearby questions are different: a hotel sells counters of identical rooms, and a flash sale sells a stock number. Here every item is unique and chosen by the buyer, which changes the contention.
Background: idempotency for safe retries and rate limiting for admission.
Clarify the requirements
Functional requirements:
- Browse events and see an interactive seat map with availability.
- Select seats and hold them while checking out.
- Pay and receive tickets, or release the seats if the hold expires.
- Limits per customer (for example, up to 4 tickets per event).
- Organizers create events, seat maps and price tiers.
Out of scope, said aloud: ticket resale and transfer, dynamic pricing, QR entry validation, the payment processor internals, and venue operations.
Non-functional requirements: these decide the design.
- A seat is sold at most once. Selling one seat to two buyers is the failure that makes the news.
- A surge must not take the site down. Admission control is a requirement, not an optimization.
- Fairness matters. People will accept losing a lottery, and will not accept losing to a bot or to someone who found a faster route into the queue.
- Holds must expire. A seat held by an abandoned checkout has to return to the pool without human help.
- Browsing may be stale; buying may not. The seat map can be a second or two old, the hold and the sale cannot.
Estimate the scale
Assume one on-sale for a stadium of 60,000 seats, with 2 million fans online at the start.
The surge: if each of the 2 million refreshes the seat map or polls their queue position every 10 seconds, that is 2M ÷ 10 = 200,000 requests per second. The average day is nothing like this.
Seat map size: one bit per seat for availability is 60,000 ÷ 8 = 7.5 KB. If every one of those 200,000 requests fetched it, the bandwidth would be 200,000 × 7.5 KB = 1.5 GB per second, which is why the map must come from a CDN with a one- or two-second cache.
Purchases: with an average of 2.5 seats per order, selling out means 60,000 ÷ 2.5 = 24,000 orders. Many admitted users abandon or lose a race, so suppose 1 in 4 admitted users completes a purchase: about 96,000 users must pass through checkout.
Admission rate: to sell out in about 10 minutes, admit 96,000 ÷ 600 = 160 users per second. This is the number the waiting room enforces. Behind it, the booking system faces about 160 new shoppers a second, not 200,000.
Hold data: 60,000 seats × about 100 bytes of hold state = 6 MB. It fits in memory with room to spare.
"The surge is 200,000 requests a second against a system whose purchase path needs about 160 admitted users a second. Almost all traffic has to be answered by a CDN or a waiting room before it ever reaches the booking path. And the seat state is only 6 MB, so contention, not size, is the problem."
The capacity estimator shows the daily totals for this one event. Remember it averages over a day, while the real load arrives in minutes, so use the peak figures above for design.
API and data model
GET /v1/events/{id}/seatmap -> availability bitmap + sections (CDN, TTL 1-2 s)
POST /v1/events/{id}/queue -> { queueToken, position? }
GET /v1/events/{id}/queue/status -> { admitted?, admitToken?, eta }
POST /v1/events/{id}/holds { seatIds[] } -> { holdId, expiresAt } (admit token required)
POST /v1/holds/{id}/checkout { paymentToken } -> { orderId } (Idempotency-Key header)seat hold (Redis): key = hold:{eventId}:{seatId} value = {holdId, userId} TTL = 300 s
seats (event_id, seat_id PK, section, price_tier, status: available|sold, order_id?)
orders (id PK, user_id, event_id, status, total)
order_seats (event_id, seat_id) UNIQUE -- the final guard against a double saleThe non-obvious choice is where "held" lives. A hold is a temporary claim with an expiry, so it goes in a store with built-in TTL. A sale is permanent and goes in the transactional database with a unique constraint. Two stores for two lifetimes.
High-level design
The slice worth running is the hold path: a gateway that admits only waiting-room-approved traffic, a hold service, a fast store for seat holds and the order database where a sale is made permanent.
- Clients reach the hold API through a gateway that checks admission.
- The hold service claims seats in Redis with an expiry, and a completed checkout writes the order to the order database.
Describe this diagram
Components
- clients (Client)
- gateway (API gateway)
- hold api (Service)
- seat holds (Redis)
- order store (PostgreSQL)
Connections
- clients sends to gateway
- gateway sends to hold api
- hold api sends to seat holds
- hold api sends to order store
Run it, then try raising the load to see where the hold service and the order database start to queue.
The browse path: the seat map and event pages are static or near-static, so they are served from a CDN with a short TTL. They never touch the booking path.
The hold path: an admitted user picks seats, the hold service claims each seat atomically in Redis with a 5-minute expiry, and returns a hold id. The hold is checked again at checkout.
The purchase path: the user pays. The service inserts the order and its seats in one transaction, and the unique constraint on (event_id, seat_id) makes a double sale impossible. On success, the hold keys are deleted. If the hold expired, the checkout fails and the user is sent back to the seat map.
The interesting problem: holding a unique seat under contention
Thousands of people click on the same front-row seat within the same second. Exactly one may hold it, and the hold must vanish if that person walks away.
Approach A: lock rows in the database
SELECT ... FOR UPDATE on the seat row, set status = 'held', held_until = now + 5 min.
Good: one source of truth, with transactional guarantees and no second store.
Bad: hot seats become lock queues, and the whole surge hits the database. Expiry needs a sweeper scanning for stale holds, and until it runs, a seat looks held when the person left. At tens of thousands of attempts a second the database becomes the bottleneck.
Approach B: a conditional update with an expiry column
UPDATE seats SET held_by = ?, held_until = ? WHERE seat_id = ? AND (held_until IS NULL OR held_until < now()).
Good: atomic, no explicit lock, and expiry is folded into the condition so there is no sweeper.
Bad: every hold attempt, including the thousands that fail, is a database write attempt. The hot seat is still a hot row.
Approach C: holds in Redis with a TTL, sales in the database
The hold is one atomic command: SET hold:{event}:{seat} {holdId} NX EX 300. It succeeds only if the key does not exist, and expires on its own after 300 seconds. A multi-seat hold uses a short Lua script that checks and claims all seats or none, so a user never ends up with half of a pair. The database is touched only at purchase.
Good: Redis serves a hold attempt in microseconds, failures are cheap reads, expiry is automatic, and only buyers who reach payment reach the database.
Bad: two stores to keep consistent, and a Redis failover can lose recent holds.
The recommended answer is C, with the database as the backstop. The unique constraint on order_seats means that even if a Redis failover drops holds and two buyers both believe they hold seat 14B, only one checkout commits. The other sees a clear "seat no longer available" and can pick again. State the principle: the fast store makes the experience smooth; the database makes it correct.
Diagram, as text
- Admitted user picks seats leads to Redis: SET NX EX, all or none
- Redis: SET NX EX, all or none leads to Payment, up to 5 minutes (claimed)
- Redis: SET NX EX, all or none leads to Pick other seats (taken)
- Payment, up to 5 minutes leads to Postgres: insert order seats, unique per seat
- Postgres: insert order seats, unique per seat leads to Tickets issued, holds deleted (committed)
- Postgres: insert order seats, unique per seat leads to Pick other seats (unique violation)
The second decision: the waiting room and fairness
200,000 requests a second against a purchase path that needs 160 admissions a second means you must queue people before they reach the booking system.
A virtual waiting room. Fans arriving at the on-sale are given a queue token and sent to a lightweight, mostly static page that polls for admission. The queue state is a sorted structure or a counter, and the page and polling endpoint are fronted by a CDN with a short TTL, so 2 million waiting users cost almost nothing. A controller admits users at the rate you set, 160 a second in our estimate, and adjusts it: slow down if the hold or order latency rises, speed up if checkouts finish quickly. An admitted user receives a signed admission token with an expiry, and the gateway rejects hold requests without one.
What order do people enter? Pure first-come-first-served rewards the fastest connection and the bots. A fairer approach: everyone who arrives before the on-sale time is shuffled into a random order when it starts, and later arrivals follow in arrival order. Say which you chose and why, and note it is a product decision.
Bots and scalpers. Require login before the queue, limit one queue entry per account, add a challenge such as proof of work or a human check on suspicious clients, limit tickets per order and per payment method, and verify the per-customer cap at purchase, not just at hold time. No filter is perfect, so say you would monitor and adjust rather than claim bots are solved.
Idempotent checkout. A double click or a mobile retry on "Pay" must not charge twice. Use an idempotency key per checkout attempt, as in Design a Payment System.
Bottlenecks and failures
The hot seat map. Millions refreshing the map is the largest read load. Serve it as a compact bitmap from a CDN with a one- or two-second TTL, and push changes over a stream only to users already admitted.
Redis failover loses holds. A replica promoted after a failure may be missing the newest holds. The unique constraint at purchase prevents a double sale, and a user may need to reselect. Keep the failure rate low and the message clear.
The order database. Only 160 shoppers a second arrive, so it is comfortable. If payments slow down, holds stay open longer and seats appear unavailable, so alert on payment latency and consider extending holds once when the processor is slow.
What if the waiting room is down? Fail closed, not open. If the room fails and everyone is sent straight to booking, the surge takes down the booking path. Serve a static "please wait" page from the CDN and restore the queue from its stored state.
Abandoned holds. At a 25% completion rate, three quarters of admitted users give up or lose. The TTL returns their seats without any job. Show a visible countdown so users act, and release seats early when a user clicks away.
Inventory sold elsewhere. If tickets are sold through other channels, those channels need the same unique-seat guard or a pre-split allocation. A shared database constraint is the safest meeting point.
Trade-offs to name aloud
- Redis holds plus a database constraint: smooth, fast contention handling, in exchange for two stores and a rare "seat no longer available" after a failover.
- A waiting room: protects the system, at the price of making users wait in a queue they cannot see inside.
- Random order for early arrivals: fairer than arrival time, but harder to explain and not accepted by everyone.
- A five-minute hold: long enough to pay, short enough that abandoned seats come back quickly.
What interviewers listen for
- A working answer: a seat table, a hold with an expiry, a purchase that marks seats sold, and a note that two buyers must not get one seat.
- A strong answer: uses an atomic claim with TTL, backs it with a database constraint, serves the seat map from a CDN, and puts a waiting room in front to control the admission rate with numbers.
- A standout answer: claims multiple seats all-or-none with a script, handles Redis failover without a double sale, chooses a fair ordering policy, plans for bots with per-account limits, and keeps the waiting room failing closed.
Check your understanding
Common mistakes
Scaling for the peak instead of shaping it. Building a booking path for 200,000 requests a second is expensive and unnecessary. A waiting room reduces the problem to the admission rate.
Holds with no expiry. Abandoned checkouts pin inventory forever. Every hold needs a TTL.
Trusting Redis as the only record. A failover can drop holds. The unique constraint on sold seats is the real guarantee.
Half a pair of seats. Claiming seats one by one can leave a user with one of two. Claim all or none in a single script.
First-come-first-served with no thought for bots. The fastest client wins, and it is not a person. Add per-account limits and a fairness policy.
Letting the waiting room fail open. A broken queue that admits everyone takes down the system it was built to protect.
Practice
Midway through an on-sale, Redis fails over and loses about 30 seconds of holds. Users report seeing 'seat no longer available' at payment. What happens in your design, and how do you reduce the damage?
Write your own answer first, on paper or in a note. Then compare.
Show a hint
Ask what the database guarantees, then what you can do about the user experience.
Show a strong answer
What is guaranteed. The unique constraint on sold seats means no seat is sold twice. The users affected had holds that were lost, so some seats were claimed again by other people. At checkout the first buyer may find the seat taken. Correctness holds.
What is hurt. Some users lose seats they thought they held, which is bad but bounded to 30 seconds of holds.
Reduce the damage. Use a Redis setup with replication and keep it healthy. On failover, treat holds created in the affected window as suspect: re-validate them against the database before payment, and offer alternatives nearby instead of an error. Tell users plainly what happened.
The pattern worth keeping: make the cheap store fast and the durable store correct, then design the failure path of the cheap one as a clear, recoverable message.
You see that 5% of accounts account for 40% of the purchases for a hot show. How do you check whether this is abuse and what can you change?
Write your own answer first, on paper or in a note. Then compare.
Show a hint
Treat it as a data question first, then choose limits that do not punish real families buying many tickets.
Show a strong answer
Look at the data. Group by account, payment method, device and delivery address. Real heavy buyers, such as a family or group booking, look different from scripts: many accounts sharing a payment card, device or address, bursts of identical timing, and no earlier browsing.
Add limits at the right points. Enforce a per-event ticket cap per account and per payment method at purchase. Require a stronger challenge for suspicious sessions before they reach the queue, and cap one queue entry per account.
Keep fairness for real buyers. Do not tighten the cap so far that groups cannot buy. Offer a way to verify and raise the limit for known customers.
The pattern worth keeping: find abuse by clustering on shared identifiers, enforce limits at the point of purchase, and tune against false positives, since no single signal is conclusive.
Key takeaways
- Design for the on-sale minute, not the average day.
- Shape the surge with a waiting room: 200,000 requests a second reduce to about 160 admissions a second.
- Hold seats with an atomic claim and a TTL, and claim multi-seat selections all or none.
- The database is the backstop: a unique constraint on sold seats makes a double sale impossible.
- Serve the seat map from a CDN as a compact bitmap with a short TTL.
- Fairness and bots are design problems: choose an ordering policy and limit by account and payment method.
Further reading
- Redis documentation: the SET command with the NX and EX options, and Lua scripting with EVAL.
- Martin Kleppmann, "How to do distributed locking" (2016): why a lock or lease needs a fencing check at the resource.
- Martin Kleppmann, "Designing Data-Intensive Applications" (O'Reilly, 2017): chapters on transactions and the trouble with distributed systems.