Case Study 11 โ€” Ticket Booking (Ticketmaster-like)

Design a concert/event ticket booking system where thousands of users compete for a limited seat inventory at the same time.

1. Problem

Users browse events, pick seats on a venue map, hold them briefly, pay, and receive confirmed tickets. The hard part is preventing double-booking when many people click the same seat at once.

2. Requirements

Functional (MVP)

  • List events and show available seats on a venue map
  • Search/filter by city, date, artist
  • Hold a seat for a short window (e.g., 10 minutes) while user pays
  • Confirm booking after successful payment
  • Release held seats if payment fails or timer expires
  • View "My Tickets" with QR/barcode for entry
  • Admin: create events, upload seat maps, set prices by section

Out of scope (initially)

  • Dynamic pricing / auctions
  • Resale marketplace
  • Waitlists and lottery draws
  • Complex package bundles (hotel + ticket)
  • Real-time seat view sync for every mouse hover (nice-to-have later)

Non-functional

  • Strong consistency for seat inventory (no two confirmed bookings for same seat)
  • Handle flash sales โ€” spikes when tickets go on sale
  • Hold path should respond in < 200 ms (user expects instant feedback)
  • Payment path can tolerate slightly higher latency
  • Idempotent payment confirmation (retries must not double-charge or double-book)
  • High availability during on-sale windows

3. Back-of-the-envelope estimates

These numbers are rough order-of-magnitude math โ€” not a capacity plan. In interviews, the goal is to show you know what to count and which resource breaks first. A useful shortcut: 1 QPS sustained โ‰ˆ 86,400 requests/day (86,400 seconds in a day). Traffic rarely stays flat; peak is often 2โ€“5ร— average, and flash sales can spike far higher for minutes at a time.

Why we estimate

Ticket booking has two very different modes: calm browsing (read-heavy) and on-sale chaos (write-heavy contention on a tiny inventory). Estimates tell us:

  • Whether the Inventory Service or Payment Service is the real bottleneck
  • If we need Redis locks, sharding by event, or a virtual waiting room
  • How much storage seat rows and booking history actually need (usually smaller than people guess)

Assumptions

AssumptionValueWhy it matters
Popular events per month500Steady catalog growth
Hot event seat count20,000 seats sold in 10 minutesDefines worst-case write burst
Average event size5,000 seats, 80% sell-throughTypical storage and confirmation rate
Peak concurrent users (one hot event)50,000Drives hold-attempt QPS
Hold window10 minutesSeats locked but not yet sold
Seat click rate during on-sale~2 clicks/min per active userMany clicks fail fast (seat taken)

Step A โ€” Traffic (QPS) with labeled arithmetic

Confirmed bookings (successful writes to inventory):

Seats to sell     = 20,000 seats
On-sale window    = 10 minutes = 600 seconds

Peak confirm QPS  = 20,000 รท 600
                  โ‰ˆ 33 confirmations/second

Even at peak, only ~33 seats/sec move from HELD โ†’ SOLD. Payment and confirmation are not the hottest path.

Hold attempts (users clicking seats โ€” the real spike):

Concurrent users        = 50,000
Clicks per user per min  = 2

Hold attempt QPS        = (50,000 ร— 2) รท 60
                        โ‰ˆ 1,700 holds/second (peak)

Most of these return 409 SEAT_UNAVAILABLE quickly โ€” but the server still must check atomically every time.

Browse / seat-map reads during on-sale:

Read:write ratio during on-sale โ‰ˆ 10:1 (users refreshing the map)

Peak read QPS โ‰ˆ 1,700 ร— 10 โ‰ˆ 17,000 reads/second

Steady-state (no flash sale):

500 events/month ร— 5,000 seats ร— 80% sold = 2M seats sold/month
โ‰ˆ 2M รท (30 ร— 86,400) โ‰ˆ 0.8 confirmations/s average

Browse traffic between sales is much lower โ€” flash sales dominate design.

Step B โ€” Storage

Seat inventory rows:

Rows            = 500 events ร— 5,000 seats = 2.5M seat rows
Bytes per row   โ‰ˆ 200 B (IDs, status, price, version, timestamps)

Seat data       = 2.5M ร— 200 B โ‰ˆ 500 MB

