Case study V.8Advanced

Design a Ticket Booking System Like Ticketmaster

Thousands of people want the same few seats in the same second. The design is about contention: exactly one buyer gets each seat, holds expire cleanly, and the on-sale spike never takes the site down.

The short answer

Requirements. Browse events and a seat map, hold seats for a few minutes during checkout, pay and get tickets, and never sell a seat twice; seat state is strongly consistent, on-sale spikes of millions of fans are survived, access is fair and bots stay out, and browsing may be a few seconds stale.

Normal day
12 per second1M tickets a day
Big on-sale
40 fans per seat2M fans for 50,000 seats
Seat map reads
400,000 per second2M fans refreshing every 5 s

The design. One conditional update decides who gets a seat: it sets the seat to held only if it is free or its hold has expired, so exactly one buyer changes the row and everyone else changes none. A hold lasts 10 minutes while the fan pays; then the booking marks the seat sold. For an on-sale, a virtual waiting room admits fans at the rate the booking service can serve, the seat map comes from a cache refreshed every second or two with changes pushed, and a hot event’s seats are split by section.

Interview prompt

Design Ticketmaster: users find an event, choose seats and buy tickets.

Requirements and estimates

Functional requirements

  • Browse events and see a seat map with availability.
  • Hold seats for a few minutes during checkout.
  • Pay and receive tickets.
  • No seat is ever sold twice.

Non-functional requirements

  • Strong consistency for seat state.
  • Survive on-sale spikes of millions of users.
  • Fair access; bots kept out.
  • Browsing may be a few seconds stale.

Estimates

Normal day  1M tickets per day                  ≈ 12 per second
Big on-sale 2M fans for 50,000 seats            = 40 fans per seat
Seat map    2M fans refreshing every 5 s         = 400,000 reads/s, so cache and push

Data model and the hold

Data model

events    event_id, venue_id, on_sale_at
seats     event_id, seat_id, section, price,
          status FREE | HELD | SOLD,
          held_by, hold_expires_at, version
bookings  booking_id, user_id, event_id,
          seat_ids, payment_id, status

The one statement that matters

UPDATE seats
SET status = 'HELD', held_by = :user,
    hold_expires_at = now() + interval '10 min'
WHERE event_id = :event AND seat_id = :seat
  AND (status = 'FREE' OR
      (status = 'HELD' AND hold_expires_at < now()));
/* 1 row changed: you hold it.
   0 rows: someone else does. */

Whiteboard

What you sketch in the first five minutes: two fans and one seat, then the line in front of the on-sale.

1. Two fans, one seat

Say: the database decides, in one statement, who holds the seat.

fan 1fan 2same secondseat A12UPDATE ... WHERE status = FREE1 row changedfan 1 holds A120 rows changedseat takenFREEHELDSOLDhold: 10 minexpired: free againwhen paid
  1. Both fans click A12 in the same second, and both send the same conditional update.
  2. Only one update finds the seat free and changes 1 row: that fan holds it for 10 minutes.
  3. The other changes 0 rows and is told the seat is taken.

Next question: the hold expires while the fan is paying. Extend it once when payment starts; if it was lost anyway and the charge went through, refund it automatically.

2. The line in front of the on-sale

Say: 2M fans for 50,000 seats is 40 per seat; let them in at the rate you can serve.

2M fans40 per seatwaiting rooma place in linetokenin batchesbookingvalid token onlyseatsseat mapfrom a cache, changes pushed400,000 reads a secondadmit at the rate booking can serve50,000 seats, one hot event:split its seats by section
  1. Fans join a virtual waiting room and get a place in line.
  2. They are admitted in batches with a signed token, at the rate booking can serve.
  3. Booking only accepts requests with a valid token.

Next question: how do you stop bots? Verified fan presales, limits per account and per card, and a challenge at the door of the waiting room.

Preventing double booking

ApproachHowTradeoff
Pessimistic lockSELECT … FOR UPDATE inside a transactionSimple; contenders queue on the row lock
Optimistic lockRead version, then UPDATE … WHERE version = :vNo locks; under heavy contention most attempts fail and retry
Conditional update Common pickOne UPDATE with the status check in WHEREAtomic, one round trip, no retry loop
Redis hold with expirySET seat:A12 user NX PX 600000Fast holds off the database; the database must still enforce the final sale

Surviving the on-sale

  • Virtual waiting room. Fans get a place in line and a signed admission token; the booking service only accepts requests with a valid token and admits at the rate it can serve.
  • Seat map from cache, changes pushed. Serve the map from a cache refreshed every second or two and push seat changes over server-sent events. The hold step is authoritative, so a slightly stale map is harmless.
  • Split the hot event. One event cannot be sharded by event ID; partition its seats by section instead.

What the interviewer probes next

The hold expires while the fan is paying. Now what?

Confirmation re-checks the hold. Extend it once when payment starts; if it was lost anyway and the charge succeeded, refund automatically and tell the fan clearly.

Why not keep seat state in application memory?

There are many application servers and their memory is not shared. One authority, the database or a single Redis key per seat, must arbitrate.

How do you stop bots from buying everything?

Verified fan presales, per account and per card limits, a challenge at waiting room entry, and device fingerprinting.

How does this change for hotels or flights?

Same core: conditional updates on inventory counts, holds with expiry and idempotent confirmation. Airlines also deliberately overbook, which is a business rule layered on top.

Building blocks used here

Want to run this as a mock interview? See interview prep.

© 2026 Arman Ajabkhani · armantik.com · Privacy