Design a high-concurrency event ticketing platform like Ticketmaster or BookMyShow. The system must handle sudden 1,000,000-user traffic surges attempting to purchase 50,000 seats at the exact same second. It must guarantee strict transactional consistency (zero double-booking), handle user cart abandonment, and prevent database deadlocks.
From patterns to decisions.
Design a high-concurrency event ticketing platform like Ticketmaster or BookMyShow. The system must handle sudden 1,000,000-user traffic surges attempting to purchase 50,000 seats at the exact same second. It must guarantee strict transactional consistency (zero double-booking), handle user cart abandonment, and prevent database deadlocks.
Flash-sale checkout engine handling 50,000.
Flash-sale checkout engine handling 50,000 concurrent purchase transactions for 500 limited sneaker SKUs. Failure cascade dynamic: Burst → Pool Saturated → Queue Bloat (10k) → STW GC → 💥 504 Timeouts.
| Choice | What it buys | What it costs |
|---|---|---|
| Operational Invariant | Never acquire relational row locks (SELECT FOR UPDATE) on shared hot counters during peak traffic surges; use in-memory atomic staging. | |
| Workload Baseline | Flash-sale checkout engine handling 50,000 concurrent purchase transactions for 500 limited sneaker SKUs. |
Implementation & Guardrails (2).
Ticketmaster burst booking architecture resolves thundering herds via a distributed Virtual Waiting Room (token-bucket rate limiting ingress to 2,000 req/sec), pessimistic row-level locking (SELECT FOR UPDATE) to prevent double-booking, and delayed message queues to release abandoned reservations after 5 minutes.
| Choice | What it buys | What it costs |
|---|---|---|
| Pessimistic Locking vs In-Memory Redis Staging | Pessimistic locking in SQL guarantees strict ACID consistency but suffers from database connection limits at extreme scale. Redis Lua staging handles 100k QPS in RAM but requires eventual synchronization to PostgreSQL via Kafka Outbox. | |
| Virtual Waiting Room vs Direct Booking | A waiting room adds learner queue friction but guarantees 100% server uptime and fair FIFO processing. |
1. Virtual Waiting Room
Incoming users are queued in a distributed token bucket system. A rate limiter admits a controlled stream (e.g. 2,000 users/sec) to the seat selection service.
2. Live Map Browsing
Read seat availability from an edge Redis cache; WebSocket connections push real-time seat lock updates to all active viewing clients.
3. Pessimistic Row Lock
When user taps "Reserve", execute a transaction in PostgreSQL using row-level locking (SELECT FOR UPDATE) to transition seat status from AVAILABLE to LOCKED with a 5-minute lease.
4. Delayed Message Queue
Schedule a message in AWS SQS with a 5-minute delay. If payment confirmation has not arrived when the delayed message is consumed, revert seat status to AVAILABLE.
Cart Abandonment Inventory Lockup
Users lock thousands of seats and close their browsers. Without an automated background cleanup (delay queue / cron), inventory remains locked while genuine buyers are turned away.
Deadlocks on Multi-Seat Reservations
If User 1 locks Seat A then Seat B, while User 2 locks Seat B then Seat A, the database deadlocks. Mitigation: Enforce strict deterministic sorting of seat IDs (e.g. ORDER BY seat_id ASC) prior to acquiring row locks.
-- PostgreSQL Atomic Reservation with Pessimistic Row Locking
BEGIN TRANSACTION;
SELECT seat_id, status
FROM seats
WHERE event_id = 101 AND seat_number = 'A-42' AND status = 'AVAILABLE'
FOR UPDATE; -- Acquires exclusive row-level lock
UPDATE seats
SET status = 'RESERVED',
reserved_by = 9942,
reservation_expires_at = NOW() + INTERVAL '5 minutes'
WHERE seat_id = 42;
COMMIT;
Trade-Off Analysis.
Architectural comparison of naive unconstrained allocations versus production-hardened mechanical sympathy.
| Choice | What it buys | What it costs |
|---|---|---|
| Ingress Admission | Naive unconstrained buffering causes queue bloat and GC exhaustion. Mitigation: Bounded ingress gate with fast non-blocking shedding. | |
| Resource Strategy | Static capacity allocations collapse under brownouts. Mitigation: Dynamic adaptive limits scaling to real-time physical bounds. | |
| Outage Impact | Cascading lock convoys and memory saturation. Mitigation: Isolated failure domains keep P99 latency flat and protected. |
Alternative 1
Naive Approach: Executing 'SELECT stock FROM inventory WHERE item_id = 101 FOR UPDATE'. 50,000 database transactions serialize behind a single InnoDB/PostgreSQL row l
Alternative 2
Production-Hardened Pattern: Offload real-time inventory reservation to an in-memory single-threaded atomic engine (Redis Lua script via DECRBY), issuing an ephemeral 15- minute l
Failure physics analysis.
Failure physics analysis: Burst → Pool Saturated → Queue Bloat (10k) → STW GC → 💥 504 Timeouts.
Cascading Failure
Executing 'SELECT stock FROM inventory WHERE item_id = 101 FOR UPDATE'. 50,000 database transactions serialize behind a single InnoDB/PostgreSQL row lock. HikariCP connection pool (100 connections) exhausts in 12ms; database CPU hits 100% on deadlock detection, crashing the API.
Breakdown Chain
Burst → Pool Saturated → Queue Bloat (10k) → STW GC → 💥 504 Timeouts
Shedding Failure
Without fast rejection at the boundary, queued dead work triggers multi-second GC pauses, CPU thrashing, and cascading 504 Gateway Timeouts.
Senior Staff SRE Interview challenge.
Senior Staff SRE Interview challenge and architectural invariant verification.
| Choice | What it buys | What it costs |
|---|---|---|
| Architectural Invariant | "Never acquire relational row locks (SELECT FOR UPDATE) on shared hot counters during peak traffic surges; use in-memory atomic staging." | |
| Physical Resource Boundary | Dynamic admission control ensures worker threads never buffer dead requests during downstream brownouts. |
Step 1
1. Track real-time latency gradients and inflight concurrency.
Step 2
2. Reject excess traffic at the ingress boundary within <0.1ms.
Step 3
3. Monitor P99 latency and verify autonomous recovery when downstream pressure subsides.
Theory & Tips and Tricks
Practical heuristics & interview traps
- 01Interview anchor: Isolate ingress routing, decouple transactional state from background operations, and enforce explicit timeout and retry budgets across all service boundaries.
- 02Trade-off tip: Ingress Admission: Naive unconstrained buffering causes queue bloat and GC exhaustion. Mitigation: Bounded ingress gate with fast non-blocking shedding.
- 03Trade-off tip: Resource Strategy: Static capacity allocations collapse under brownouts. Mitigation: Dynamic adaptive limits scaling to real-time physical bounds.
- 04Watch out for: Cascading Failure: Executing 'SELECT stock FROM inventory WHERE item_id = 101 FOR UPDATE'. 50,000 database transactions serialize behind a single InnoDB/PostgreSQL row lock. HikariCP connection pool (100 connections) exhausts in 12ms; database CPU hits 100% on deadlock detection, crashing the API.
- 05Watch out for: Breakdown Chain: Burst → Pool Saturated → Queue Bloat (10k) → STW GC → 💥 504 Timeouts
Design Ticketmaster Flash Sale System — Normal → Load / Fault → Recovery
Isolate ingress routing, decouple transactional state from background operations, and enforce explicit timeout and retry budgets across all service boundaries.
Putting Design Ticketmaster & Flash-Sale Reservations Together
Isolate ingress routing, decouple transactional state from background operations, and enforce explicit timeout and retry budgets across all service boundaries.
Putting Design Ticketmaster & Flash-Sale Reservations Together
- 1. Virtual Waiting Room: Incoming users are queued in a distributed token bucket system. A rate limiter admits a controlled stream (e.g. 2,000 users/sec) to the seat selection service.
- 2. Live Map Browsing: Read seat availability from an edge Redis cache; WebSocket connections push real-time seat lock updates to all active viewing clients.
- 3. Pessimistic Row Lock: When user taps "Reserve", execute a transaction in PostgreSQL using row-level locking (SELECT FOR UPDATE) to transition seat status from AVAILABLE to LOCKED with a 5-minute lease.
- 4. Delayed Message Queue: Schedule a message in AWS SQS with a 5-minute delay. If payment confirmation has not arrived when the delayed message is consumed, revert seat status to AVAILABLE.
Interview Readiness Check
Failure physics analysis: Burst → Pool Saturated → Queue Bloat (10k) → STW GC → 💥 504 Timeouts.
Walk through bottlenecks, back-of-the-envelope math, and failure recovery.
Make the trade-off yourself.
Practice Check
Test your understanding
Why do high-throughput write-heavy storage engines (like RocksDB and Cassandra) use LSM-Trees instead of traditional B+ Trees?
Design Ticketmaster & Flash-Sale Reservations
Isolate ingress routing, decouple transactional state from background operations, and enforce explicit timeout and retry budgets across all service boundaries.