Bookings, payments, tickets (1 year, rough):

Bookings/year   โ‰ˆ 2M seats ร— 12 months โ‰ˆ 24M booking rows (same order of magnitude)
Row size        โ‰ˆ 300โ€“500 B with indexes

Year-1 total    โ‰ˆ tens of GB, not petabytes โ€” seat contention matters more than disk

Step C โ€” Bandwidth

Seat map API responses (peak read path):

Seat map payload  โ‰ˆ 5,000 seats ร— ~50 B JSON โ‰ˆ 250 KB per full map fetch
Peak read QPS    โ‰ˆ 17,000/s

If every read fetched full map (worst case):
  17,000 ร— 250 KB โ‰ˆ 4.25 GB/s  โ†’ unrealistic; CDN + section-level fetch + caching required

In practice, clients fetch sections or cached snapshots, not 17k full maps/sec. Bandwidth pushes you toward CDN for static venue maps and incremental seat status updates.

Step D โ€” Read:write ratio table

OperationTypePeak QPS (hot event)Notes
View seat map / browseRead~17,000/sPoll or WebSocket updates
Hold seatWrite~1,700/sMust be atomic; Redis + DB
Confirm after paymentWrite~33/sIdempotent; lower volume
Payment chargeExternal write~33/sStripe-like API
Hold expiry (worker)Write~33/sReleases timed-out holds

Ratio during on-sale: reads ~10ร— writes on inventory; hold writes dominate internal design.

What the numbers tell us

  • Seat holds (~1,700/s peak), not payments (~33/s), are the bottleneck โ†’ optimize Inventory Service with Redis SET NX, DB row locks, and sharding by event_id
  • Strong consistency is non-negotiable for confirmed seats; failed holds can fail fast
  • 10-minute holds mean many seats sit in HELD during on-sale โ†’ expiry workers and TTL are first-class
  • 17k read/s on seat maps โ†’ cache per-event availability, section-level APIs, optional WebSocket for deltas
  • 500 MB of seat rows is tiny โ†’ the hard problem is concurrency, not storage
  • At extreme scale, add a virtual waiting room to cap concurrent users below 50k on one event

Common mistake for this problem

Treating payment QPS as the scaling bottleneck. Interviewers want you to see that inventory contention (many users, few seats) is the hard part. Another mistake: using eventual consistency for seat state โ€” double-booking is unacceptable; use atomic holds + durable DB confirmation.

4. High-Level Design (HLD)

Components

ComponentRole
Event ServiceEvents, venues, schedules, search
Inventory ServiceSeat map, availability, holds, releases
Booking ServiceOrchestrates hold โ†’ pay โ†’ confirm lifecycle
Payment ServiceCharges card, webhooks, idempotency
Ticket ServiceGenerates ticket PDF/QR after confirmation
RedisShort-lived seat locks (fast path)
Inventory DBAuthoritative seat state per event
Queue + workersExpire holds, send emails, async cleanup

Flows

Browse & view seats

  1. User opens event โ†’ Event Service returns metadata
  2. Inventory Service returns seat map + status (AVAILABLE, HELD, SOLD)
  3. Frontend polls or uses WebSocket for updates (optional at scale)

Hold โ†’ Pay โ†’ Confirm (happy path)

  1. User selects seat A-12 โ†’ POST /holds
  2. Inventory Service tries atomic lock in Redis + DB update to HELD
  3. Booking Service creates booking in PENDING_PAYMENT with expires_at
  4. User submits payment โ†’ Payment Service charges with idempotency key
  5. On success, Booking Service calls Inventory to CONFIRM (seat โ†’ SOLD)
  6. Ticket Service generates QR; notification sent

Hold expiry

  1. Timer fires (Redis TTL or scheduled job via queue)
  2. If booking still PENDING_PAYMENT, release seat โ†’ AVAILABLE
  3. Cancel booking record

Trade-offs

ChoiceProsCons
Redis lock + DBFast holds, survives Redis restart if DB is truthTwo layers to keep in sync
DB-only pessimistic lock (SELECT FOR UPDATE)Simpler correctnessSlower under extreme contention
Optimistic locking (version column)Good for low contentionMany retries during flash sales
Seat-level vs section-level inventorySeat map UXMore rows, harder to scale
10-min hold vs 5-minBetter conversionMore seats locked, fewer available

