Flash-sale inventory and admission 00:00:01 One thousand items, a longer line One thousand items are available when the flash sale opens. The waiting line grows longer than the stock count before most customers reach checkout. What does an admission token actually promise? Each person gets a token that lets them try to buy, but it doesn't mean they’ll actually get anything—just a chance to attempt checkout. Even with a token, there's no guarantee of an item or a successful charge—stock might be gone by the time they reach it. The gate meters work; the stock ledger decides ownership. Even a perfectly fair queue can contain more people than there are items. Give customers an admission message that makes this distinction clear. 00:00:42 Issue a bounded number of attempts We limit arrivals to 200 per second using a tested backend rate to keep the system from collapsing under load. An admission token can have a short validity window, such as ten seconds in this example. A stable purchase request identifier is separate and must survive retries for the interval the product promises. We record actual wait time separately—measured at 3.2 seconds—so we can track performance without affecting stock. In this example two hundred admissions per second is an operating setting chosen after a load test. Monitor checkout completion and contention and reduce admissions if the sustainable backend capacity falls during the sale. 00:01:25 Claim with one authoritative transition Before any hold is created, we check remaining stock and create a timed hold in one atomic step to avoid race conditions. If precisely one unit is held, available stock falls from one thousand to nine hundred ninety-nine as part of that same atomic change. A second request with the same ID finds the original hold already in place and returns the same reservation state. Record the hold and change the available count in one protected transaction. If the process could stop between those changes, the same inventory could appear permanently missing or could be sold more than once. 00:02:05 Payment responds after a timeout The merchant records the pending payment intent before asking the provider. The reservation has its own expiry; the earlier waiting-room token does not decide whether the existing hold may be confirmed. Suppose the provider’s response arrives after the reservation deadline. Consult the authoritative expiration rule and expected hold identifier instead of trusting a stale success message. An expired hold cannot be confirmed merely because a provider later authorized the card. Reconcile the external result under its stable identity and release or void funds as the actual provider state requires. Authorization and capture are also different. The merchant may need to void an authorization or refund a captured payment after resolving uncertainty. Dropping an internal response cannot undo an effect at a payment provider. 00:02:58 Report sold out truthfully In another snapshot of the sale, two purchases have completed. The page cache may still show the opening thousand, although the stock ledger now has nine hundred ninety-eight units available if no other holds exist. The ledger distinguishes available, actively held and sold quantities. A hold temporarily reduces what other buyers can claim whether or not the eventual payment succeeds. If every unit is ultimately sold, close the line and explain the outcome. Earlier in our two-sale snapshot plenty remained; do not confuse that intermediate moment with the final sold-out condition. Use the durable counts to decide when to close admissions. A queue length estimates demand, a hold protects a temporary claim and a sale records ownership; adding all three would count the same person several times.