Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Design Ticketmaster &
Flash-Sale Reservations.

A Ticketmaster-grade flash-sale system absorbs 1,000,000-user surges via an edge virtual waiting room, serves seat maps from CDN/Redis, and enforces zero double-booking with atomic DB/Redis seat holds.
Start the journey5 stages
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When `1,000,000` fans hit refresh at the exact same second for `50,000` concert seats, read-to-write ratios and hot, never let 1M unthrottled users hit your primary RDBMS—use a virtual waiting room at the edge to meter traffic, cache read-heavy seat maps, and enforce ACID row locks on the 50k-seat booking path.

TL;DR30-second simplified summary
▾

Core Mechanics: When 1,000,000 fans hit refresh at the exact same second for 50,000 concert seats, read-to-write ratios and hot-row contention spike by 1,000×.

Visual & Structural Flow: Depicts Virtual Waiting Room -> Cached Seat Map -> Atomic 5-Min Hold (Waiting Room -> Redis Seat Map -> Booking API -> Sharded RDBMS); Edge Queue + Redis Seat Map + Sharded ACID Inventory (Edge Queue -> Redis Cache -> Booking Svc -> Sharded DB).

Trade-Offs & Production: A naive design puts all 1M users directly onto the booking API backed by Postgres SELECT FOR UPDATE: Thundering Herd Collapse: Even though only 50k seats exist, 950k doomed requests saturate CPU and HikariCP pools. Production flash-sale platforms layer four defenses: Virtual Waiting Room (Edge): Queue 1M users in a FIFO/shuffled Redis or Cloudflare Durable Object queue, issuing signed.

Failure Modes & Application: The edge-queue + conditional-lease architecture generalizes to any scarce-inventory spike: Sneaker Drops & E-Commerce Flash Sales: Metering checkout queues while decrementing bounded SKU inventory.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Database Indexing: B-Trees vs LSM-Trees
B-Trees organize sorted keys into fixed-size mutable pages optimized for fast, predictable point and range reads, whereas LSM-Trees buffer writes in memory and flush immutable sorted runs to disk for high write throughput.
Database Isolation Levels & Transaction Anomalies
Database isolation levels control what concurrent transaction anomalies—dirty reads, non-repeatable reads, phantom reads, and write skew—are permitted in exchange for lower locking or coordination overhead.
Transaction Isolation & Distributed ACID
Isolation levels control which concurrent read/write anomalies a database permits, trading throughput and lock/abort rates for correctness—while distributed ACID extends those guarantees across shards via 2PC, TrueTime, or HLCs.
Full walkthrough · 5 stages
01
STAGE 01 · WHY IT MATTERSL4 · FUNDAMENTALS

Why flash-sale ticketing breaks standard e-commerce architectures.

Why this matters: The mechanism: understand how Why flash-sale ticketing breaks standard e-commerce architectures works from first principles.

Think of Why flash-sale ticketing breaks standard e-commerce architectures as the intuition layer for Design Ticketmaster & Flash-Sale Reservations: The mechanism: understand how Why flash-sale ticketing breaks standard e-commerce architectures works from first principles.

When 1,000,000 fans hit refresh at the exact same second for 50,000 concert seats, read-to-write ratios and hot-row contention spike by 1,000×. Seat map browsing must stay < 100 ms and reservation holds < 500 ms, while guaranteeing strict ACID zero double-booking and automatic release of abandoned 5-minute carts.

02
STAGE 02 · IMPACTL5 · APPLIED DESIGN

What happens without edge admission control and read caching.

Why this matters: The problem: see what breaks without What happens without edge admission control and read caching under real concurrency or scale.

Sending 1M concurrent users directly to the booking database causes an immediate thundering-herd outage:

  1. Connection Pool & Lock Exhaustion: Thousands of concurrent SELECT ... FOR UPDATE queries on the same show_id exhaust DB connections and stall all transactions.
  2. Seat Map Read Storm: Repeatedly querying Postgres for available seats saturates read IOPS before anyone even checks out.
  3. Ghost Inventory: Abandoned carts lock seats indefinitely if TTL expiry is not automated.
Admission & Reservation Flow

Virtual Waiting Room -> Cached Seat Map -> Atomic 5-Min Hold

Waiting RoomRedis Seat MapBooking APISharded RDBMS1. Admit metered token (e.g. 5k/s)2. GET seat map (<10ms)3. BEGIN; UPDATE seat WHEREAVAILABLE4. Publish HELD (TTL 300s)5. Payment failed -> release seat