Interview tip: Start with Redis hold + DB confirmation. Mention DB-only as MVP if team is small.

5. Low-Level Design (LLD)

APIs

GET /api/v1/events?city=NYC&date=2026-08-01
โ†’ { events: [{ eventId, title, venue, startsAt, minPrice }] }

GET /api/v1/events/:eventId/seats
โ†’ { sections: [...], seats: [{ seatId, row, number, price, status }] }

POST /api/v1/holds
Headers: Idempotency-Key: <uuid>   # optional for hold retries
Body: { eventId, seatIds: ["s-101"], userId }
โ†’ 201 { holdId, bookingId, expiresAt, totalAmount }
โ†’ 409 { error: "SEAT_UNAVAILABLE", seatIds: ["s-101"] }

DELETE /api/v1/holds/:holdId
โ†’ 204

POST /api/v1/bookings/:bookingId/pay
Headers: Idempotency-Key: <uuid>   # required
Body: { paymentMethodId, amount }
โ†’ 200 { bookingId, status: "CONFIRMED", ticketIds: [...] }
โ†’ 402 { error: "PAYMENT_FAILED" }
โ†’ 410 { error: "HOLD_EXPIRED" }

GET /api/v1/users/:userId/tickets
โ†’ { tickets: [{ ticketId, event, seat, qrUrl }] }

Schema

events (
  event_id      UUID PRIMARY KEY,
  title         TEXT NOT NULL,
  venue_id      UUID NOT NULL,
  starts_at     TIMESTAMPTZ NOT NULL,
  on_sale_at    TIMESTAMPTZ NOT NULL,
  status        VARCHAR(20)  -- DRAFT, ON_SALE, SOLD_OUT
)

seats (
  seat_id       UUID PRIMARY KEY,
  event_id      UUID NOT NULL,
  section       VARCHAR(20),
  row_label     VARCHAR(10),
  seat_number   INT,
  price_cents   INT NOT NULL,
  status        VARCHAR(20),  -- AVAILABLE, HELD, SOLD
  version       INT DEFAULT 0,  -- optimistic lock
  held_by       UUID NULL,
  hold_expires  TIMESTAMPTZ NULL,
  UNIQUE (event_id, section, row_label, seat_number)
)

bookings (
  booking_id    UUID PRIMARY KEY,
  user_id       UUID NOT NULL,
  event_id      UUID NOT NULL,
  status        VARCHAR(30),  -- PENDING_PAYMENT, CONFIRMED, CANCELLED, EXPIRED
  total_cents   INT NOT NULL,
  hold_expires  TIMESTAMPTZ NOT NULL,
  idempotency_key VARCHAR(64) UNIQUE,
  created_at    TIMESTAMPTZ NOT NULL
)

booking_seats (
  booking_id    UUID REFERENCES bookings,
  seat_id       UUID REFERENCES seats,
  PRIMARY KEY (booking_id, seat_id)
)

payments (
  payment_id    UUID PRIMARY KEY,
  booking_id    UUID NOT NULL,
  idempotency_key VARCHAR(64) UNIQUE NOT NULL,
  amount_cents  INT NOT NULL,
  status        VARCHAR(20),  -- PENDING, SUCCEEDED, FAILED
  gateway_ref   TEXT,
  created_at    TIMESTAMPTZ NOT NULL
)

tickets (
  ticket_id     UUID PRIMARY KEY,
  booking_id    UUID NOT NULL,
  seat_id       UUID NOT NULL,
  qr_payload    TEXT NOT NULL,
  issued_at     TIMESTAMPTZ NOT NULL
)

Modules

EventController / EventService / EventRepository
InventoryController / SeatLockService / SeatRepository
BookingController / BookingOrchestrator / HoldExpiryWorker
PaymentController / PaymentService / PaymentGatewayClient
TicketService / QrGenerator
NotificationProducer

Key algorithm โ€” seat hold (Redis + DB)

