Queueing theory explained
Five checkouts, two customers a minute, two minutes per customer: the checkouts are busy only 80% of the time, yet more than half of the customers have to queue. Queueing theory explains why. It began with a Danish engineer counting telephone calls, and it now sizes call centres, hospital wards, web servers and the tills of every supermarket. Its formulas show how long people wait, how long the lines get, and why a small rise in traffic can turn a short wait into a very long one.
Erlang and the Copenhagen telephone exchange
Agner Krarup Erlang joined the Copenhagen Telephone Company in 1908 with a practical question: how many lines and operators does an exchange need? In 1909 he showed that the number of calls arriving in a given minute follows a Poisson distribution, and in 1917 he published the two formulas that still carry his name. Erlang B gives the share of calls that are lost when every line is busy and callers hang up; Erlang C gives the chance that a caller has to wait when callers hold on instead. The unit of traffic, one line kept busy all the time, is called an erlang in his honour, and the same mathematics now describes customers at a supermarket till.
Random arrivals and random service
When many people each decide independently when to go shopping, the arrivals form a Poisson process: in any minute the number of customers has a Poisson distribution with mean λ (the arrival rate), and the time between two customers is exponential with mean 1/λ. At 120 customers an hour, λ = 2 per minute, so on average one arrives every 30 seconds, but gaps of a few seconds and of two minutes are both common. Checkout times are often modelled as exponential too, with mean S: most customers are quick and a few take a long time. The exponential distribution is memoryless, which is what makes the formulas below exact. With Rush hour on, the rate changes during the day; such a non-homogeneous Poisson process is simulated by thinning: draw arrivals at the peak rate and keep each one with probability λ(t)/λmax.
Kendall notation: M/M/1 and M/M/c
In 1953 David Kendall proposed writing a queue as A/S/c: the arrival process, the service time distribution and the number of servers. M stands for Markovian, that is Poisson arrivals or exponential service times; D for a fixed (deterministic) time; G for any distribution. M/M/1 is one checkout with random arrivals and random checkout times; M/M/c is c checkouts fed by one shared line. Two numbers describe the load. The offered load a = λS is the average number of checkouts the customers keep busy (2 per minute × 2 minutes = 4 erlangs), and the utilisation ρ = a/c is the share of the time each checkout is busy. With 5 checkouts, ρ = 4/5 = 80%. If ρ is 100% or more, the checkouts cannot keep up and the line grows without limit.
The Erlang C formula
For the M/M/c queue the chance that an arriving customer finds every checkout busy and has to wait is C(c, a) = (aᶜ/c! · c/(c − a)) / (Σₖ₌₀ᶜ⁻¹ aᵏ/k! + aᶜ/c! · c/(c − a)). The mean wait in line is then Wq = C(c, a) · S/(c − a), and the waits that are not zero are exponential, so P(W > t) = C(c, a) · e^(−(c − a)t/S). For a = 4 and c = 5: Σ = 1 + 4 + 8 + 10.67 + 10.67 = 34.33, the last term is 1024/120 × 5 = 42.67, so C = 42.67/77 = 0.554. Then 55% of customers wait, the mean wait is 0.554 × 2/1 = 1.1 minutes (about 66 seconds), 20% wait more than 2 minutes and 4.5% more than 5 minutes. One extra checkout (c = 6) cuts the chance of waiting to 28% and the mean wait to 17 seconds.
Little's law
John Little proved in 1961 a law that holds for almost any queue in a steady state: the average number of people in a system equals the arrival rate times the average time each spends there, L = λW. It needs no assumptions about the distributions. Applied to the line alone it says Lq = λ·Wq: with 2 customers a minute and a mean wait of 1.1 minutes, on average 2.2 customers are waiting. Applied to the whole checkout area, including the time at the till, W = 1.1 + 2 = 3.1 minutes and L = 6.2 customers. Little's law lets a manager turn a count of people in line, which is easy to see, into the average wait, which is not.
Why waits explode near 100%
For one checkout (M/M/1) the mean wait is Wq = ρ/(1 − ρ) · S. With a 2-minute checkout time that is 2 minutes at 50% utilisation, 8 minutes at 80%, 18 minutes at 90%, 38 minutes at 95% and 198 minutes at 99%. The factor 1/(1 − ρ) is the reason: the last few percent of capacity are where all the waiting is. A checkout that is busy 99% of the time has almost no slack to catch up after a burst of arrivals or one slow customer, so the backlog lingers. More checkouts help in two ways: at the same utilisation the waits are far shorter (at 40 erlangs with 50 checkouts, also 80% busy, the mean wait is about one second), and a big operation can run at a higher utilisation for the same wait. Variability matters too: by the Pollaczek-Khinchine formula, fixed checkout times halve the wait at a single checkout compared with exponential ones (and roughly so with several), and Steady times of ±20% come close to that.
One line or a line per checkout?
Suppose the same 5 checkouts each got their own line and customers picked one at random. Each line is then an M/M/1 queue with a fifth of the arrivals and 80% utilisation, so the mean wait would be 0.8/0.2 × 2 = 8 minutes, against 1.1 minutes for one shared line. With separate lines a checkout can stand idle while the next line is full, which never happens with a shared line. Real customers do better than random: they join the shortest line, and that recovers most of the difference, but not all, because a short line can still hide a slow customer, and nobody may switch once in line. The shared line is also fairer: customers are served in the order they came. That is why banks, post offices and many supermarkets use a single snake line with a sign showing the next free till.
Explore it
Open the queue simulator with 120 customers per hour, a 2-minute checkout time and 5 checkouts: Busy reads 80% and Checkouts needed reads 5 for a target wait of 2 minutes. Press Play and watch the line grow and shrink at random even though the average load never changes, then choose Waiting times to compare the histogram with the Erlang C curve. Drop to 4 checkouts: Busy hits 100% and the queue over time climbs all day. Switch to A line per checkout to see waits grow at the same load, set Checkout times to Steady to see them shrink, and turn on Rush hour to see how many checkouts the peak needs. The pencil opens the picture in the photo editor with the shop, the customers, the chart and its labels on layers of their own.
Frequently asked questions
What is the Erlang C formula used for?
It gives the chance that a customer, caller or job has to wait in an M/M/c queue, and from it the mean wait C(c, a) · S/(c − a). Call centres use it to decide how many agents to staff each half hour, and it works the same way for checkouts, help desks and servers.
What does Little's law say?
That the average number in a system equals the arrival rate times the average time spent in it: L = λW. With 2 arrivals a minute and a 3-minute average stay, 6 people are inside on average. It holds for almost any queue in a steady state, whatever the distributions.
Why does the queue keep growing at 100% utilisation?
At 100% the checkouts can only just serve the average stream of customers, with no spare capacity. Every random burst of arrivals or slow customer adds to the line and there is no quiet time to work it off, so the line drifts upwards without limit. Even at 90% or 95% the waits are already many times the checkout time.
Is one shared line really faster than separate lines?
For the same number of checkouts and customers, yes: no checkout is idle while someone waits. With 5 checkouts at 80% load the mean wait is about 1.1 minutes with one line and 8 minutes with randomly chosen separate lines. Joining the shortest line closes most of that gap, but the shared line is still shorter on average and serves people in order.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Open the queue simulator