A11 · Lesson 51 · Queues
Why a router at 90% load is so much slower than at 80%
Packets arrive at a router at random and wait their turn to be sent. Interrupts queue for a processor, print jobs for a printer, calls for an operator. When arrivals are random, a server that is busy less than 100% of the time still builds up queues, and those queues grow explosively as the load approaches 100%. The simplest model, the M/M/1 queue, with Poisson arrivals and random service times, captures this exactly, and Little's law, which holds for almost any queue, ties together how many are waiting and how long they wait.
- The curve is the mean number in an M/M/1 system, , against the utilization , the fraction of time the server is busy.
- At 50% load there's about one in the system on average. At 90%, nine; at 99%, ninety-nine.
- The readouts give the mean time in the system, for a server that handles 1000 per second, and the chance the buffer holds more than 20.
Predict
A link serves 1000 packets per second. Traffic rises from 800 to 900 per second. What happens to the average delay?
It doubles. The mean time in an M/M/1 system is : s = 5 ms at 800 per second and s = 10 ms at 900. The spare capacity is what matters, and it halved. That's why networks are engineered to run well below full load.
Name it
The M/M/1 queue
Arrivals are Poisson at rate , service times are exponential with rate , and there's one server. With utilization :
- the number in the system is geometric: , so ;
- the mean number in the system is ;
- the mean time in the system is ;
- the mean wait before service starts is .
At the queue grows without bound.
Little's law
For any stable system, the average number inside equals the arrival rate times the average time spent inside:
It needs no assumptions about the distributions. A router holding 4 packets on average while 800 per second pass through keeps each one for 5 ms.
Buffers
A finite buffer drops arrivals when full. For a buffer of packets in an M/M/1 system, the overflow probability is about when it's small: each extra packet of buffer cuts losses by a factor , which buys a lot at 50% load and very little near 100%.
Worked example
Packets arrive at 800 per second at a link that serves 1000 per second. Find the utilization, the mean number in the system and the mean delay.
Show the solution
- Utilization.
- Mean number in the system.
- Mean delay.
- Check with Little's law.
Answer the utilization is 0.8, the mean number in the system 4 packets, and the mean delay 5 ms.
Worked example
At the same link, traffic rises to 900 per second. What happens?
Show the solution
- New figures. and , and
- Compare. A 12.5% increase in traffic more than doubled the number waiting and doubled the delay.
- What it means. The last 10% of capacity is the most expensive to use.
Answer the utilization rises to 0.9, the mean number in the system to 9 and the mean delay to 10 ms.
Worked example
At 80% load, how often does the system hold more than 20 packets?
Show the solution
- More than 20. about 1% of the time.
- A 20-packet buffer. A buffer of 20 packets would drop about 1% of arrivals.
- At 50% load. The same buffer would overflow with probability .
Answer it holds more than 20 packets 0.92% of the time, about 1%.
Check
Packets arrive at 800 per second at a server that handles 1000 per second. What is the mean time in the system?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
An M/M/1 server is busy a fraction 0.8 of the time. How many are in the system on average?
Check
A system holds 3 jobs on average while 100 per second pass through. How long does each spend inside, on average?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
At utilization 0.7, what is the chance an M/M/1 system holds more than 10?
Check
Arrivals at 600 per second, service at 1000 per second.
(a)
What is the utilization?
(b)
What is the mean wait before service starts?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
Derive the M/M/1 mean from .
Step 1
What is ?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is the chance of more than two in the system?
Check
Simulate an M/M/1 queue with arrivals at 800 per second and service at 1000 per second for 200 000 packets (np.random.default_rng(3)): each packet starts service at the later of its arrival and the previous packet's departure. Set W to the mean time in the system, in ms.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why does delay grow so steeply as a queue's utilization approaches 100%, even when arrivals are below the service rate on average?
With random arrivals, there are stretches when jobs arrive faster than the server can handle them and stretches when it sits idle. Idle time is lost forever, since the server can't work ahead, but a burst leaves a backlog that has to be worked off. The closer the load is to capacity, the less spare time there is to work off backlogs, so they persist and pile up. In the M/M/1 model the mean delay is , inversely proportional to the spare capacity: halving the spare capacity doubles the delay. Perfectly regular arrivals wouldn't queue at all; randomness is what makes waiting.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.