Worked interview ticket bookingMany buyers. One seat. Keep every booking correct.
Worked interview ticket booking. Learn the concepts, explore a model and defend your design.
13SYSTEM DESIGN
DEFINITION
A ticket-booking system coordinates scarce inventory and uncertain payment outcomes. Browsing can show an approximate seat map, but reservation and sale need an authoritative state transition that prevents two buyers being promised the same seat. This is an original worked solution to a Microsoft candidate-reported ticket-booking topic.
A seat has a controlled state machine
STEP 1AvailableCan attempt a hold
STEP 2HeldExpires under a stated rule
STEP 3ConfirmedPayment + seat rules satisfied
A transition must be atomic at its authority; a screen displaying availability does not own the seat.
CONCEPT 1
Microsoft reported topic · A ticket-booking service
1 Clarify the teaching problem
Let users view a show, temporarily hold a specific seat and confirm a purchase. The key rule is that one seat cannot be sold to two different buyers. Browsing may tolerate a slightly stale seat map, while checkout must use an authoritative decision. For this example, assume a three-minute hold and a payment sandbox. These choices explain the solution; they are not established as Microsoft's exact question.
2 Model the seat and the operation
Use Show, Seat(show_id,seat_id,state,hold_token,hold_until) and Booking(id,user_id,seat_id,status,operation_key). Define a uniqueness rule for one successful sale per show and seat. Scope operation_key to the customer and intended checkout. Add a hold token that changes whenever ownership of a hold changes, so a delayed event cannot act as the newest seat holder.
3 Make the hold atomic
In one database transaction, change an available or expired seat into a held seat and record its token and expiry. A conditional update or appropriate locking strategy ensures only one competing request wins. Check the update result; another request should receive an unavailable outcome. Do not decide based solely on a cached map or an earlier read that said available. Avoid holding the database transaction open while waiting for the payment network.
CONCEPT 2
Ticket booking · Solve the failure follow-ups
4 What if the request or response is lost
Before a request reaches the server, nothing may have happened. After a successful commit with a lost reply, a hold or booking may already exist. The retry must reuse its original operation key and look up the existing result. A fresh key can be a new purchase intent, so do not create one automatically on every timeout. This distinction prevents duplicate bookings caused by uncertain network outcomes.
5 What if payment arrives after the hold expires
A callback must prove the provider event is authentic and refer to the intended booking and hold token. Apply a transition only if the current state still allows it. If that seat has since been allocated to another buyer, do not overwrite the newer ownership. Use a declared recovery policy, such as refund or manual reconciliation. Release expired holds safely, and coordinate cleanup with checkout so both cannot win different interpretations of the same state.
6 What if the service is under heavy demand
Cache suitable show details and browsing data, but send holds and final confirmation to the authoritative transactional path. A waiting room, per-user limits and bounded concurrency can protect it. If the authority is unavailable or partitioned, reject or defer uncertain seat sales rather than letting both sides independently promise the final seat. Observe hold success, expiry, payment reconciliation, contention and duplicate-operation handling.
A concise model answer
I would separate approximate browsing from strongly coordinated purchase state. A database-enforced hold and unique sale rule protect the seat, while an operation key makes retries safe. I would not hold locks across payment calls. Authenticated callbacks and reconciliation would handle uncertain payment outcomes, including late success after a hold has expired.
Payment and booking are separate state machines
STEP 1Provider succeedsPayment result becomes known
STEP 2Booking ruleHold may already have expired
STEP 3ReconcileConfirm or refund under policy
Retries and duplicate callbacks must not create extra seats or duplicate refunds.
Key learning points
Separate approximate browsing from authoritative reservation.
Use a stable operation identity and a changing hold token for different hold ownerships.
Keep locks short and external payment outside a long-held local transaction.
Late callbacks and expired holds need explicit reconciliation.
Compare the important ideas
Worked interview ticket booking: concepts and trade-offs
Seat or booking state
Allowed next behavior
Required check
Available
Create one held reservation
Atomic authoritative decision
Held
Pay, expire or release
Current holder/token and time policy
Payment pending
Confirm or reconcile
Authenticated provider evidence and allowed transition
Confirmed
Fulfil or follow a cancellation policy
No second successful sale for that seat
Expired hold
New reservation may be allowed
Old callback cannot overwrite a newer holder
WORKED EXAMPLE
A safe lost-reply path
An order operation commits a hold, but its reply is lost. The app sends the same user-scoped operation key again. The service returns the existing hold/result rather than creating a new purchase. If payment success arrives after that hold expired and a newer buyer owns the seat, the old hold token must not authorize a sale. Resolve the money under the declared refund or reconciliation policy.
Further reading
Original teaching explanations by Buildfest Learn. Check these primary references for the underlying concepts and implementation details.
Interview cases adapt publicly reported topics with original teaching constraints and solutions. They are not official company questions or answer keys.
CHANGE AN ASSUMPTION. EXPLAIN THE RESULT.
Handle a late payment
A payment success arrives after the original hold expired and another buyer took the seat. Choose a recovery action.
1Old hold expired; payment succeeded
2Overwrite current seat owner
3Can violate seat ownership
Do not confirm an expired hold over a new reservation.
Authenticate and deduplicate the callback, match its operation and hold token, then check current state. Payment success does not automatically revive an expired reservation.
Chapter review: two questions
Attempt both questions before opening the model answers.
Question 1
Two buyers request the last seat at the same time. Describe the atomic database decision, the loser response and the retry after the winner loses its reply.
Reveal model answer
A conditional hold update or correct transaction permits one winner. The other request gets an unavailable result. The winner retries with its original operation key and retrieves the existing outcome. Persist the relevant reservation and operation result consistently and keep a unique sale invariant for the show and seat.
Question 2
Payment success arrives for an expired hold after a new buyer reserved the seat. State what must not happen and propose a recovery policy.
Reveal model answer
Do not overwrite the new holder or create a second confirmed sale. Authenticate and match the event to the old operation and hold token, check the current state, then use the declared refund/manual reconciliation path if the sale is no longer valid. Recovery must protect both seat ownership and the money outcome.
Answers stay in this tab. Download before leaving. This practice is not graded or saved to your account.