skip to content

In an arena on-sale where two million buyers arrive for 20,000 seats, how should a waiting room admit buyers and block requests that skip the line?

level: seniorimportance: nice to knowfreq 33%

answer

  1. a place in line, not a free-for-all
  2. admit what checkout can hold
  3. signed, short-lived, bound to a session
  4. a gateway that checks without a lookup
  5. mark the token spent after purchase

basics

~20 s

Give each arrival a place in line, admit batches at the rate checkout can serve, and hand each admitted buyer a short-lived signed admission token tied to their session, which a gateway in front of checkout checks on every request.

solid answer

~50 s

Arrivals before opening commonly get a randomised position, so refreshing at 09:59 gains nothing, and later arrivals join the back. The room admits in batches sized to what checkout can hold: 2,000 concurrent checkouts lasting four minutes each allow about 500 admissions a minute (illustrative figures, by Little's law), and admission stops once stock and live holds are exhausted. Each admitted buyer receives an admission token signed by the waiting room, carrying the event, the buyer's session, a short expiry and a unique id. A gateway in front of every purchase endpoint verifies signature, expiry and session binding without a database lookup and turns away anything else. Replay is closed by the session binding, which the gateway checks locally, and by the purchase step marking each token id spent, so a copy fails in another browser and a used token cannot buy twice; an unused token expires and its slot passes on.

go deeper

for a junior

Recall that a waiting room gives buyers a place in line and lets in only as many as checkout can serve, handing each a pass that checkout insists on.

for a middle

Explain batch sizing from checkout capacity with Little's law, the fields of the signed admission token, and why the gateway checks it on every purchase endpoint.

for a senior

Show the hardening: session binding against copies and spent-token records against reuse, short expiry with clock leeway, stopping admission at sell-out, key rotation, and an edge-served waiting page.

for a principal

Decide whether an event warrants a waiting room at all and which fairness rule it publishes, weighing buyer experience and engineering cost against an unmanaged spike.

## Why a waiting room at all The scenario: **two million buyers** arrive at 10:00 for **20,000 seats**. The checkout path (seat map, holds, payment) can serve, say, a few thousand buyers at once. Letting everyone in means the checkout tier spends its capacity failing requests, the buyers who do get through see errors mid-payment, and the outcome is decided by who retries fastest. A **waiting room** replaces that with an explicit line: buyers wait on a cheap page served from the edge, and checkout sees only the number of buyers it can actually serve. A waiting room is admission control by **position**. It is not a per-client request-rate limiter; how those algorithms work is a separate topic. ## Positions in line - **Before opening**, many platforms collect arrivals in a pre-queue and assign positions **at random** when the sale opens, so arriving at 09:30 and hammering refresh at 09:59:59 are equal. That is a fairness choice; first-come order is the alternative. - **After opening**, new arrivals join the back in arrival order. - The position lives server-side, or in a signed queue ticket the browser holds, so a buyer cannot edit their own place. - The waiting page polls for its status at a modest interval, often with jitter, so two million pages do not all poll in the same second. ## Sizing the batches Admissions are sized from **checkout's capacity**, never from the length of the line: 1. Measure how many buyers checkout can hold at once, say **2,000**, and how long a checkout session lasts on average, say **four minutes** (both illustrative). 2. By **Little's law** (buyers in the system = arrival rate × time each spends), a steady 2,000 at four minutes each allows 2,000 / 4 = **500 admissions a minute**. 3. Release that many per interval, adjusted by feedback: admit faster when sessions end quickly, slower when checkout error rates or latency rise. 4. **Stop admitting** once remaining stock plus live holds is exhausted, and tell the rest of the line the event is sold out rather than letting them wait for nothing. Holds that expire can reopen admission for a small batch. At 500 a minute, the 10,000 or so successful buyers a 20,000-seat arena needs, assuming two tickets each, take at least twenty minutes to pass through, longer once abandoners are counted. Almost all of the two million will never be admitted, which is exactly why telling them early matters. ## The admission token An admitted buyer receives an **admission token**, signed by the waiting room with a key only it and the gateway trust: | Field | Why it is there | |---|---| | event id | a token for one show cannot open another | | session binding | a copy pasted into another browser does not match | | issued-at and expiry | an admitted buyer must start within minutes | | unique token id | lets the purchase step mark it spent, closing reuse | ## The gateway check, expiry and replay A **gateway** sits in front of every purchase endpoint, not just the first page; otherwise a buyer who knows the checkout address can skip the line. - **Verification is local.** Checking a signature and an expiry needs no shared lookup, so the gateway scales with traffic. A request without a valid token is redirected to the line or refused. - **Expiry** is short, often a few minutes to begin checkout, with a little leeway for clock differences between servers. A token that expires unused gives its slot back to the next batch; batch sizing assumes some admitted buyers never show. - **Replay** has two forms. A token **copied** to other browsers still carries a valid signature, which is why signing alone is not enough: the session binding makes the copy fail. A token **reused** for a second purchase is stopped by the purchase step recording its id as spent, in a small store whose entries live only as long as the token; that lookup happens once per purchase, not on every request. - Signing proves integrity, not secrecy. Anything in the token is readable by the buyer, so it carries no secrets. Per-account purchase limits and bot defence are separate controls; the waiting room only decides who may try. ## Failure modes and what to watch - The waiting page itself must survive the spike, so it is static and edge-cached; a waiting room that falls over is worse than none. - If the signing key leaks, anyone can mint admission; rotate it per event and accept the previous key only briefly. - Watch admissions per minute against checkout concurrency, tokens issued against tokens used, the share expiring unused, and gateway rejections, where a spike usually means a client trying to skip the line.

  • Why not admit buyers in strict arrival order from the first second, including those who came early?
    Arrival order before opening rewards whoever loaded the page first or runs the most tabs, and it makes the seconds before opening a stampede of refreshes. Randomising the pre-queue at opening removes that race and is easy to explain. After opening, arrival order is fine because nobody can arrive earlier than they did. Either choice is a fairness policy the business should state publicly.
  • How does the waiting room know when to stop admitting?
    It reads the same stock state the purchase path uses: remaining stock plus live holds. When that reaches zero, admitting more buyers only gives them an empty seat map, so the room stops and tells the line the event is sold out. If holds expire and return seats, it can admit a small batch again, sized to the seats that came back.

A timed-entry museum ticket: you queue for a slot and get a stamped ticket with your name on it, and the door checks the stamp, the time and your name. A photocopy carries the same stamp, which is why the name check matters.

  • A valid signature proves the request came from the buyer it was issued to.
  • Batch size should equal stock so every admitted buyer gets a seat.
  • Checking the admission token on the first checkout page is enough.
  • A waiting room is just a rate limiter keyed by IP address.
  • Admission tokens should last as long as the whole sale.