System Design Interview: Designing a Ticket Booking System (Ticketmaster-style)
The hard part isn't browsing events; it's selling a limited number of seats to a crowd that all clicks "buy" in the same second.
Requirements
- Browse events and see a seat map with availability.
- Hold seats for a few minutes during checkout; never sell the same seat twice.
- Survive "on-sale" spikes: 1M users arriving for 50k seats.
Data model
event(id, venue_id, start_time)seat(event_id, seat_id, status, hold_expires_at, order_id)with status in AVAILABLE / HELD / SOLD.
Holding seats without double-selling
Use a conditional update so only one request can win a seat:
UPDATE seat
SET status = 'HELD', hold_expires_at = now() + interval '8 minutes', order_id = :order
WHERE event_id = :e AND seat_id = ANY(:seats)
AND (status = 'AVAILABLE' OR (status = 'HELD' AND hold_expires_at < now()));
If the number of updated rows is less than requested, roll back and tell the user those seats are gone. Expired holds are reclaimed by the same predicate, so no cleanup job is strictly required (one still helps keep the seat map accurate).
A Redis SET seat:{e}:{s} order NX PX 480000 is a faster alternative for holds, but the database stays the source of truth for SOLD.
Payment
Checkout calls the payment provider with an idempotency key. On success, flip HELD to SOLD in a transaction that checks the hold still belongs to this order. If the hold expired mid-payment, refund automatically.
Handling the spike
- Virtual waiting room: put arriving users in a queue and admit them at a rate the booking service can handle. This is the single most important idea.
- Serve the seat map from a cache refreshed every second or two; it only needs to be approximately right because the hold step is authoritative.
- Rate-limit per user and use bot detection.
Follow-ups
- General admission (no seat numbers): decrement a counter atomically instead of locking seats.
- Fairness: randomize queue position for people who arrived before the sale opened.
Disclosure: I'm part of Linkjob AI, an AI interview assistant.