Design a High-Traffic Event Seat Reservation Platform
System DesignModel answerLast updated
Design a seat reservation system for sold-out events that handles millions of concurrent users without overselling, covering holds, payments, and real-time availability.
Scenario
Your team is building the ticketing backend for a major live events platform. Every few weeks, a high-profile concert goes on sale and millions of fans hit the site simultaneously. The current system oversells seats and crashes under load. You are asked to design a replacement from scratch.
What you need to design
Walk through the full system: data model, API surface, concurrency strategy, consistency guarantees, scaling approach, and failure handling. A strong answer reasons through trade-offs rather than listing buzzwords.
Core capabilities
- Display a venue seat map with live availability.
- Let a user select specific seats and reserve them temporarily. That reservation should expire automatically if the user does not complete checkout.
- Process payment in a way that is safe to retry and impossible to double-charge.
- Prevent selling the same seat twice under any conditions, including traffic spikes and partial failures.
- Queue excess users during a hot on-sale rather than dropping or crashing.
- Support cancellations, refunds, and payment disputes.
- Rate-limit and detect bots.
- Maintain a complete audit trail of every state change.
Non-functional targets
Use a large-scale on-sale as your sizing anchor: a 60,000-seat venue with 10 million users trying to buy tickets in the first ten minutes. Discuss how your design handles the read/write asymmetry that creates.
What the interviewer expects
- Concrete API definitions (not vague service boxes).
- A data model with table shapes and key constraints.
- A reasoned choice between optimistic and pessimistic locking, including when you would switch strategies.
- Where you use strong consistency versus eventual consistency, and why each is safe.
- How idempotency keys flow end-to-end through the checkout and payment path.
- How hold expiry is enforced correctly, even if the background worker lags.
- How the system behaves when the payment processor times out.
- At least one concrete failure mode and its recovery path.
Hints
Hint 1
Start by identifying the core invariant — a seat can be sold at most once — and work backwards to what consistency guarantees that requires. Not every part of the system needs the same guarantees.
Hint 2
The read/write ratio is extreme: millions of users are reading the seat map, but successful writes are bounded by inventory size. That asymmetry should drive where you put a cache and where you insist on hitting the database.
Hint 3
Think about hold expiry as two separate problems: correctness (a hold that should be expired must never block a new purchase) and consistency (users need to see the seat become available again). Those can use different mechanisms.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Requirements and scale
Before drawing any boxes, pin down what is actually required.
Functional scope: seat map browsing with live availability; temporary seat holds with a TTL (10 minutes is typical); checkout with idempotent payment; a virtual waiting room for hot on-sales; cancellations, refunds, and chargeback handling; and an immutable audit log.
The one hard invariant: no seat is ever sold twice. Everything else — latency, availability, freshness of the seat map — is negotiable. This single rule determines where you need strong consistency.
Back-of-envelope: 60k seats, 10M users in 10 minutes → roughly 17k arrivals/second, bursting to 100k+ req/sec on seat-map reads. Successful hold writes are capped by inventory, so at most ~60k holds plus retry noise, meaning 5–20k write attempts/sec against a very small keyspace. The system is read-heavy and cacheable on the browse path, contended and correctness-critical on the hold path. Design for that gap.
2. APIs
GET /events/{eventId}/seatmap # cached, versioned ETag
POST /queue/{eventId}/join # → {queueToken, position}
GET /queue/{eventId}/status?token=… # → {position, admitted, accessToken}
POST /events/{eventId}/holds # Idempotency-Key header required
body {seatIds[]} # → {holdId, expiresAt} | 409
DELETE /holds/{holdId} # explicit early release
POST /orders # Idempotency-Key header required
body {holdId, paymentMethodToken} # → {orderId, status}
GET /orders/{orderId}
POST /orders/{orderId}/refund # Idempotency-Key header required
POST /webhooks/payments # signed callback from PSP
WS /events/{eventId}/availability # server-pushed seat-state deltas
A hold is all-or-nothing for the requested seat set. Partial holds create orphaned inventory and confusing UX.
3. Data model
Use a relational store with ACID transactions (Postgres, Spanner, or CockroachDB), sharded by event_id so one event's inventory fits in one shard and transactions never cross shards.
Key tables:
seats(event_id, seat_id, status {AVAILABLE|HELD|SOLD}, hold_id, hold_expires_at, order_id, version)— PK is(event_id, seat_id). Theversioncolumn enables optimistic locking.holds(hold_id, event_id, user_id, seat_ids[], expires_at, status {ACTIVE|CONVERTED|EXPIRED|RELEASED})orders(order_id, user_id, hold_id UNIQUE, amount, status {PENDING_PAYMENT|CONFIRMED|FAILED|REFUNDED|CHARGEBACK})payments(payment_id, order_id, psp_reference, idempotency_key UNIQUE, status, attempts)idempotency_keys(key, user_id, request_hash, response_body, created_at)— unique constraint onkey.outbox(id, aggregate_id, event_type, payload, published_at)— transactional outbox feeding Kafka for fan-out, audit, and notifications.
For general-admission sections, replace per-seat rows with a counter: UPDATE sections SET remaining = remaining - n WHERE remaining >= n. Under extreme contention, split the counter into N sub-buckets and retry on a different bucket.
4. Architecture overview
Client → CDN / WAF / Bot detection → API Gateway (auth, rate limiting)
→ Waiting Room service (Redis sorted set, token issuance)
→ Seat Map Read service ← Redis cache ← CDC from Inventory DB
→ Inventory / Hold service → Inventory DB (sharded by event_id)
→ Order service → Payment service → PSP (Stripe / Adyen)
→ Outbox → Kafka → {WebSocket fan-out, Audit log, Notifications}
→ Hold Expiry worker
5. Deep dives
Preventing oversells: locking strategy
The database row is the single source of truth. Redis must never be the correctness layer — it is a fast pre-filter that rejects obviously taken seats before touching the DB.
The default choice is optimistic locking via a conditional update:
UPDATE seats
SET status = 'HELD',
hold_id = :holdId,
hold_expires_at = now() + interval '10 minutes',
version = version + 1
WHERE event_id = :eventId
AND seat_id = ANY(:seatIds)
AND (
status = 'AVAILABLE'
OR (status = 'HELD' AND hold_expires_at < now())
);
-- If updated rowcount != len(seatIds), rollback → return 409
This holds no locks between reads and writes, so throughput stays high. Conflicts fail cheaply. It works well because users spread across a large seat map — row contention is low.
When to use pessimistic locking (SELECT ... FOR UPDATE): if you need to read seat state and make decisions within the same transaction, or if contention on specific rows is genuinely high (e.g., "best available" allocation). The risk is lock queues and deadlocks. Mitigate deadlocks by always acquiring row locks in sorted seat_id order.
Avoid distributed locks (Redlock) as the correctness mechanism. GC pauses, clock skew, and Redis failovers can all violate the safety guarantees. Use Redis only to shed load before the database sees a request.
Hold TTL enforcement
Correctness is enforced lazily inside the SQL predicate (hold_expires_at < now()). An expired hold is treated as available by any subsequent update, so correctness never depends on a background job running on time.
A separate sweeper job and a delayed-queue worker handle the visibility side: they release expired holds, set status = 'AVAILABLE', and publish deltas to the WebSocket fan-out. At checkout, the order service re-validates hold_id and expiry inside the same transaction that creates the order.
Consistency tiers
| Path | Consistency | Reason |
|---|---|---|
| Inventory writes and orders | Strong (single-shard ACID) | Oversell prevention is a hard invariant |
| Seat map reads | Eventually consistent (~1s lag) | A stale map costs a 409 retry, never an oversell |
| Waiting room position | Approximate | Exact ordering is not a correctness requirement |
Payment idempotency and failure handling
- The client generates an
Idempotency-Key(UUID). The server stores(key, request_hash)under a unique constraint before calling the PSP. A replay returns the stored response. - In one transaction: create the order as
PENDING_PAYMENT, extend the hold expiry to cover expected payment time. - Call the PSP with the same idempotency key, so PSP-side retries never double-charge.
- On PSP success: one transaction moves seats
HELD → SOLD, sets order toCONFIRMED, writes an outbox event. - On timeout or unknown outcome: do not release the seats. Reconcile via the PSP webhook or polling. Retry with exponential backoff and jitter. Releasing seats optimistically risks a window where two buyers both think a seat is available.
- Rare race: payment succeeds but the hold has already expired. Auto-refund and send the user an apology. Log it — this should be a very rare event, and a high rate signals a TTL that is too short.
The overall checkout flow is a saga with compensating transactions. There is no 2PC across the PSP boundary.
Refunds and chargebacks
- Refund: idempotent PSP refund call, order moves to
REFUNDED, seat returns toAVAILABLE(or stays void depending on policy), ticket barcode invalidated. - Chargeback webhook: order moves to
CHARGEBACK, barcode invalidated, user account flagged for review. The dispute window means the seat may or may not be re-listed, depending on business rules.
Anti-bot and rate limiting
- Waiting room tokens are tied to a verified identity (CAPTCHA at join time).
- API Gateway enforces per-IP and per-account rate limits. Limits tighten when a hot on-sale is active.
- Purchase limits (e.g., 4 tickets per account per event) are enforced at the hold creation step inside the DB.
- Velocity checks on payment methods flag unusual patterns for manual review.
Common mistakes to avoid
- Using Redis as the seat reservation store. Redis replication is asynchronous and does not provide the durability guarantees needed for financial inventory.
- Releasing seats optimistically on payment timeout. Always reconcile before releasing.
- Forgetting to re-validate hold expiry at order creation time. The hold window and the order creation are separate steps; a race can exist between them.
- A single global seat-map cache entry. Invalidate at the seat level (or section level) to avoid invalidating the entire map on every update.