Design a movie ticket booking system 00:00:00 Make a prediction You will design a seat hold tied to one showing, owner and expiry, and explain how a late payment interacts with it. Ana's hold on A7 expires. Lee then holds that same seat. An old expiry job for Ana finally runs. May it mark A7 free? No. Release only if the current hold identifier still equals Ana's expired hold. A delayed job must never free a seat currently assigned to Lee. 00:00:31 An evening at the open-air cinema An outdoor cinema marks held seats with coloured pegs. Blue pegs fall off when their timer expires. Lee adds green pegs; removing the greens because an old blue timer rings would give away Lee's seats. The peg colour stands for a hold identifier, not just a seat number. Every expiry or confirmation must verify which hold still owns that showing's seat. A movie ticket booking system in a low-level design round is the part that sells seats: it shows which seats of a show are free, holds some for a customer for a short time, takes the money, and gives out tickets. The domain is known to everybody, and the difficulty is real: two people, one seat, a clock and a bank, all at the same moment. 00:01:18 Move one seat from hold to sale Two shoppers select seat A7 for the same showing. Only one atomic operation may move that showing's seat from available to held. The successful hold records an owner, identifier and expiry. Its timeout must not release a later shopper's different hold on the same seat. Confirm only the matching live hold after payment. A repeated confirmation for that request should return the existing booking rather than sell another ticket. Give Jo a hold on A seven and let Pat attempt to select it one second later. Pat should not pay for a seat Jo still owns. Now expire Jo’s hold before payment confirmation arrives. The design needs a reconciliation outcome if the payment succeeded but conditional seat confirmation fails. 00:02:04 Two showings can sell the same seat label Seat A7 at the six o'clock showing is different inventory from A7 at nine. Key availability by showing and seat together. A seat map keyed only by the physical chair would falsely mark the evening showing as sold out. Sell A seven for the six o'clock showing. At nine o'clock it is still the same physical chair, but it is a separate sale opportunity. A global sold flag on the chair would wrongly reject the second booking. Include the show identity in the seat state. A payment may complete after the seat has been reallocated. Do not confirm a different customer's hold; reconcile or compensate under the payment policy. A transaction or carefully scoped atomic update for the showing-seat record can protect the local invariant before considering distributed workflows. pretix: carts that end. In the API of this open source ticket shop a cart position has an expires time, after which it no longer blocks quota. A hold with an end, and a comparison. pretix: seats and check-in. A seat knows the order position or cart position that has it, and whether it is blocked by hand. A check-in can be refused as already redeemed, canceled or unpaid. 00:03:22 Try an interview follow-up Why should a Seat not have a status? The chair is in the room for every show. Free or sold is a fact about the chair in one show. So the status belongs to the pair: an entry in the seat map of the show, or a row with show id and seat id. One customer cancels seat A seven for the six o'clock showing. Both showings are sold. Which count changes? Release only the confirmed booking identified by that showing and seat. The nine o'clock sale belongs to a different inventory unit. A retried cancellation should find the earlier operation already complete and cannot release the same chair twice. 00:04:06 What to take with you The state belongs to the seat of a show. One map and one lock for each show; check all seats, then write all. A hold is a pending booking with an end, and expired is a comparison with the clock, so no timer can write it at the wrong moment. Paying has three steps: look and mark PAYING under the lock, charge outside it with the key of the booking, record the answer under it. Declined goes back with the old deadline. Silence stays PAYING until a job has asked the bank.