Designing a Scalable Concert Ticketing System
System DesignModel answerLast updated
Build the backend for a live event ticketing platform that prevents overselling during high-traffic on-sales while managing seat reservations and payments.
You're tasked with architecting a ticketing platform for live events like concerts and sports games. The system must handle extreme load during popular event launches while guaranteeing that no seat is ever double-booked.
Core Functionality
Your platform needs to support:
- Real-time seat browsing: Users see which seats remain available and their prices
- Time-limited reservations: Selected seats are locked exclusively for a customer (typically 10 minutes) during payment
- Payment processing: Handle credit card transactions that may fail, timeout, or complete after the reservation window
- Traffic control: Manage huge spikes when tickets go on sale to prevent system overload
Critical Constraints
- No double-booking: The same seat cannot be sold to multiple buyers under any circumstances, even during failures or race conditions
- Performance targets: Viewing availability should respond in under 200ms (p99); creating a reservation under 500ms
- Scale: Handle 2 million simultaneous users competing for up to 80,000 seats
- Load patterns: Expect 100,000 reads/sec for seat availability and 30,000 attempts/sec to reserve seats
Expected Coverage
Design the architecture addressing:
- Component layout: How traffic flows from users through various services to storage
- Inventory management: Data model for seats and the state transitions between available, reserved, and sold
- Concurrency control: Mechanisms preventing race conditions when multiple users target the same seat
- Reservation expiry: Safely reclaiming seats when payment doesn't complete in time, including edge cases where payment arrives just as time expires
- Demand management: Approaches to prevent overwhelming backend systems and detect automated bots
- Payment reliability: Ensuring exactly-once payment semantics despite retries and asynchronous callbacks
Provide concrete design choices with justification for your decisions.
Hints
Hint 1
Consider what can be cached versus what requires strong consistency - viewing availability and securing a seat have different requirements
Hint 2
Use optimistic concurrency control with version numbers to handle the race between reservation expiry and late payment completion
Hint 3
A queueing layer that admits users gradually protects downstream services and provides fairness, but needs to issue verifiable admission credentials
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Solution: Scalable Concert Ticketing Architecture
Understanding the Problem Space
The key insight is recognizing this as a coordination problem under scarcity, not purely a throughput challenge. With 2M users competing for 80K seats, roughly 96% of users will fail to purchase. The architecture's primary goal is efficiently rejecting the majority while guaranteeing correctness for successful purchases.
Calculating the constraints:
- 100K seat map reads/sec at 10KB per full venue = 1GB/sec, easily handled by CDN caching
- 30K reservation attempts/sec concentrated on the best seats creates severe contention
- Only 80K reservations can ever succeed, suggesting we should admit users at 2-5K/sec maximum
- Consistency is required only for the final sale confirmation; stale availability views are acceptable
API Design
GET /events/{id}/access → {queue_position, eta, admission_token}
GET /events/{id}/seats/{section} → {availability_bitmap, prices, version}
POST /reservations → {reservation_id, seats[], expires_at, fence_token}
Headers: Admission-Token, Request-ID
Body: {event_id, seat_ids[]}
POST /reservations/{id}/purchase → {order_id, status}
Headers: Request-ID
Body: {payment_details}
POST /webhooks/payment → 200 OK (signed, idempotent)
Storage Schema
Using a distributed SQL database (CockroachDB/Spanner) partitioned by (event_id, section_id):
seats table:
(event_id, seat_id) PRIMARY KEY
section_id, row_number, seat_number
status: OPEN | RESERVED | PURCHASED
reservation_id, version_number
reserved_until, purchased_by, order_id
reservations table:
reservation_id PRIMARY KEY
user_id, event_id, seat_ids[]
version_number, created_at, expires_at
status: ACTIVE | COMPLETED | EXPIRED | CANCELLED
orders table:
order_id PRIMARY KEY
reservation_id UNIQUE
user_id, total_amount
payment_provider_id, payment_status
created_at, completed_at
payment_events table (for webhook deduplication):
provider_event_id PRIMARY KEY
order_id, event_type, payload
received_at, processed_at
Architecture Components
1. Entry Layer with Queue Management
Users first interact with a virtual waiting room service that:
- Assigns queue positions using randomization for users arriving before the sale starts (prevents early-arrival gaming)
- Issues cryptographically signed admission tokens with short TTLs (15 minutes)
- Controls admission rate based on downstream capacity and remaining inventory
- Tokens contain:
{event_id, user_id, issued_at, expires_at, signature}
This layer reduces load from 2M to a manageable 5K concurrent active shoppers.
2. Read Path: Seat Availability
Seat availability is eventually consistent and heavily cached:
- A background process publishes seat availability snapshots to CDN every 1-2 seconds
- Format: compressed bitmaps per section (100 bytes per 800-seat section)
- Clients poll rather than using WebSockets (2M WebSocket connections are expensive)
- Stale data is acceptable—users will discover unavailability during reservation
3. Write Path: Reservation Service
This service is the sole authority for seat state transitions:
OPEN → RESERVED → PURCHASED
↓
EXPIRED → OPEN
Creating a reservation:
BEGIN TRANSACTION;
-- Lock rows in deterministic order (sorted by seat_id) to prevent deadlocks
SELECT seat_id, version_number
FROM seats
WHERE event_id = ? AND seat_id IN (?)
AND (status = 'OPEN'
OR (status = 'RESERVED' AND reserved_until < NOW() - INTERVAL '60 seconds'))
FOR UPDATE;
-- Atomic state transition with version increment
UPDATE seats
SET status = 'RESERVED',
reservation_id = ?,
version_number = version_number + 1,
reserved_until = NOW() + INTERVAL '10 minutes'
WHERE seat_id IN (?)
AND event_id = ?
AND (status = 'OPEN' OR (status = 'RESERVED' AND reserved_until < NOW() - INTERVAL '60 seconds'));
-- Verify all requested seats were reserved
-- If row count < requested count, ROLLBACK
INSERT INTO reservations (...) VALUES (...);
COMMIT;
Key details:
- All-or-nothing semantics: either get all requested seats or fail
- The 60-second grace period beyond the displayed 10-minute timer handles slow payments
- Version numbers enable optimistic concurrency control for purchase confirmation
4. Payment and Purchase Confirmation
The checkout flow uses fencing tokens to handle race conditions:
- Initiate payment: Create payment intent with provider, storing
(order_id, reservation_id, version_number) - Authorize (not capture): Lock funds but don't complete the transaction yet
- Confirm seats with fence check:
UPDATE seats
SET status = 'PURCHASED',
order_id = ?,
purchased_by = ?
WHERE seat_id IN (?)
AND reservation_id = ?
AND version_number = ?
AND status = 'RESERVED';
This conditional update succeeds only if the reservation hasn't been superseded. If the version mismatch occurs (seat was re-released and re-reserved), the update fails and the authorization is voided.
- Capture payment only after seat confirmation succeeds
This ordering prevents the nightmare scenario: charging a customer whose seats were given away.
5. Expiry Management
A background sweeper runs every 30 seconds:
UPDATE seats
SET status = 'OPEN',
reservation_id = NULL
WHERE status = 'RESERVED'
AND reserved_until < NOW() - INTERVAL '60 seconds';
The grace period means customer-facing timers show 10 minutes, but the system waits 11 minutes before reclaiming. This absorbs most payment processing delays.
6. Payment Webhook Handling
Payment providers send asynchronous notifications:
def handle_webhook(signed_payload):
# Verify signature
if not verify_signature(signed_payload):
return 401
# Idempotent processing using provider's event ID
result = db.execute(
"INSERT INTO payment_events (provider_event_id, ...) VALUES (...)
ON CONFLICT (provider_event_id) DO NOTHING
RETURNING provider_event_id"
)
if result.rowcount == 0:
return 200 # Already processed
# Process state transition
if event_type == 'payment.succeeded':
finalize_order(order_id)
elif event_type == 'payment.failed':
release_reservation(reservation_id)
The ON CONFLICT DO NOTHING provides exactly-once processing even if webhooks are retried.
Bot Prevention and Fairness
Rate limiting:
- Per user account: 5 reservation attempts per minute
- Per IP/network block: 100 attempts per minute
- Per payment card: prevent same card from buying multiple times
Behavioral analysis:
- Browser fingerprinting to detect automation
- Mouse movement and timing analysis
- CAPTCHA challenges for suspicious patterns
Verified fan programs:
- Pre-registration with identity verification
- Priority queue access for verified accounts
Common Pitfalls
Using Redis as the source of truth: Redis replication is asynchronous. A replica promotion can lose acknowledged writes, causing double-booking. Redis works excellently as a fast rejection layer but cannot be the final authority.
Capturing payment before confirming seats: If seat confirmation fails, you've charged the customer for nothing, requiring refunds and support tickets.
No version/fence tokens: Without versioning, a delayed payment webhook can overwrite a newer reservation of the same seat.
Blocking sweepers: Don't run expiry cleanup in a lock that blocks new reservations. Use the predicate approach shown above.
Scaling Considerations
- Database partitioning: Partition by
(event_id, section_id)to distribute hot seats - Read replicas: Route availability queries to replicas; only reservations hit the leader
- Caching strategy: Aggressive CDN caching for availability with 1-2s TTL
- Geographic distribution: Deploy regionally but maintain strong consistency for reservations
- Capacity planning: Monitor reservation success rate and adjust queue admission rate dynamically
This architecture handles the scale while providing the transactional guarantees necessary for a trustworthy ticketing platform.