Terminology (6)Terms used in this lesson
Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.
- Little’s law
- Over a window where the system is steady, L = λ × W: average items inside = arrival rate × average time inside.
- Work in progress Also L
- The average number of items inside the boundary over the window, queued and in service.
- Arrival rate Also λ
- Items entering the boundary per unit time.
- Time in system Also W
- Average time an item spends inside the boundary, from arrival to departure.
- Flow conservation
- Items at the start plus arrivals minus departures must equal items at the end.
- Transient window
- A window in which the queue grows or drains noticeably, so a steady-state interpretation needs further justification.
Why this matters
Queues sit in front of workers, databases, thread pools and support teams. Little’s law links three numbers you can measure, so one can be found from the other two: the wait from queue length and arrival rate, or the needed concurrency from rate and latency. Its steady-state form relates long-run averages without requiring a particular service-time distribution. A short window approximates those averages only when boundary effects and changes in workload are small.
This lesson assumes rates and unit conversion.
What Little’s law relates
Little’s law relates the average number of jobs inside a system, their arrival rate and their average time inside it. In a stable long-run regime, average jobs equal arrivals per unit time multiplied by average time per job: L = λW.
Applying that relation to a dashboard requires measurements of the same system. A changing queue or a short observation window can make its quotient a poor estimate of long-run time; conservation and balance checks help identify problems without proving stability.
01Name the boundary
Name the boundary
A dashboard divides average queue length by arrival rate and shows a 30-second wait for thumbnail jobs. That window, the queue grew by 400 jobs. Before presenting that estimate as a steady-state time, check the system boundary, flow counters and whether the workload was stable. A small net change alone cannot establish stability.
L, λ and W must describe the same boundary and window. If L counts jobs waiting and being processed, W is the time from arrival to completion. If L counts only waiting jobs, W is only the wait before a worker picks a job up. Mixing them gives a number that is neither.
02Units that cancel
Units that cancel
Predict the three lines this program prints.
const jobs = 12; // average jobs in the system over the window
const arrivalsPerMinute = 180;
console.log((jobs / arrivalsPerMinute).toFixed(3)); // units: minutes
console.log((jobs / (arrivalsPerMinute / 60)).toFixed(3)); // units: seconds
console.log(((4 * 500 + 40 * 100) / 600).toFixed(3)); // 4 jobs for 500 s, then 40 for 100 s
Counters arrive as numbers, so arrivals / seconds is a fraction already. Compare counts with === only while they are whole numbers.
03Check the books
Check the books
Over a 600-second window the queue started with 10 jobs, 1,800 arrived, 1,790 left and 20 remained: 10 + 1,800 − 1,790 = 20, so the counters agree. Had the end count read 25, five jobs would be unaccounted for, a lost metric or a bug, and any wait time computed from these counters would rest on numbers that contradict each other.
04Steady or growing
Steady or growing
| Arrivals | Departures | Gap | Verdict |
|---|---|---|---|
| 3,600 | 3,592 | 0.2% | steady |
| 3,600 | 3,200 | 11% | transient: the queue grew by 400 |
The second window accumulated 400 jobs, or 400/900 ≈ 0.44 jobs/s. That warns against treating L/λ as a stable time estimate. It does not imply every successive job waits longer: worker speed, scheduling and arrivals can vary. A draining queue is transient too. The lab flags a net gap greater than 5% of arrivals, including growth and drainage; a window inside that tolerance can still contain large bursts. Inspect the time series and workload before interpreting the estimate.
05Average over time
Average over time
06Read the job queue
Read the job queue
The thumbnail panel first needs seconds rather than minutes. Its next request applies conservation and a declared balance filter before showing an estimate. When observations arrive at unequal intervals, the panel also needs job-seconds: a count seen briefly must not outweigh a count held through most of the window.
A thumbnail job queue
Wait from Little’s law, can the window be trusted, then raw samples.
In the frontend An honest queue panel in Next.js and Svelte Optional
A status panel shows the average wait only for a steady window and otherwise says the queue is growing or draining, the counters disagree or nothing arrived. The label says time in the system because the counts include jobs being processed. Passing the balance filter still relies on a separately justified stable workload.
type Window =
| { verdict: "steady"; waitSeconds: number }
| { verdict: "transient" | "inconsistent" | "unavailable" };
// Show the wait only when the window supports it, and say why when it does not.
export function QueueWait({ window }: { window: Window }) {
const messages = {
transient: "Queue is growing or draining; steady-state estimate withheld",
inconsistent: "Counters disagree; check the metrics pipeline",
unavailable: "No jobs arrived in this window"
} as const;
if (window.verdict !== "steady")
return <p role="status">{messages[window.verdict]}</p>;
return <p>Estimated time in system: {window.waitSeconds.toFixed(1)} s</p>;
}
Check this idea later
Sources
- Little (1961), A proof for the queuing formula L = λW
- Google SRE book: handling overload
- Rust: u64::checked_sub
Values above were computed in Node 22 and run in Go 1.27, Rust 1.99 and Apple clang 17. The thumbnail queue is a worked model.
Sign in to keep your read marks on every device. Sign in
Was this helpful?