Quick revision
The short answer
The waiting room runs at the edge: users who arrive before 10:00 get a random position among early arrivals, later users a position by arrival time, held in a signed, expiring token and served from the CDN or a light queue service, never from checkout. A counter of the highest admitted position advances at a rate set from checkout's capacity and the share of admitted users who buy, adjusted live from checkout health, and admitted users get a short-lived signed access token that checkout requires. Stock is reserved atomically with a time limit, everyone is told when it sells out, and bots are fought with one entry per verified account, edge bot detection and limits per card and address.
What to remember
In this answer, we designed a virtual waiting room for a limited release. Users get signed queue tokens at the edge, with random order among early arrivals and arrival order after the start. A controller advances the highest admitted position at a rate derived from checkout capacity and conversion and adjusted from checkout health, while clients poll a cacheable status endpoint. Admitted users get short-lived, session-bound access tokens that checkout requires, stock is reserved atomically with a time limit, everyone is told when it sells out, and verified accounts, edge bot detection and purchase limits stop people and bots from skipping the line.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The waiting room runs at the edge: users who arrive before 10:00 get a random position among early arrivals, later users a position by arrival time, held in a signed, expiring token and served from the CDN or a light queue service, never from checkout. A counter of the highest admitted position advances at a rate set from checkout's capacity and the share of admitted users who buy, adjusted live from checkout health, and admitted users get a short-lived signed access token that checkout requires. Stock is reserved atomically with a time limit, everyone is told when it sells out, and bots are fought with one entry per verified account, edge bot detection and limits per card and address.
Why this question is asked
Limited releases are the extreme case of a traffic spike: the spike is announced in advance, demand is a hundred times supply, and every second matters to buyers. Without a waiting room, 1.5 million people hit checkout at 10:00, it collapses, and the pairs go to whoever's retries happen to get through, which is usually bots. Interviewers ask this design because it combines capacity control, fairness and security in one flow. In this answer, we will size the problem, design how users enter the queue, how admission is paced, how checkout is protected by tokens, how stock is reserved, and how we stop people and bots from skipping the line.
1A Quick Recap and Some Numbers
A virtual waiting room is a page where users wait their turn before being allowed into a protected flow, here checkout. It turns an uncontrolled crowd into an orderly queue that enters at a rate the backend can handle.
Checkout can safely complete about 300 purchases per second. Suppose about 60 percent of admitted users actually complete a purchase, the rest browse sizes or fail payment. Then we can admit about 300 / 0.6 = 500 users per second. With one pair per buyer, 20,000 pairs are gone after about 33,000 admissions, which takes roughly 67 seconds. So of 1.5 million people, only around 2 percent will get in before the item sells out. That number shapes the design: the waiting room must be extremely cheap per user, because almost everyone will only ever wait and leave.
2Entering the Queue
The waiting room runs at the edge, on the CDN or a light queue service, never on the checkout backend. When a user arrives, they receive a signed token holding their queue position, the event id and an expiry. Because it is signed, for example with an HMAC key the edge and the queue service share, users cannot change their position.
Fairness needs care at the start. If positions were simply by arrival time, people who refreshed at 09:59:59.9 and bots with low latency would win. So users who arrive before 10:00 are all treated as early arrivals and given random positions among themselves; users who arrive after 10:00 are placed after them, in arrival order. This removes the advantage of hammering refresh just before the start.
9 messages in order. Play them, or step through them one at a time.
The backend only sees users who hold a valid access token.
3Controlling Admission
Admission is controlled by one number: the highest admitted position. A user whose position is at or below it may enter. A small controller advances that number at the chosen rate, starting near 500 per second, and stores it where the edge can read it cheaply.
Waiting clients poll a status endpoint, for example every 10 to 30 seconds with some jitter. The response depends only on the current admitted position, so it can be cached at the edge for a second or two; the client compares it with the position in its own token. 1.5 million clients polling every 20 seconds is 75,000 requests per second, which is fine for a CDN but far too much for any origin, which is why this endpoint must be cacheable.
The rate is not fixed. The controller watches checkout's latency and error rate and the actual share of admitted users who buy. If checkout p99 rises or errors appear, it slows admission; if checkout is comfortable and fewer people buy than expected, it speeds up. This feedback keeps checkout at a safe load whatever the real behaviour of the crowd.
4Protecting Checkout With Access Tokens
The queue would be pointless if anyone could call checkout directly. So when a user is admitted, the edge issues a short-lived access token, valid for perhaps 10 minutes and bound to the user's session or account. Checkout rejects every request without a valid token, at the edge or the gateway, before any work is done.
Binding the token to the session prevents one admitted user from sharing it with a bot farm, and the short lifetime means a token cannot be kept for later. Each token can be used for one purchase.
5Reserving Stock and Ending the Queue
Stock must never be oversold. When an admitted user selects a size, checkout reserves one pair atomically with a time limit, for example 10 minutes. A Redis DECR on a per-size counter, or a conditional update such as UPDATE stock SET reserved = reserved + 1 WHERE size = 42 AND reserved < total in PostgreSQL, makes the reservation atomic. If the user pays, the reservation becomes a sale; if the reservation expires, the pair returns to stock and the controller can admit a few more users.
Once all 20,000 pairs are reserved or sold, the waiting room tells everyone still waiting that the item is sold out, perhaps with an option to join a list in case reservations expire. Keeping 1.4 million people in a line that can never reach the front is unkind and wastes polling capacity.
6Stopping People and Bots From Skipping
Bots are the main threat to fairness. The first defence is one queue entry per verified account: users must sign in, with an account older than the release announcement or verified by phone, to get a position. A second token request from the same account returns the same position. The second is bot detection at the edge, looking at device fingerprints, behaviour and challenges, before a position is issued. The third is at checkout: limits per payment card, per shipping address and per account, so even bots that get in can buy only one pair each.
Every check is cheap because it happens at the edge or on a small token, and none of it relies on the backend holding the crowd.
| Attempt | Defence |
|---|---|
| Call checkout directly | Access token required, verified at the gateway |
| Edit the queue position | Position in a signed token |
| Refresh before 10:00 to be first | Random order among early arrivals |
| Many accounts or devices | Verified accounts, one entry each, bot detection |
| Share an access token | Token bound to the session, single use |
| Buy many pairs | Limits per card, address and account |
7Follow-up questions
How do you adjust the admission rate if checkout errors rise during the release?
The controller treats checkout health as feedback. If p99 latency passes a threshold or errors rise above a small percentage, it lowers the admission rate, for example by halving it, and raises it again gradually once checkout recovers, much like congestion control in TCP. Users already admitted keep their access tokens, so slowing admission does not hurt them; it just pauses the line for a moment.
Why not let users into checkout in larger batches every minute?
Batches create small spikes of their own: 30,000 users admitted at once all load the page and select sizes together. A steady trickle keeps checkout load flat, and users experience the line as moving continuously.
What happens if the waiting room service fails?
It should fail closed for checkout: without an access token, nobody enters, so checkout is protected. The waiting page itself is static and served from the CDN, so users keep waiting rather than seeing errors, and once the service recovers admission resumes from the stored admitted position.
8Conclusion
In this answer, we designed a virtual waiting room for a limited release. Users get signed queue tokens at the edge, with random order among early arrivals and arrival order after the start. A controller advances the highest admitted position at a rate derived from checkout capacity and conversion and adjusted from checkout health, while clients poll a cacheable status endpoint. Admitted users get short-lived, session-bound access tokens that checkout requires, stock is reserved atomically with a time limit, everyone is told when it sells out, and verified accounts, edge bot detection and purchase limits stop people and bots from skipping the line.
Open with
I would put the waiting room at the edge, served from the CDN with a light queue service, so 1.5 million people never touch checkout. Each user gets a signed token with their position and an expiry.
Then, if they want more
For fairness, everyone who arrives before 10:00 gets a random position among the early arrivals, and later users go after them by arrival time, so refreshing at the last second gives no advantage.
Admission is one number, the highest admitted position, which a controller advances at a rate based on checkout capacity and conversion: 300 purchases per second at about 60 percent conversion is around 500 admissions per second, adjusted live from checkout latency and errors. Clients poll a cacheable status endpoint with backoff.
When admitted, a user gets a short-lived access token bound to their session, and checkout rejects any request without one, so nobody can skip the queue by calling checkout directly. Stock is reserved atomically per buyer with a time limit, and when 20,000 pairs are reserved we tell everyone still waiting that it is sold out.
Against bots: one entry per verified account, bot detection at the edge, and limits per card, address and account at checkout.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Design a virtual waiting room that protects checkout and is fair to users: how users...": https://scrivio-interview-library.netlify.app/architecture/high-availability/b167142009/