Ticketmaster
Hold expiry and payment confirmation race on the last seat.
Topic tools
Layout updated
Problem statement
Design a ticket booking service like Ticketmaster. Users can find events, temporarily hold seats, pay, and receive tickets. Two customers should never buy the same seat.
Functional requirements
- Search events and browse available seats.
- Hold selected seats together until a stated expiry.
- Pay for a valid hold and receive a ticket.
- Check purchase status, cancel eligible reservations, and reconcile refunds.
Non-functional requirements
- Never give the same seat to two buyers.
- Limit booking pressure during popular sales.
- Never charge twice because a response was lost.
- Preserve order and inventory state during retries and failover.
Back-of-the-envelope estimates
| Illustrative estimate |
|---|
| 100k users arrive for 10k seats |
| 20k admitted sessions × 1 hold attempt/10 s ≈ 2k attempts/s |
| 2k checkout attempts/s × 1 KB intent ≈ 2 MB/s raw |
| One-minute provider outage at 2k/s → 120k uncertain/pending attempts |
Entities
| Entity / logical owner |
|---|
| Seat(eventId, seatId, state, reservationId, expiresAt, version) |
| Reservation(id, buyerId, requestId, seatIds, status) |
| Event/index/cache and admission token |
| PaymentIntent(paymentId, reservationId, providerKey, amount, state) |
| Seat/Order(reservationId, buyerId, state, version) |
| ProviderResult(providerId, eventId, status) |
API design
| Operation / input | Response and retry contract |
|---|---|
GET/events?q=... | Search projection with approximate availability. |
POST/reservations {requestId, admissionToken, eventId, seatIds} | 201 {reservationId, expiresAt} only after all-seat commit; 409 on contention. |
GET/reservations/{id} | Authoritative status for the buyer, distinct from the cached seat map. |
POST/payments {requestId, reservationId, paymentMethodToken} | Return paymentId and PENDING/confirmed result; never log raw payment secrets. |
POST/provider-callbacks {eventId, paymentId, result} | Authenticate and apply idempotently; out-of-order callbacks cannot regress state. |
GET/payments/{id} | Durable status and next action for the buyer; retry using the same payment identity. |
High-level design
How to draw this design
- Discover eventsBuyer, gateway, search, and waiting room
- Hold inventoryReservation service, PostgreSQL inventory, and expiry worker
- Settle paymentPayment orchestrator, provider, and reconciler
- Deliver and recoverTicket , confirmation worker, and regional standby
Find an event, admit the buyer, hold the seats, and finish the purchase against that same hold.
- State ownership
- PostgreSQL inventory owns seat and hold state. The provider owns the charge outcome.
- Scale
- Use the waiting room to limit pressure on hot event writes.
- Correctness
- Commit SOLD, the order, and ticket intent together after verifying the eligible hold.
- Failure and recovery
- If the charge succeeds after the hold is released, reconcile and compensate without taking another buyer's seat.
Event discovery and seat holds
Follow a buyer through event search, waiting-room admission, and the PostgreSQL transaction that holds the seats.
- Edge
- Compute
- State
- Messaging
━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault
Each arrow is one interaction. Request, background and recovery branches are not one linear transaction.
Read the 12 flow steps
Checkout, ticket delivery, and recovery
The reservation ID from the first diagram ties payment, inventory ownership, and ticket delivery together.
- Compute
- State
- Messaging
━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault
Each arrow is one interaction. Request, background and recovery branches are not one linear transaction.
Read the 13 flow steps
High-level design component walkthrough
Buyer Client
Search, select seats, pay
Why, tradeoff and connected operations
An application or user-facing endpoint starts or receives this flow.
Tradeoff: Multiple buyers contend for one seat
Connected operations: Search or reserve
CDN / API Gateway
Static assets, auth, controls
Why, tradeoff and connected operations
Centralize admission and routing while keeping business-state ownership downstream.
Tradeoff: Traffic floods still need admission
Connected operations: Search or reserve; Discover events; Admit buyers for hot sale; Forward normal booking
Event Search Service
Fast public search & listing
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Index may show stale availability
Connected operations: Discover events; Read cached search results; Query on cache miss
Waiting Room
Admission token;
Why, tradeoff and connected operations
Centralize admission and routing while keeping business-state ownership downstream.
Tradeoff: Fairness and long user wait
Connected operations: Admit buyers for hot sale; Forward admitted request
Redis / Search Cache
Popular events; approximate seats
Why, tradeoff and connected operations
Redis caches popular event results and approximate seat availability. This absorbs repeated browsing traffic during ticket releases. Cached availability is advisory; the inventory transaction makes the actual reservation decision.
Tradeoff: and invalidation leave stale seats
Connected operations: Read cached search results
Elasticsearch Event Search
Event search projection
Why, tradeoff and connected operations
Elasticsearch supports event-name search and filters such as location and date. It keeps discovery traffic away from the reservation transaction path. Search is a derived view; PostgreSQL alone confirms whether a seat can be held.
Tradeoff: Eventual index freshness / extra cost
Connected operations: Query on cache miss; Update search projection
PostgreSQL: Event Catalog
Store event listings and index publication intent. Seat availability belongs to inventory.
Why, tradeoff and connected operations
PostgreSQL keeps event catalog edits and publication intent consistent. Indexed event IDs support direct reads while a separate search index handles discovery. suits authoritative catalog records; Elasticsearch serves flexible text and filter queries.
Tradeoff: Catalog writes + cross-index sync
Connected operations: Relay catalog updates
Kafka / Outbox / CDC
Project event updates
Why, tradeoff and connected operations
Kafka retained partitioned stream. Key events by the domain ordering key; replay and independent consumers motivate this choice. rows remain in the source database; a relay publishes after commit. Buffer independent producers and consumers, with bounded and replay semantics.
Tradeoff: Index publication is asynchronous
Connected operations: Relay catalog updates; Update search projection
Reservation Service
Validate token, reserve seats
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: High contention on hot events
Connected operations: Forward admitted request; Forward normal booking; Claim seats and write hold
PostgreSQL: Inventory and Holds
Atomically transition eligible seats to HELD and write the reservation and expiry in the same transaction.
Why, tradeoff and connected operations
PostgreSQL atomically checks and reserves the requested seats. Constraints and conditional updates prevent concurrent buyers from owning the same seat. makes multi-seat transactions explicit; a key-value model would need an equally strong reservation boundary.
Tradeoff: locks constrain hot-seat writes
Connected operations: Claim seats and write hold; Read due holds; Release only matching expired hold
Reservation Expiry Worker
Scan for expired holds and release only the exact eligible reservation.
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Expiry jobs can arrive late
Connected operations: Read due holds; Release only matching expired hold
Payment Orchestrator
Durable PAYMENT_PENDING
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: External side effects are uncertain
Connected operations: Validate hold and save intent; Charge with stable provider key; Return result or timeout; Reconcile unclear outcome; Finalize order and
Payment Provider
External charge; retries
Why, tradeoff and connected operations
Treat another system as a separate failure and retry domain with a documented contract.
Tradeoff: Timeout may hide successful charge
Connected operations: Charge with stable provider key; Return result or timeout; Look up original attempt
Reconciliation Worker
Resolve ambiguous timeout
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Slow settlement and refund paths
Connected operations: Reconcile unclear outcome; Look up original attempt; Record verified result
PostgreSQL: Inventory, Holds and Orders
Use the same inventory authority from the reservation diagram. Keep hold, payment intent, final order and state together.
Why, tradeoff and connected operations
The same PostgreSQL inventory authority keeps holds, payment intent, orders and rows consistent. Transactions tie checkout state to the reservation it consumes. This extends the existing store rather than adding an independent payment database.
Tradeoff: Transactions serialize contested seats
Connected operations: Validate hold and save intent; Record verified result; Finalize order and ; Relay committed ticket event; Replicate committed state; Route writes to current owner
Kafka / Transactional Outbox
Reliable post-commit events
Why, tradeoff and connected operations
Kafka retained partitioned stream. Key events by the domain ordering key; replay and independent consumers motivate this choice. rows remain in the source database; a relay publishes after commit. Buffer independent producers and consumers, with bounded and replay semantics.
Tradeoff: Async confirmations may be delayed
Connected operations: Relay committed ticket event; Deliver confirmation
PostgreSQL: Regional Standby
Replicate committed inventory, orders and payment intent for recovery.
Why, tradeoff and connected operations
A PostgreSQL standby copies the inventory and checkout state for regional recovery. It can resume the same transaction model after promotion. It is a replica of the same authority, not a separate database choice; lag and determine safe failover.
Tradeoff: Replication lag risks failover data loss
Connected operations: Replicate committed state; Check replication on failover
Confirmation Worker
Send tickets / receipts
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Email/push duplicates or outage
Connected operations: Deliver confirmation
Event Home-Region Writer
Single authorized write owner
Why, tradeoff and connected operations
Make ownership/version changes explicit; downstream resources must reject stale owners.
Tradeoff: Hot home-region writer bottleneck
Connected operations: Route writes to current owner; Grant new and fence old
Quorum + Epoch/Fencing
Promote new owner safely
Why, tradeoff and connected operations
Make ownership/version changes explicit; downstream resources must reject stale owners.
Tradeoff: Minority region loses write access
Connected operations: Check replication on failover; Grant new and fence old
Engineering control room
Deep dives — decisions, failures and recovery
Open a deep dive to follow the steps, try an example and see how recovery works.
Tradeoffs and alternatives
| Decision | Tradeoff / alternative and recovery implication |
|---|---|
| Let the database choose who gets the seat | Keeping an event's seats in one transaction makes multi-seat holds simpler. Splitting them across writers would need a more complex all-or-nothing protocol. |
| Make expiry and confirmation agree | Cleanup can suggest which rows to inspect; only the transaction decides whether a seat is free. This adds checks but prevents stale workers from undoing a sale. |
| Keep sale traffic away from inventory locks | A waiting room adds delay for buyers, so show that delay and measure fairness rather than treating it as an invisible infrastructure detail. |
| Record payment intent before calling the provider | The customer may see pending longer. Sending a new charge after every timeout is faster only when the original charge truly failed, which a timeout cannot establish. |
| Handle payment that completes after a hold expires | Extending an in-flight hold reduces refunds but keeps inventory unavailable longer. A bounded extension or authorization before capture can reduce the cost. |
| Fail over inventory without selling a seat twice | Asynchronous replication lowers write latency but can leave a gap in holds, orders, and payment attempts. Synchronous remote durability costs a WAN round trip and may stop writes during a partition. |
Production scars & failure modes
Hold expiry and payment confirmation race on the last seat.
Look for: Inspect reservation ID, database time, state version and lock waits.
Recovery and invariant: Use a conditional transition under the inventory authority; confirm only the exact eligible hold and reconcile/refund payment if the hold has already been lost.
| Component / failure | Impact | Recovery mechanism | Alternative / tradeoff |
|---|---|---|---|
| Two buyers select same seats | Only one transaction may own the overlapping seat rows. | Serialize/conditionally update and abort losing attempts; retry only within a bounded client budget. | Hot seats remain contention hotspots despite more stateless servers. |
| Expiry worker runs during payment | It could incorrectly release a seat under active finalization. | Transition to PAYMENT_PENDING under a defined deadline policy; cleanup checks expected state/version. | Long payment uncertainty needs , not unlimited holds. |
| Search index stale | Users see seats/events that have changed. | Validate inventory on reservation and publish versioned projections via . | Eventual discovery improves read scale but accepts occasional booking conflicts. |
| Inventory primary fails | Holds and new reservations pause. | Fence old writer and promote only a safe replica; clients retry requestId. | A stale promotion can double-book; availability cannot trump the ownership invariant. |
| Charge succeeded; caller timed out | The buyer may retry while inventory remains pending. | Reconcile provider status with the same payment key, then finalize idempotently. | Immediate alternate-provider retry risks double charge. |
| Reservation no longer eligible | A late success cannot safely claim already-released inventory. | Verify reservation identity/state; refund or enter manual if finalization fails. | Compensation is not an rollback of the external charge. |
| Old region still running | Two orchestrators may retry the same intent. | Fence inventory writes and reuse the same provider key across both attempts. | alone cannot prevent duplicate external charges without provider support. |
| Confirmation worker unavailable | The order is SOLD but user notifications lag. | Replay durable and provide authoritative order lookup. | Delivery timing is weaker than inventory correctness. |
90-second interview summary
I would split event discovery from seat ownership. An index and cache handle browsing, and a waiting room limits how many buyers reach booking during a popular sale. The inventory transaction in PostgreSQL decides whether all requested seats can be held together, using database time for expiry.
Checkout writes payment intent and a stable provider key before contacting the provider. If a worker crashes or times out, the next worker reconciles the same attempt. The database commits the order, the final seat state, and ticket delivery work together. Workers can retry delivery without repeating the sale.
If a payment succeeds after the hold was lost, the system voids or refunds the charge. It cannot sell a seat already owned by another buyer. This is why I track hold identity, payment status, and ticket delivery as related but separate states.
I would assign an event one write region, fence the old owner during failover, and pause sales until the new owner can prove it has the inventory and payment state needed to resume. Browsing can stay available. I am willing to delay a sale to avoid double-selling or double-charging.
Explain it without looking
Explain let the database choose who gets the seat
Reveal answer
Claim all requested seats in one PostgreSQL transaction.
A Redis lock can expire while payment runs. It does not establish permanent ownership of inventory.
Keeping an event's seats in one transaction makes multi-seat holds simpler. Splitting them across writers would need a more complex all-or-nothing protocol.
Explain make expiry and confirmation agree
Reveal answer
Check hold identity, current state and database time before changing a reservation.
A delayed cleanup message may refer to a hold that has already been sold or replaced.
Cleanup can suggest which rows to inspect; only the transaction decides whether a seat is free. This adds checks but prevents stale workers from undoing a sale.
Explain keep sale traffic away from inventory locks
Reveal answer
Serve browsing from caches and limit how many buyers reach booking at once.
A cached available seat is not a reservation, and thousands of contenders can overwhelm the write path.
A waiting room adds delay for buyers, so show that delay and measure fairness rather than treating it as an invisible infrastructure detail.
Explain record payment intent before calling the provider
Reveal answer
Create one durable payment attempt and one stable provider key per checkout operation.
A crash can happen after the provider charges the customer but before the application records the response.
The customer may see pending longer. Sending a new charge after every timeout is faster only when the original charge truly failed, which a timeout cannot establish.
Explain handle payment that completes after a hold expires
Reveal answer
Confirm a sale only while the exact reservation is still eligible. Refund or void a successful payment if that claim was lost.
The seat may already belong to another buyer by the time a delayed success arrives.
Extending an in-flight hold reduces refunds but keeps inventory unavailable longer. A bounded extension or authorization before capture can reduce the cost.
Explain fail over inventory without selling a seat twice
Reveal answer
Route each event to one fenced inventory writer and prove the recovery copy has the state needed to resume sales.
A new region can otherwise see an already-sold seat as free or reissue a payment while the old owner is still active.
Asynchronous replication lowers write latency but can leave a gap in holds, orders, and payment attempts. Synchronous remote durability costs a WAN round trip and may stop writes during a partition.
Revision checklist
Revision checklist
- Reconstruct let the database choose who gets the seat: Claim all requested seats in one PostgreSQL transaction.
- Reconstruct make expiry and confirmation agree: Check hold identity, current state and database time before changing a reservation.
- Reconstruct keep sale traffic away from inventory locks: Serve browsing from caches and limit how many buyers reach booking at once.
- Reconstruct record payment intent before calling the provider: Create one durable payment attempt and one stable provider key per checkout operation.
- Reconstruct handle payment that completes after a hold expires: Confirm a sale only while the exact reservation is still eligible. Refund or void a successful payment if that claim was lost.
- Reconstruct fail over inventory without selling a seat twice: Route each event to one fenced inventory writer and prove the recovery copy has the state needed to resume sales.
- Name the authoritative state, boundary, retry identity and failure-domain durability guarantee.
- Explain one alternative and exactly which guarantee you would relax.
- Redraw the request and recovery paths without looking; mark what required a hint.
60-minute interview outline
60-minute interview walkthrough
| Time | Focus | What to cover |
|---|---|---|
| 0–5 min | Introductions | Introduce yourself briefly and confirm the interview format. |
| 5–15 min | Scope and scale | Scope event discovery, seat holds, and checkout. Estimate demand for a hot sale and define the hold and payment guarantees. |
| 15–30 min | High-level design | Draw discovery and booking through the waiting room and inventory database. Extend the same hold into checkout and ticket delivery. |
| 30–45 min | Deep dives | Explain seat holds and how expiry competes with confirmation. Keep the order and ticket intent in the same transaction. |
| 45–55 min | Failure and recovery | Walk through payment success after the hold is lost. Reconcile the original charge and compensate without taking another buyer’s seat. |
| 55–60 min | Wrap-up | Summarize the design and its main tradeoff. Leave time for questions. |
On this page
- Problem statement
- Functional requirements
- Non-functional requirements
- Back-of-the-envelope estimates
- Entities
- API design
- High-level design
- High-level design component walkthrough
- Engineering control room
- Deep dives — decisions, failures and recovery
- Tradeoffs and alternatives
- Production scars & failure modes
- 90-second interview summary
- Explain it without looking
- Revision checklist
- 60-minute interview walkthrough