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
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 SeatBitmapPOST /events/:id/seats/:seatId/reserve -> { orderId, expiresAt }POST /events/:id/seats/:seatId/payment { orderId }-> 200 OKHow it works
1. Split AP browse from CP booking
- Read-heavy catalog: Event metadata rarely mutates, so
Browse / Searchcaches 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)RedisGET. - Atomic hold & deadlock-free multi-seat: One Lua script flips the bitmap bit(s) and sets
SET seat:{eid}:{sid} {orderId} NX EX 600in sortedseat_idorder (co-located via hash tag{eid}), while an expiry sweep unflips abandoned bits back to0.
3. Conditional DB truth & automated refunds
- Durable Stripe webhooks: Pass
Idempotency-Key: booking_idfor payment idempotency and consumepayment_intent.succeededwebhooks intoBooking Kafkaso browser closes never lose paid tickets. - Final commit + refund safety net:
Booking Handlerruns an atomic conditional write (WHERE status = 'AVAILABLE'); if a hold expired att = 601sand another fan bought the seat, the conflict triggersRefund Serviceautomatically.
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?
Select an option to check the trade-off.
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?
Select an option to check the trade-off.
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?
Select an option to check the trade-off.
singleflightcaching
Coalescing concurrent identical cache misses inside a process so only one request queries the DB and shares the result.
thundering herdcaching
When a hot cache key expires and hundreds of concurrent requests simultaneously miss and hammer the origin database.
idempotencyreliability
Property where repeating the exact same request multiple times produces the same final state as executing it once.