The order slip rail a show in 8 chapters
Goal: let the counter take every order without waiting, and keep the wait short
1 of 8 Your guess
Before we start
The chai stall is famous now. One person takes orders at the counter, another works the stove, and the stove is far slower than the counter.
Which picture is closest to how a busy website handles work it cannot finish right away?
Pick the closest. You find out which fits at the end.
16 calls ÷ 12 minutes = 1.33 a minute. Part of a wire cannot be bought, so 2.spaced out, no minute has more than 2 calls: 0 busy tones
2 of 8 The problem
1909: how many wires to buy
In 1908 a Danish engineer, Agner Krarup Erlang, joined the Copenhagen Telephone Company and was handed a question no opinion could settle. Every call needed a wire of its own across town. How many wires should the company buy?
The obvious answer is to count the calls and buy enough for the average. Here is a made-up afternoon: 16 calls in 12 minutes, each a minute long, spaced out evenly.
Erlang's 1909 paper found the catch. Calls do not arrive politely spaced out. They bunch: the wires sit idle for a minute, then six people call at once.
The same 16 calls, the same 2 wires, bunched the way calls really come.
Press Play to watch the afternoon, a minute at a time.
What changed
- Callers who hear a busy tone: 0 → 7
The average was right and the wires were still too few. Hold that thought: the stall is about to meet the same bunching.
6 minutes = 360 son its own: 360 s ÷ 4 s = 90 orderschained to the stove: 360 s ÷ 90 s = 4 orders
3 of 8 The problem
Back at the stall: the counter freezes
A customer asks for three cups. The order-taker calls it through, then stands there: the cook is 2 orders behind and there is nowhere to put the new one.
Behind that customer 11 people wait, none of them served. Nobody is cooking slower. The counter has simply stopped.
Your goal: let the counter take every order without waiting on the stove, and keep the wait short.
The order-taker handles a customer every 4 seconds. The stove takes 90. Call those 90 seconds one cooking time: every wait in this show is counted in them.
Chained together, the fast thing runs at the speed of the slow thing.
What changed
- Orders the counter takes in 6 minutes: 90 → 4
4 of 8 The fix
The wire over the stove
Every busy stall in India owns the fix, for forty rupees: a wire strung above the stove. The order-taker writes each order on a paper slip, clips it to the wire, hands over a numbered token and says next.
The cook pulls slips off at whatever pace the stove allows. Here comes the rush of 12.
Press Play: 12 customers, one wire.
What changed
- Time the counter needs for a rush of 12: 18 minutes → 48 s
The rush did not shrink. It got stored.
That wire is a queue: work written down and held in the middle, so the end that makes work and the end that does it need not run at the same speed.
The token is the other half. The tea is not ready when the customer walks away. It is promised. Work accepted now and finished later, with a receipt in the meantime, is asynchronous work.
Every "your order has been placed" email is a token with a slip on a wire behind it.
50 in − 40 out = 10 more slips every hourafter 8 hours: 8 × 10 = 80 slips
busy ÷ idle = 0.5 ÷ (1 − 0.5) = 0.5 ÷ 0.5 = 1 cooking time
| busy | wait | costs |
|---|---|---|
| 50% → 51% | 1.00 → 1.04 | +0.04 |
| 80% → 81% | 4.00 → 4.26 | +0.26 |
| 90% → 91% | 9.00 → 10.11 | +1.11 |
| 95% → 96% | 19.00 → 24.00 | +5.00 |
| 98% → 99% | 49.00 → 99.00 | +50.00 |
at 98%: 0.98 ÷ 0.02 = 49, at 99%: 0.99 ÷ 0.01 = 99, so 99 − 49 = 50
5 of 8 The cost
Erlang's bad news: busy is not spare
It feels like the wire bought capacity. It did not. The wire holds slips, it does not cook.
Orders arrive for 50 cups an hour and the stove makes 40. The wire grows all day, and every token is a longer lie.
A queue smooths bursts. It cannot fix a stove slower than the day.
So the stove has to keep up on average. How busy can it run? The fraction of the time it is busy is its utilisation.
Erlang's bad news is what waiting does as that fraction climbs. For one stove taking orders at random, the extra wait in cooking times is busy ÷ idle. At 50% busy that is 0.5 ÷ 0.5 = 1.
At 95% busy, how many cooking times of extra wait?
What changed
- Extra wait, in cooking times: 1 at 50% busy → 19 at 95%
The lesson's simulation, 200,000 orders through one stove, measured 19.7 at 95%. Move the dial and watch the curve take off.
Read the shape, not the digits. One more point of busy costs almost nothing at 50% and a fortune at 98%.
The reason is Erlang's bunching. At half busy there are gaps between customers, and a gap is where a bunch drains away. At 99% there is no gap left, so every bunch lands on the last one's leftovers.
Idle time is not waste. It is the shock absorber.
6 of 8 The fix
The dropped slip
Now break something. The cook pulls slip 41, turns to the stove and drops it in the fire.
If taking a slip removed it from the wire, that order no longer exists anywhere. A customer is outside holding a token for tea nobody is making.
That failure is the worst kind: silent.
So a real rail does not remove a slip when a cook takes it. It turns the slip face down for a few minutes. If the cook says done, the slip is thrown away. If the minutes pass with no word, it turns face up again and any cook can take it.
Press Play: slip 41 again, on the new rule.
What changed
- Orders lost to a burned slip: 1 → 0
The price: a cook who finishes the tea, then drops dead before saying done, leaves slip 41 to be cooked twice. That bargain is called at-least-once, so the work must be safe to do twice. Two cups costs a cup. Charging a card twice costs a customer.
7 of 8 Your guess
Your picture now
The wire took the rush of 12 in 48 s (chapter 4). At 80% busy the stove adds 4 cooking times of wait, at 95% it adds 19 (chapter 5). A burned slip comes back (chapter 6). Which picture is closest now?
Pick one.
The rail is c, a queue: work written down in the middle, a token for each customer, and a stove kept below flat out. A faster stove only moves the cliff, and more order-takers only feed the one stove faster.
8 of 8 Keep this
Keep this
Write the work down in the middle and hand a token for it, so the fast end never waits on the slow end. Then keep the stove below flat out: the extra wait is busy ÷ idle, so the last few points of busy cost the most.
The price: at-least-once. A slip can come back and be cooked twice, so cooking it twice must be safe.
Read the full lessonComing up The rail let the counter stop waiting on the stove. Next: the register is still one book under one counter, and in May 2000 one feature let a server call every change down the row to clerks keeping copies of their own.