At Quillfern Parcels. This is the system from chapter 1 of the Quillfern story, "One server under the desk": The booking site and its database run on one Linux server in the office. A month-end invoice job makes the whole server freeze, and every reboot for updates stops bookings.
What the model simplifies
One core, no context-switch cost, no input or output: each program only needs CPU time, counted in ticks of 10 ms. First come, first served and shortest job first let a program run to the end; round robin gives each a time slice in turn. Real kernels (Linux CFS and EEVDF) behave more like a weighted round robin with priorities. Every number on this page comes from one shared set of calculations, which the simulation questions use too, so a question can never disagree with what the simulator shows.
The drills, written out
A long batch job freezes the server (the convoy effect)
- Healthy state. With round robin and a 2-tick slice the four programs take turns. The ssh session waits 5 ticks and the average wait is 4.75 ticks.
- Trigger. At month end the invoice batch needs 24 ticks of CPU, and the server was set to first come, first served, so once the batch starts it runs to the end.
- What is affected. Everything that arrives after the batch: label printing, scan ingestion, and the engineer's ssh session.
- Symptoms. The ssh session shows nothing for 260 ms after each command, label printing stalls, and the depot reports a slow server, while the CPU is busy all the time.
- Metrics. Average wait rises from 4.75 to 18.50 ticks. The load average stays near 1: one program running, the rest queued behind it.
invoice-batch: waits 0 ticks, finishes at 24
label-print: waits 23 ticks, finishes at 27
scan-ingest: waits 25 ticks, finishes at 29
ssh session: waits 26 ticks, finishes at 30
- Logs. top shows one process using the whole CPU and the others ready but not running.
top - load average: 1.00, 0.97, 0.62
%Cpu(s): 99.6 us, 0.4 sy, 0.0 id
PID S %CPU COMMAND
4120 R 99.6 invoice-batch
4188 R 0.0 label-print
4191 R 0.0 scan-ingest
- Reasoning. The CPU is not too slow; it is held. First come, first served never takes the CPU back, so one long job makes every short job wait behind it. That is the convoy effect.
- Mitigation. Give the CPU back in slices: with round robin the ssh session waits 5 ticks even while the 24-tick batch runs.
- Recovery. The batch now finishes at tick 30 instead of 24: time slicing costs the long job a little and saves everyone else a lot.
- Prevention. Run batch work at a lower priority with nice, or in its own cgroup with a CPU limit, and watch run-queue length and scheduling delay, not only CPU percentage.
Learn it properly
All simulators · Curriculum map