skip to content
jaeaeichsysdes

Design Ticketmaster (Event Booking)

Handling 1M concurrent users during hot ticket drops: split AP browse/search and CP seat booking, Redis 6 KB stadium bitmaps, atomic 10-minute Lua holds, conditional DB commits, and auto-refunds.

The whiteboard

Trace browse & search (AP), seat map & hold (CP), and payment & auto-refund (CP) below — tying together Distributed Locks & Fencing Tokens, Idempotency, Retries & Outbox, and Caching & Failure Modes.

whiteboard · press 1–4 to trace flows

AP BROWSE & SEARCHCP SEAT MAP & 10m HOLDCP PAYMENT, DB TRUTH & AUTO-REFUNDsearchCDC syncadmitwebhookconsumeCAS putconflictauto-refund if hold expiredBrowse / Searchsingleflight cacheAP · geo + textElasticsearchevent catalogsynced via CDCWaiting Roomedge FIFO gate1M → 10K waveSeat Hold Svcatomic Lua scriptsorted multi-seatRedis Bitmap + Lock6.25 KB · SETNX 600sStripe / PSPIdempotency-Keypaid webhookBooking Kafkadurable order logdecouples commitBooking HandlerCAS seat committriggers refundEvents & Seats DBWHERE status='AVAIL'final truthRefund Serviceif hold expired

Full Ticketmaster: AP search runs off CDC-fed Elasticsearch, while CP drops funnel 1M fans through a waiting room, 6.25 KB Redis bitmaps, and conditional DB commits.Splitting AP browse from CP booking lets you cache event metadata aggressively while guaranteeing zero double-sold seats.

Scale & APIs

6.25 KB

50,000-seat bitmap in Redis

600 s

10-min temporary seat hold TTL

1M users

buffered by edge waiting room

Tables:
Events { event_id, name, venue_id, starts_at }
Seats { (event_id, seat_id) PK, status (AVAILABLE | BOOKED), booking_id, version }
Bookings { booking_id, user_id, event_id, seat_ids[], status, payment_intent_id }
GET /events/browse?lat=...&long=...&q=... -> PartialEvent[]
GET /events/:id/seats -> 6.25 KB SeatBitmap
POST /events/:id/seats/:seatId/reserve -> { orderId, expiresAt }
POST /events/:id/seats/:seatId/payment { orderId }-> 200 OK

How it works

1. Split AP browse from CP booking

  • Read-heavy catalog: Event metadata rarely mutates, so Browse / Search caches it aggressively with singleflight and serves geo/text queries from CDC-synced Elasticsearch.
  • Virtual Waiting Room: During 1M-fan drops, an edge FIFO queue admits controlled waves (5K–10K shoppers) to protect the hot stadium bitmap from thundering herd saturation.

2. 6.25 KB Redis bitmap + atomic Lua hold

  • Sub-ms seat maps: Packing 50,000 seats into 1 bit each yields a 6.25 KB payload fetched in one O(1) Redis GET.
  • Atomic hold & deadlock-free multi-seat: One Lua script flips the bitmap bit(s) and sets SET seat:{eid}:{sid} {orderId} NX EX 600 in sorted seat_id order (co-located via hash tag {eid}), while an expiry sweep unflips abandoned bits back to 0.

3. Conditional DB truth & automated refunds

  • Durable Stripe webhooks: Pass Idempotency-Key: booking_id for payment idempotency and consume payment_intent.succeeded webhooks into Booking Kafka so browser closes never lose paid tickets.
  • Final commit + refund safety net: Booking Handler runs an atomic conditional write (WHERE status = 'AVAILABLE'); if a hold expired at t = 601s and another fan bought the seat, the conflict triggers Refund Service automatically.

lesson

Interview differentiator: Treat Redis SETNX as a UX reservation (fast, best-effort) and the database conditional write as financial truth (strict, atomic) — then explicitly draw the Refund Service arrow for payments that clear after TTL expiry.

Check yourself

interactive · stress-test this booking system against classic Ticketmaster probes

01 · Payment succeeds 2 seconds after the 10-minute hold expires

hold expired mid-pay · DB conditional write · no double-sell

User A holds seat A12 for 10 minutes and clicks Pay at 9:59. Stripe takes 3 seconds to confirm. Meanwhile at 10:00 the Redis hold expired, User B reserved A12, and booked it in the DB. How does your architecture handle User A's late Stripe confirmation?

02 · Why store the live seat map as a Redis bitmap?

50,000 seats · high read QPS · 6.25 KB payload

A stadium has 50,000 seats and 10,000 admitted shoppers refresh the seat map every 2 seconds. Why is a Redis bitmap (eid:seats) dramatically better than querying 50,000 rows from DynamoDB per request?

03 · Abandoned checkout ghost seats

abandoned hold · 600s TTL · bitmap sync

A user reserves seat B7 (Lua sets seat:eid:B7 EX 600 and flips bitmap bit B7 to 1), then closes the tab without paying. After 10 minutes Redis deletes the hold key. What breaks if nothing unflips bit B7?

esc
⌘B sidebar[ ] prev/next1–5 flowsc copyt theme