Edge queuing caps concurrency reaching the database while atomic conditional UPDATEs guarantee zero double-booking.

Engineering Decision Framework
Problem
How to implement Design Ticketmaster & Flash-Sale Reservations without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
When 1,000,000 fans hit refresh at the exact same second for 50,000 concert seats, read-to-write ratios and hot, never let 1M unthrottled users hit your primary RDBMS—use a virtual waiting room at the edge to meter traffic, cache read-heavy seat maps, and enforce ACID row locks on the 50k-seat booking path.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design Ticketmaster & Flash-Sale Reservations experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
STAGE 03 · NAIVE SOLUTIONL5 · APPLIED DESIGN

Naive solution (and why DB-only locking without a waiting room fails).

Why this matters: The problem: see what breaks without Naive solution under real concurrency or scale.

A naive design puts all 1M users directly onto the booking API backed by Postgres SELECT FOR UPDATE:

  • Thundering Herd Collapse: Even though only 50k seats exist, 950k doomed requests saturate CPU and HikariCP pools.
  • Lock Wait Cascades: Unbounded FOR UPDATE without NOWAIT / SKIP LOCKED piles up blocked worker threads.
  • No Read/Write Split: Seat-map polling competes with payment commits on the primary DB.
Request & State Flow

Naive solution (and why DB-only locking without a waiting room fails)

CallerService EntryCore ProcessorState Store1. Submit bounded request2. Apply domain invariant3. Persist or read state4. Return verified response
04
STAGE 04 · ENTERPRISE SOLUTIONL6 · SCALE & TRADE-OFFS

Enterprise solution: Virtual Waiting Room + Conditional ACID Hold + TTL Sweeper.

Why this matters: Operational control: configure bounds, failure handling, and safe production defaults.

Production flash-sale platforms layer four defenses:

  • Virtual Waiting Room (Edge): Queue 1M users in a FIFO/shuffled Redis or Cloudflare Durable Object queue, issuing signed admission JWTs at a rate the DB can sustain (e.g., 5,000 users/sec).
  • Read/Write Separation: Serve static venue SVG + live seat availability from CDN + Redis (updated via CDC/outbox) in < 100 ms.
  • Atomic Conditional Hold: Reserve seats in sharded Postgres (shard_key = event_id) using UPDATE seats SET status='HELD', hold_until=now()+interval '5 min' WHERE seat_id = ANY($1) AND status='AVAILABLE' (sorted IDs, NOWAIT).
  • Automated Expiry: A background sweeper + Redis keyspace/delay queue releases unpaid holds after 5 minutes.
Read/Write Isolation

Edge Queue + Redis Seat Map + Sharded ACID Inventory

Edge QueueMeters 1M -> 5k/sRedis CacheSeat map <100msBooking SvcIdempotent holdSharded DBACID 5-min lease

1.Waiting Room: Absorbs 1M spike at edge and drips signed admission tokens.

2.Seat Map Cache: Offloads 99% of browsing reads from the primary RDBMS.

3.Conditional UPDATE: Atomic WHERE status='AVAILABLE' prevents double-booking.

4.5-Min TTL Sweeper: Reclaims abandoned holds back to AVAILABLE automatically.

Metering admission at the edge and serving seat maps from Redis lets the sharded RDBMS focus solely on atomic 5-minute holds.

-- Atomic, deadlock-free 5-minute seat hold (seat_ids passed sorted)
UPDATE show_seats
SET status = 'HELD',
    held_by_user_id = $1,
    hold_token = $2,
    hold_expires_at = NOW() + INTERVAL '5 minutes'
WHERE show_id = $3
  AND seat_id = ANY($4::bigint[])
  AND (status = 'AVAILABLE' OR (status = 'HELD' AND hold_expires_at < NOW()))
RETURNING seat_id;
-- Application verifies returned row count == cardinality($4); otherwise ROLLBACK.
05
STAGE 05 · SYSTEM DESIGN APPLICATIONSL7 · STAFF / PRINCIPAL

Where Flash-Sale Reservation Patterns apply in System Design.

Why this matters: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.

The edge-queue + conditional-lease architecture generalizes to any scarce-inventory spike:

  • Sneaker Drops & E-Commerce Flash Sales: Metering checkout queues while decrementing bounded SKU inventory.
  • Airline & Train Seat Maps: Serving high-read seat maps from cache while locking PNR inventory atomically.
  • Concert & Sports Ticketing: Isolating hot event_id shards from unrelated venue traffic.
Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why is a Virtual Waiting Room essential even when the database uses atomic conditional UPDATEs for seat holds?

Recommended Learning Flow