Flash Sale System 00:00:01 Winning entry does not win the final pair of shoes Ten million shoppers want a limited shoe release. This illustrative waiting room protects the stock service by admitting a controlled share. Passing through its door grants permission to try. It does not grant ownership. The room is open. Joins spread over 30 minutes. Signed, and kept by the phone. From the CDN. My number is above the cutoff, so I wait. 100 people a second are 0.00001 of 10 million. The shopper's assigned position falls below the current cutoff. Their time-limited chance to claim stock begins. At one hundred admissions per second, only a tiny fraction of ten million enters each second. Keep the public progress view cheap to load and verify each admission at the service that enforces it. 00:00:49 Price a numbered line Try a different policy with sequential positions. One shopper receives place four thousand five hundred twenty-two. The estimated wait depends on both the current serving position and how fast that position changes. One increment gives each person another number. From 0 at 1,000 a minute that is about 4.5 minutes. Serving 4,500. 22 places ahead are about 1.3 seconds of serving. Once the served cutoff passes the shopper's position, the service can consider their claim. At one thousand admissions per minute the initial wait is roughly four and a half minutes. Once serving reaches four thousand five hundred, only twenty-two positions remain, roughly one point three seconds at the same pace. 00:01:34 Two shoppers see one available unit Buyer A and buyer B receive the same optimistic stock hint. Both are allowed into the sale. Have them attempt the authoritative conditional change before either screen celebrates success. Buyer A asks, with ticket and key. The same checks, the same answers. Buyer A's conditional update changes one stock row. Buyer B now fails the same availability condition and changes zero rows. Same key, same hold. Nothing is taken again. Only one update can claim the final unit. A retry of the winner's original request must return its existing hold. A read from a fast but delayed cache cannot resolve this conflict. 00:02:17 One second before the hold expires The shopper presses Pay one second before expiry. A sweeper and a payment handler now compete over the same hold. Make each transition check the hold's current state rather than inferring success from the clock on the phone. The buyer presses pay at 10:05:06. The hold ends at 10:05:07. Still in time: one row changed. It looks for held only and finds nothing here. Ten seconds without an answer. Unknown is not refused. After confirming the provider outcome, commit the order, sold state and publication record together. In the illustrated policy an accepted payment attempt moves the hold into a separate state before the provider call. A provider timeout means unknown. Reconcile under the existing identity before releasing or selling the same unit. 00:03:08 Test the invariant, then reopen the doors Run two different shoppers against a single remaining unit. First separate the read from an unconditional write. Then repeat with the condition checked as part of the atomic stock update. Which test can oversell? Both read 1. Two orders for one unit. Both ask the database to take one if there is one. B's change finds nothing to change. The deliberately broken version produces two orders. The guarded version permits one owner. Monitor queue admission, conditional claim failures and payment reconciliation separately. Each protects a different part of the sale.