System design interview: design a ticket booking system

A ticket booking system sells a fixed number of seats to far more people than there are seats, often in the first minutes after a sale opens. The interview turns on three decisions: how you hold a seat while someone pays without ever selling it twice, how you absorb a crowd ten thousand times larger than normal traffic, and how you keep payment and reservation consistent when either can fail.

By Published 7 min read

1. Clarify the requirements

  • Functional: browse events, view available seats (assigned seating or general admission), hold seats while paying, pay, receive a ticket, cancel within the rules.
  • Non-functional: strong consistency for inventory (no double booking), high availability for browsing, fairness when demand exceeds supply, and protection against bots.
  • Ask about: assigned seats or general admission, how many tickets one person can buy, how long a hold lasts, and whether resale is in scope.
  • Out of scope unless asked: event creation tools for organizers, dynamic pricing, the payment processor itself.

2. Estimate the scale

Back-of-envelope estimate (assumed figures, for illustration)
QuantityAssumptionResult
Normal load10 million seat-map views a dayabout 115 reads a second; easy
A hot on-sale2 million people arrive in the first 10 minutes for 50,000 seatsabout 3,300 arrivals a second, 40 people per seat
Hold attempts during the rusheach person tries 3 to 5 seat selections10,000 to 15,000 write attempts a second against one event's inventory
Inventory sizeone venue of 50,000 seatstiny: fits in memory on one machine
Tickets per year100 millionabout 3 a second on average; storage is not the problem
Back-of-envelope estimate (assumed figures, for illustration). Scroll sideways on a small screen.

The estimate shows where the difficulty is. Data volume is small and average load is modest. The problem is contention: thousands of requests a second competing for the same few thousand rows, during a few minutes, with real money attached.

3. API

GET  /events/{eventId}/seats            -> seat map with status (may be a few seconds stale)
POST /events/{eventId}/holds            {seatIds[], idempotencyKey} -> {holdId, expiresAt}
POST /holds/{holdId}/checkout           {paymentToken, idempotencyKey} -> {orderId, status}
GET  /orders/{orderId}                  -> order and tickets
DELETE /holds/{holdId}                  -> release early
Core endpoints

4. Data model

Main tables
TableKey fieldsNotes
eventsevent_id, venue_id, starts_at, on_sale_atRead-heavy, cached
seatsevent_id, seat_id, section, row, price_tier, status, hold_id, hold_expires_at, versionOne row per seat per event; status is AVAILABLE, HELD or SOLD
holdshold_id, user_id, event_id, seat_ids, expires_atShort-lived; TTL cleanup
ordersorder_id, user_id, hold_id, payment_id, status, idempotency_keyUnique constraint on idempotency_key
ticketsticket_id, order_id, seat_id, barcodeIssued only after payment and confirmation both succeed
Main tables. Scroll sideways on a small screen.

A relational database is the natural choice here: the data is small, the relationships are real, and you need transactions on the seat rows. Partition by event_id when you have many events; one event's inventory stays on one shard, which keeps every hold a single-shard transaction.

5. Holding a seat without double booking

This is the core of the interview. Choosing a seat and paying for it are minutes apart, and you cannot lock a database row for minutes. So the seat moves through states, and each transition is a short atomic update that checks the state it expects.

UPDATE seats
   SET status = 'HELD', hold_id = :holdId, hold_expires_at = now() + interval '8 minutes'
 WHERE event_id = :eventId
   AND seat_id = ANY(:seatIds)
   AND (status = 'AVAILABLE' OR (status = 'HELD' AND hold_expires_at < now()));
-- In the same transaction: if rows updated != number of seats requested, roll back.
Hold: succeeds only if every requested seat is still free (or its old hold expired)
UPDATE seats
   SET status = 'SOLD'
 WHERE hold_id = :holdId
   AND status = 'HELD'
   AND hold_expires_at > now();
Confirm: only the current, unexpired holder can turn HELD into SOLD
  • Why not a distributed lock? You can hold seats in Redis with SET seat:{id} holdId NX PX 480000, which is fast and expires on its own. It works, but the database must still enforce the final state, so many designs keep the conditional update as the source of truth and use Redis only to shed obviously failing requests early.
  • Expiry is lazy. The hold query treats an expired hold as available, so you do not depend on a cleanup job running on time. A background sweep only tidies rows and updates the cached seat map.
  • General admission is simpler: one counter per section, decremented with a conditional update (WHERE remaining >= :qty).

6. Surviving the on-sale rush: the waiting room

No database should take two million users at once for one event. A virtual waiting room turns the crowd into a queue with a controlled exit rate.

  1. Edge
    • CDN
    • Bot checks
    • Waiting room (queue tokens)
  2. Services
    • Seat map service
    • Booking service
    • Checkout service
  3. Data
    • Seat map cache
    • Inventory DB (sharded by event)
    • Orders DB
  4. External
    • Payment provider
    • Ticket delivery (email, app)
  5. Async
    • Hold expiry sweep
    • Payment reconciliation
