senior loop
Deep Dives/Ticket Booking & Inventory Reservation

Ticket Booking & Inventory Reservation

Two people click the same seat in the same millisecond. One must lose, and neither may be charged for a seat they do not get. The same problem sits under concert tickets, hotel rooms, flights, and limited-stock drops, and the interview is almost never about the happy path. It is about the second click, the abandoned cart, the late payment, and the million people arriving at ten o'clock.

ConcurrencyPaymentsSenior+ IC~25 min · 10 sections

Prerequisites: Database transactions, idempotency keys, and the saga pattern.

Cover these firstThe Design Round ItselfIdempotency & Exactly-Once Effects in PaymentsSaga, Outbox & CDC for Payments

After this: Prevent double-selling with atomic holds, model date ranges and counted pools, and design the on-sale rush and payment recovery.

Suggested first pass: Read sections 1–5, answer each section in your own words, then use the remaining failure modes and exercises as the advanced pass.

Booking in three lines

1. A unit of inventory is sold at most once. This is the only hard invariant; everything else is a product choice.

2. Buying is two steps, hold then confirm, because payment takes minutes and the seat must not vanish while the customer types a card number.

3. A hold is a lease that expires. Expiry is how abandoned carts return seats to the pool without anyone running a cleanup for correctness.

Illustrative on-sale — size the design before drawing it
50,000
Seats for one arena show. Small data; the difficulty is contention, not volume.
1M
People who show up in the first minute for a hot event. Twenty buyers per seat.
~17k/s
Arrival rate if 1M people hit the page across 60 seconds, before retries and refreshes.
10 min
A typical hold length. 50,000 seats can sit locked by carts that never pay.
1 row
Contention unit for a seat. Two buyers wanting different seats never collide.
1 hot row
Contention unit for a counted pool such as general admission. Everyone hits one counter.
Browsing is not booking

Browsing ("142 seats left in this section") is read-heavy, cacheable, and allowed to be wrong for a few seconds. Holding is write-heavy, uncached, and must be exact. Designs that struggle on sale day almost always mixed the two, so every curious page view reads the same rows that buyers are trying to lock.

State this split early in an interview. It tells the interviewer you know where correctness lives, and it gives you licence to cache aggressively everywhere else.

What not to promise

Do not promise that a seat shown as available can always be bought. Under load, a "stale available" seat fails at hold time and the buyer picks another. The guarantee is that no seat is ever sold twice, not that the seat map is a perfect mirror of the truth. A candidate who tries to make the map perfect has spent the interview on the wrong problem.

Next deep dive
Ride Dispatch & Surge Pricing →
~38 min