In a concert-ticketing checkout, why hold a seat before payment rather than check availability after it, and what happens when the hold expires?
answer
- payment takes minutes, not milliseconds
- available, held, sold
- one conditional move per state change
- expiry hands the seat back
- an expired hold reads as free
basics
~20 sPayment takes minutes, so checking only afterwards lets two buyers pay for one seat. A hold reserves the seat for one buyer for a limited time; if payment has not confirmed when it lapses, the seat returns to sale.
solid answer
~50 sA seat moves through three states: `available`, `held` (by one buyer, until an expiry time) and `sold`. Picking a seat creates the hold with one conditional write that succeeds only if the seat is available or its previous hold has lapsed, so two buyers can never hold it at once. Payment then runs against a seat that is guaranteed to that buyer, and success turns the hold into `sold` only if it is still that buyer's hold. If the buyer abandons or payment is too slow, the hold expires and the seat is sellable again. Checking only after payment would charge buyers for seats that may already be gone and refund the losers, which at a busy on-sale is a large share of buyers. The time limit is sized against how long checkout really takes, and every read treats an expired hold as available even before any cleanup has run.
go deeper
Recall the three states, available, held and sold, and say plainly that payment is slow, so the seat must be reserved for one buyer while it runs and released if they do not finish.
Explain that each state change is one conditional write, that expiry is checked on every read rather than waiting for cleanup, and how the time limit is sized from real checkout durations.
Show the operational view: abandoned holds making an on-sale look sold out, sweeps falling behind under load, bounded extensions, and measuring how often real buyers run out of time.
Frame the time limit as a business setting that trades buyer frustration against inventory locked by abandoners, owned by product and engineering together and revisited from data.
## Why payment forces a hold Selling a concert seat looks like one step but is two: the buyer **chooses** a seat, then **pays** for it. Choosing takes milliseconds; paying takes minutes. The buyer types card details, the bank may add an extra authentication step, and the payment provider answers in seconds at best. During those minutes the seat is still visible to everyone else. Without a hold there are two bad options: - **Check availability only after payment succeeds.** Two buyers pick the same seat, both pay, and one of them must be told the seat is gone and refunded. At a busy on-sale, with many buyers clicking the same good seats, that is not an edge case; it is the common case. - **Mark the seat sold the moment it is picked.** Every buyer who picks a seat and then walks away leaves it marked sold with no payment behind it. A **hold** is the middle state: the seat belongs to one buyer, provisionally, for a bounded time. Other buyers see it as taken, the holder can pay without racing anyone, and if the holder disappears the seat comes back on its own. ## The three states | State | Who can take it | Leaves this state when | |---|---|---| | `available` | any buyer, by placing a hold | a hold is placed | | `held` (holder, `expiresAt`) | only the holder, by paying | payment confirms, the buyer cancels, or `expiresAt` passes | | `sold` | nobody | a refund or exchange policy returns it | Every move between states is one **conditional write** on the seat's record: "set to held by buyer B until time T, only if the seat is available or its hold has expired", and "set to sold, only if it is still held by B". The condition is what stops two buyers from holding the same seat; how a given store makes that write atomic is a concurrency topic of its own, and this design only needs it to be atomic. ## What expiry does When `expiresAt` passes without a confirmation: 1. The seat is **available again** to every other buyer, immediately in meaning even if no record has been touched yet. 2. The original buyer's checkout is told the hold has lapsed, usually by the countdown the page has been showing. 3. If that buyer's payment still succeeds later, the system must not blindly confirm it; a late payment is re-checked against whoever holds the seat now, and refunded if the seat has gone. ## Sizing the time limit The time limit is a business setting, and it is a trade: - **Too short** and real buyers, mid-payment, lose their seats; late payments and refunds rise. - **Too long** and abandoned holds lock inventory. During an on-sale, seats look sold out, then trickle back minutes later, which reads to buyers as unfair. - **Size it from measurement:** the time real buyers take from seat pick to payment submission, plus the slow tail of the payment step. Many ticketing services choose somewhere between a few minutes and a quarter of an hour; that is a choice, not a standard. - **Allow at most a bounded extension**, for example once the buyer has actually started paying, never an open-ended one. ## Releasing expired holds: on read or by sweep Two policies decide when an expired hold stops blocking the seat, and most systems use both: - **Lazy release on read.** Every availability check and every new hold attempt compares `expiresAt` with the current time and treats an expired hold as free. This is what makes expiry *correct*: nothing waits for a cleanup job. - **A background sweep.** A periodic job clears expired holds so that seat maps, available counts and reports are tidy. If the sweep is late, the counts shown to buyers lag, but no seat is wrongly blocked, because the reads already ignore lapsed holds. Relying on the sweep alone is the classic mistake: a sweep that falls behind under on-sale load leaves sellable seats locked. How timers and due-time polling are built at scale belongs with job scheduling; here the point is that the deadline check lives in the state change itself. ## Common mistakes - Treating the hold as a promise that the sale will complete; it only promises the seat is reserved while the hold lasts. - Confirming a sale without checking that the hold is still the payer's. - Letting the buyer's open browser tab decide when a hold ends; tabs close without telling anyone. - Choosing the time limit once and never measuring how often real buyers run out of it.
- Why not rely on the store deleting the hold record automatically when its expiry passes?Automatic expiry is fine as cleanup, but correctness should not depend on when a deletion happens. Stores that expire records may remove them some time after the deadline, and a separate cleanup can fall behind. Put the deadline in the state change itself: a new hold succeeds if the seat is available or its hold's expiry time has passed, and confirmation succeeds only if the hold is still the payer's, with a payment that arrives after expiry re-checked against whoever holds the seat now.
- Should a buyer be allowed to extend a seat hold?A single bounded extension is reasonable, for instance when the buyer reaches the payment form or the bank asks for extra authentication. Unlimited extensions recreate the problem the time limit solves: a seat locked by someone who will never pay. Cap the total hold time with a hard deadline and measure how often buyers need the extension; frequent use means the base limit is too short.
- Why can the available-seat count shown to buyers lag behind the real availability?If the count is maintained by the background sweep, seats whose holds lapsed since the last sweep are still counted as held. That lag is cosmetic as long as hold attempts compare expiry times directly: a buyer who picks such a seat gets it. The trade is how often the sweep runs against how stale the displayed count may be.
A shop assistant puts a jacket behind the counter with your name on it for fifteen minutes while you fetch your wallet. If you are back in time, you buy it. If you are late, the jacket goes back on the rack; whether you still get it depends on whether someone else has bought it in the meantime.
- Checking availability only after payment is fine because collisions are rare.
- A hold should last until the buyer closes the checkout page.
- Seats become sellable again only once a cleanup job deletes the expired holds.
- Confirming a paid seat needs no check of who currently holds it.
- A longer hold is always kinder to buyers and costs nothing.