Skip to the guide

Holds that expire, queues and virtual waiting rooms

IntermediatePattern5 pages

On the morning a new phone goes on sale, the shop can't let the whole street in at once. Staff at the door hand out numbered tickets, drawing everyone who queued before opening in random order, and a screen above the door shows the number now being let in. Inside, an assistant puts a phone aside in your name for ten minutes while you go to the till. Unpaid by then, it goes back on the shelf, and the shop's clock decides, not your word.

The street is the crowd of fans and the tickets are places in a virtual waiting room. Letting people in as counters free up is admitting fans at the rate the seat database takes, and the screen is the one "now admitting" number every waiting page checks. The phone set aside is a hold with an expiry, the till is the payment provider, and the shop's clock is the database's clock, now() in the update on the seat's row. Interviewers ask this right after contention: what happens when a hold runs out mid-payment, and how ten million fans reach a database built for thousands of writes a second. The move: hold for a fixed time with the expiry in the row the next claim checks, and put a waiting room in front that admits fans at the rate holds can be taken.