function holdSeats(eventId, seatIds, userId, ttlSeconds=600):
  for seatId in seatIds:
    lockKey = "hold:{eventId}:{seatId}"
    acquired = redis.set(lockKey, userId, NX, EX=ttlSeconds)
    if not acquired:
      releaseAnyPartialLocks(eventId, seatIds, userId)
      return SEAT_UNAVAILABLE(seatId)

  # All Redis locks acquired โ€” persist to DB in one transaction
  begin transaction
    for seatId in seatIds:
      row = repo.selectSeatForUpdate(seatId)
      if row.status != AVAILABLE:
        rollback; releaseRedisLocks(); return SEAT_UNAVAILABLE
      repo.updateSeat(seatId, status=HELD, held_by=userId,
                      hold_expires=now()+ttl, version=row.version+1)
    booking = repo.createBooking(userId, eventId, PENDING_PAYMENT, hold_expires)
    repo.linkBookingSeats(booking.id, seatIds)
  commit

  return { holdId, bookingId, expiresAt }

Why both Redis and DB?

  • Redis rejects duplicate holds in microseconds (flash sale UX)
  • DB is durable source of truth if Redis evicts or restarts

Key algorithm โ€” confirm after payment

function confirmBooking(bookingId, idempotencyKey, paymentPayload):
  existing = payments.findByIdempotencyKey(idempotencyKey)
  if existing: return existing.result  # idempotent replay

  booking = repo.getBooking(bookingId)
  if booking.status == CONFIRMED: return booking  # already done
  if booking.hold_expires < now(): return HOLD_EXPIRED
  if any seat not HELD by this user: return INVALID_STATE

  payment = gateway.charge(paymentPayload)
  if payment.failed:
    repo.savePayment(FAILED, idempotencyKey)
    return PAYMENT_FAILED

  begin transaction
    repo.savePayment(SUCCEEDED, idempotencyKey, payment.ref)
    for seatId in booking.seatIds:
      repo.updateSeat(seatId, status=SOLD, held_by=null, hold_expires=null)
    repo.updateBooking(bookingId, status=CONFIRMED)
    tickets = ticketService.issue(bookingId)
  commit

  for seatId in booking.seatIds:
    redis.del("hold:{eventId}:{seatId}")

  notify(userId, tickets)
  return { status: CONFIRMED, tickets }

Key algorithm โ€” hold expiry (worker)

function expireHolds():
  expiredBookings = repo.findPendingWhere(hold_expires < now(), limit=500)
  for booking in expiredBookings:
    begin transaction
      repo.updateBooking(booking.id, EXPIRED)
      for seatId in booking.seatIds:
        repo.updateSeatIfHeldBy(seatId, booking.userId, status=AVAILABLE)
    commit
    for seatId in booking.seatIds:
      redis.del("hold:{eventId}:{seatId}")

Run worker every few seconds + rely on Redis TTL as a safety net.

Concurrency & correctness

RiskMitigation
Double booking same seatUNIQUE (event_id, section, row, seat) + transactional status checks
Two holds same seatRedis SET NX + DB SELECT FOR UPDATE
Payment retry double-chargesidempotency_key unique on payments
Payment succeeds but confirm crashesReconciliation job: poll gateway, complete confirm
Partial multi-seat holdHold all-or-nothing in one DB transaction
Stale seat map in UIPoll every 5s or push WebSocket on section granularity

Virtual waiting room (at extreme scale): Before on-sale, queue users in FIFO; only N enter checkout at a time. Reduces thundering herd on Inventory Service.

6. Scale evolution

StageChange
MVPSingle Postgres, Redis, monolith; DB row locks
Hot eventRedis cluster; shard Inventory DB by event_id
Flash saleVirtual waiting room; pre-warm seat cache; CDN for static maps
Global toursRegional read replicas; single writer per event shard
Resale (later)Separate marketplace service; transfer ticket ownership

7. Recap

  • Seat inventory needs strong consistency โ€” optimistic UI is fine, confirmed booking is not
  • Pattern: fast lock (Redis) + durable state (DB) + idempotent payment
  • Hold timer prevents seats being locked forever by abandoned carts
  • Flash sales add queueing and sharding by event, not just bigger servers

Practice: Draw the hold โ†’ pay โ†’ confirm sequence diagram from memory. Write pseudocode for holdSeats including rollback on partial failure.