Request flow for a hot event. Users reach a CDN and edge layer, which serves static pages and the waiting room. The waiting room gives each user a signed queue token and admits them at a fixed rate. Admitted users call the booking service, which reads the cached seat map and performs holds and confirmations against the inventory database. Checkout calls the payment provider, and a reconciliation worker matches payments with orders.
  1. ArriveBefore the sale opens, users land on a static page from the CDN. At opening time each gets a random position (fair for everyone who arrived early) or a first-come position, and a signed token.
  2. WaitThe page polls a cheap endpoint for its turn. This load hits the edge, not the booking service.
  3. AdmitThe waiting room admits users at the rate the booking service can handle, for example 2,000 a minute, and adjusts as holds turn into sales or expire.
  4. BookOnly requests with a valid admission token reach the booking service. When inventory is gone, the waiting room tells everyone still queued at once.

7. Payment and consistency

  • Idempotency keys on hold and checkout requests mean a retried click or a dropped connection cannot create two orders or two charges.
  • Authorize, then confirm, then capture. Authorize the card, run the confirm update on the seats, and capture the payment only if the confirm succeeded. If the confirm fails because the hold expired, void the authorization.
  • Reconciliation. Payment providers send webhooks late or twice. A worker matches every successful payment with a sold order and refunds or flags anything left over.
  • Tickets last. Issue the barcode only when both sides agree; then send it by email or to the app.

8. Failure modes

What breaks and how the design copes
FailureEffectMitigation
Payment succeeds after the hold expiredCustomer charged for a seat someone else now holdsConfirm before capture; void or refund automatically; offer a nearby seat if any remain
Inventory shard overloadedHolds time out for one eventWaiting-room admission rate, per-user hold limits, and a read cache that keeps browsing off the shard
Bots grab seatsReal fans see nothing availableBot checks at the edge, verified accounts for presales, per-account and per-card limits
Seat map cache is staleA user picks a seat already takenHold fails cleanly with the updated map; staleness of a few seconds is acceptable by design
Region outageSales stopInventory for one event lives in one primary region with a synchronous replica; fail over rather than accept writes in two places
What breaks and how the design copes. Scroll sideways on a small screen.

9. Trade-offs to discuss

  • Hold length. Long holds are kinder to slow buyers but lock inventory that may never sell; short holds keep seats moving but frustrate people mid-payment. Eight to ten minutes is common; say why you chose yours.
  • Random or first-come queue order. Random order at opening removes the incentive to hammer the site early; first-come rewards those who arrived first. Many sellers randomize everyone who arrived before the sale opened.
  • Pessimistic or optimistic. The conditional update is optimistic: no locks held, failures retried. Row locks (SELECT ... FOR UPDATE) are simpler to reason about but serialize every attempt on hot seats.
  • Show exact availability or not. Exact live availability under heavy contention costs a lot; a "best available" picker that assigns seats server-side avoids most conflicts.

10. How to talk through it in the interview

Fictional example

Getting to the double-booking answer quickly
Interviewer
Two people click the same seat at the same moment. What happens?
Candidate
Both send a hold. The hold is one conditional update: set the seat to HELD only if it is AVAILABLE or its old hold has expired. The database applies them one after the other, so the first succeeds and the second updates zero rows and gets the refreshed seat map.
Interviewer
And if the first person's card is declined?
Candidate
The hold expires after eight minutes or is released at once on decline, and the seat becomes available again. Confirmation only works for the current holder, so a late payment cannot steal it back.
  • Lead with the contention numbers; they justify the waiting room.
  • Write the conditional update on the whiteboard. It is the most convincing minute of the answer.
  • Close with the payment-after-expiry case. It shows you think about money, not only rows.

Practicing this design with Natively

Ticket booking is a favourite because it hides a concurrency problem inside a product everyone knows, and candidates often talk about the product for too long. Rehearse it as a timed mock interview over a call. Natively keeps a live transcript and can turn the flow you describe into a diagram, so after the session you can check whether the hold and confirm steps came across clearly. Pair this walk-through with the payment system design for idempotency and reconciliation, and with the web crawler for a very different kind of scaling problem.

Questions people ask

How do you prevent double booking in a ticket system?

Hold the seat with one conditional update that only succeeds if the seat is available or its previous hold has expired, then confirm the sale with another update that only works for the current, unexpired holder.

What is a virtual waiting room?

A queue in front of a busy sale. Users get a signed position at the edge and are admitted to the booking service at a controlled rate, so the database sees a steady flow instead of the whole crowd at once.

What happens if payment succeeds after the seat hold expires?

The confirm step fails because the hold is no longer valid, so the payment is voided or refunded automatically. Authorizing first and capturing only after a successful confirm avoids most of these cases.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP