← Math
Math

Queue growth and Little’s Law intuition

How long does a thumbnail job wait?

Relate work in progress, arrival rate and time only after checking the measured boundary and workload.

Outcome

Compute W = L ÷ λ with units that cancel, check flow conservation and balance before trusting it, and average queue length over time.

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.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
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
Which line is the average time in the system in seconds?

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

Windows of 900 s
ArrivalsDeparturesGapVerdict
3,6003,5920.2%steady
3,6003,20011%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

The queue held 4 jobs for 500 s, then 40 jobs for the last 100 s of a 600 s window. What is L?

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.

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.

Estimate.tsx
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
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
Between two stable regimes at the same boundary, arrival rate halves while average jobs inside stays the same. What happens to average time in the system?
In a stable regime, a service averages 400 requests per second and a mean time in system of 50 ms. How many requests are in flight on average?
Sources

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.

Report a problem in this lesson

For typos, mistakes and things that don’t work. We read every report and fix what’s wrong, but we don’t reply here, so a question won’t get an answer.