Little's Law for Workers and Queues: Size by Math, Group by SLA
L = λW fits on one line and sizes almost everything in a job system: worker slots, connection pools, in-flight caps, retry windows. What the law says, why it holds, how to use it with real numbers from Tesar, and why queues should be grouped by time to complete, not by team.
Most capacity questions about a job system come down to three. How many workers do we need? Why did the queue back up when nothing was broken? Should this new kind of work get its own queue? I answer all three with the same tool, a result from 1961 that fits on one line.
L = λ × W
Everything below is about using that line well. The examples come from the ingestion workers I built for Tesar, with numbers we measured, plus a simulation for the part about grouping Jobs, so you can rerun every number yourself.
What the three letters mean
| Symbol | Meaning | In a job system |
|---|---|---|
| L | Average number of items inside the system | Jobs in flight, messages unacked, requests open, connections held |
| λ (lambda) | Average rate items pass through | Jobs per second, requests per second, messages per minute |
| W | Average time one item spends inside | Time from entering the boundary to leaving it: waiting plus running |
Two details matter more than they look.
Units have to agree. If λ is per second, W is in seconds. Most mistakes I have seen in sizing docs are a per-minute rate multiplied by a time in milliseconds.
λ is the rate in and the rate out. In a stable system those are the same over time. If more comes in than goes out, the queue grows without end, W grows with it, and no average is meaningful. The first question about any queue is whether it is stable. The law only applies after that.
Why it is true
John Little proved it in 1961, and the proof is short enough to get the idea from a picture.
Count the items inside the system at every instant and plot it. The area under that curve, over a long window T, is the total item-seconds spent inside. You can compute that area two ways. Per instant: average count times T, which is L × T. Per item: number of items times the average time each stayed, which is λT × W. Same area, so L = λW.
Nothing in that argument talks about how items arrive, how long they take, or in what order they are served. Poisson or bursty, FIFO or priority, one server or a thousand, it holds. That is what makes it so useful: it is not a model you have to believe, it is accounting.

The animation above uses deliberately ugly service times: two thirds of items stay 0.5 to 2 seconds and one third stays 6 to 11 seconds. The count inside jumps around constantly, and after forty seconds of simulated time λ × W and the average L agree to within about 1%.
What the law does not give you is any statement about the instant, or about the tail. L is an average count. W is an average time. A p99 is not in the formula, and I come back to that below because it is where most of the interesting decisions are.
Draw the box anywhere
The system in L = λW is whatever boundary you choose. That is the part I use most, because it lets you measure two of the three numbers and get the third for free.

At 2.42 Jobs per second passing through:
- Draw the box around the slots only. W is the running time, 3.31 s, so 8 slots are busy.
- Draw it around the queue only. If Jobs wait 10 s before a slot picks them up, about 24 are waiting.
- Draw it around both. W is 13.31 s, so 32 Jobs are inside the worker in total.
Each box gives you one equation. In practice you usually know λ from a counter and L from a gauge (queue depth, in-flight count), and W is the thing you cannot see directly, so W = L / λ. If your broker tells you the queue depth is 1,200 and you drain 40 per second, a new Job waits about 30 seconds before anyone looks at it. No tracing needed.
Sizing a worker that pulls into slots
The workers I write pull Jobs into a fixed number of slots and only ask the broker for more when a slot is free. While there is work waiting, every slot is busy, so L is the slot count. Rearranged, the law gives throughput directly:
λ = slots / W
That changes how you plan capacity. You do not need a load test to know what a worker can do. You need W, which you can read in production from the time each Job spends in a slot.
Going the other direction, to hit a target rate:
slots needed = target λ × W
At Tesar, against a provider that takes 0.1 s per file, each Job spent about 3.3 s in its slot (fetching, parsing, writing to the twin, reporting the outcome). To ingest 500 Jobs a minute:
500 / 60 = 8.33 Jobs/s
8.33 × 3.3 s = 27.5 slots
Round up, add headroom (more on that below), and that is the setting. Here is what happened when we doubled slots on the real worker:

| Slots (L) | Jobs a minute (λ) | W = L / λ |
|---|---|---|
| 2 | 37 | 3.24 s |
| 8 | 145 | 3.31 s |
| 16 | 280 | 3.43 s |
| 32 | 548 | 3.50 s |
W moved 8% across a sixteenfold change in slots, so throughput grew almost in step. Each slot costs about 0.3 MiB in that worker, so adding concurrency inside the process was close to free. No new machine.
W tells you which lever to pull
The table above is one of two shapes W can take as you add concurrency, and telling them apart is the most practical thing the law gives you.
W flat while L grows. The slots are waiting on something outside the worker: a provider, a database, the network. The worker is not the bottleneck. Add slots.
W growing in proportion to L. Throughput has stopped growing and the extra Jobs are just queueing inside your process. The worker is now the server. Adding slots only adds waiting. Add another worker (or fix what makes each Job expensive).
The same Tesar worker against a provider that answers instantly showed the second shape:
| Workers × slots | Jobs a minute | W = L / λ |
|---|---|---|
| 1 × 4 | 7,185 | 33 ms |
| 1 × 8 | 7,689 | 62 ms |
| 1 × 16 | 7,614 | 126 ms |
| 2 × 8 | 11,384 | 84 ms |
From 8 to 16 slots, λ is flat and W doubles. That is the law telling you, with no profiler, that the extra 8 slots did nothing. A second worker on the same queue took it from 7,689 to 11,384.
So when someone asks me "should we scale this?", I ask what W does when we add concurrency. That one curve answers it.
Headroom: the law is exact, the averages are not enough
Little's law is about averages. Queues hurt you in the tail, and the tail is decided by utilization: how close the arrival rate is to the capacity.

This is the textbook M/M/c model (random arrivals, random service times), which is a reasonable stand-in for a busy job queue. With one consumer, W is 2 times the service time at 50% busy, 5 times at 80%, and 10 times at 90%. With 8 consumers sharing one queue the curve stays flat much longer: 1.3 times at 80%, 1.9 times at 90%, 3.1 times at 95%. Every point on both curves satisfies L = λW. The law tells you how many Jobs are inside at each point. It does not tell you where the cliff starts. Utilization does.
That gives two practical rules:
- Size for a target utilization, not for 100%. If the math says 27.5 slots, I do not run 28. I divide by the utilization I am willing to live at (0.7 to 0.8 for most queues), so about 35 to 40 slots.
- Pooled consumers absorb variance better than separate ones. Eight slots on one queue behave far better than eight queues with one slot each. Keep that in mind for the next section, because grouping queues by SLA looks like it contradicts it. It does not.
Every limit on things in flight is an L
Once you see the law, you see it in every configuration file. Anything that caps how many things can be in flight at once is an L, and its correct value is λ × W for the slowest honest W, plus headroom.
- Connection pools. 400 queries per second at 25 ms each is
400 × 0.025 = 10connections busy on average. A pool of 10 is already at the cliff from the previous section; a pool of 14 to 16 is not. - Broker in-flight caps (
max_ack_pendingin NATS, prefetch in RabbitMQ). Messages delivered and not yet acked are L. - Concurrency limits and rate limiters. A downstream that allows 50 concurrent requests and answers in 200 ms will never do more than
50 / 0.2 = 250requests per second, whatever your client does. - Buffers and channels. A bounded channel between two stages has to hold
λ × Wof the slower stage, or the fast one stalls.
And the timers are W:
- Ack waits and visibility timeouts have to be longer than the W of the slowest honest Job, or a healthy Job gets redelivered while it is still running.
- Retry windows have to cover how long the thing you are waiting for can take to exist.
- Alerts on "no result after X" have to use the real W, or they fire every day on correct data.
The worst defect I found in Tesar's ingestion this year was one of these. The consumer had max_ack_pending at 1,000. One source is NASA's daily rain product, which is published around 14:30 UTC the day after. A daily Job asks for yesterday shortly after midnight, so it waits about 14.5 hours, delivered and unacked, for its file to exist. One Job per asset per day:
L = assets × 14.5 h / 24 h
At about 1,650 assets that reaches 1,000. From there every in-flight place is held by a Job that is only waiting, and nothing else from that source is delivered, including the backfill whose files have existed for a year. Every Job ran correctly in every test. The number was only wrong once it met the real W. I wrote the full story in Jobs that run on their own.
Group queues by time to complete
This is the part people asked about most, and it follows directly from everything above.
The common way to split queues is by who produces the work: one queue per feature, per team, per domain. It feels organized. The problem is that a single queue then holds Jobs whose W differs by orders of magnitude. A thumbnail that takes 100 ms and a report that takes 14 minutes end up in the same line, served by the same consumers.
Three things break when you do that.
The average W stops meaning anything. In the simulation below, fast Jobs take 0.1 s and slow ones 40 s. The average W of the mixed queue is about 1 second, which describes no Job that ever ran. You cannot size a pool from a number that describes nothing, and every formula in this post takes W as input.
Slow Jobs take the place of fast ones. When a few long Jobs arrive close together they occupy consumers for their whole duration. The fast Jobs behind them wait for a free consumer, so a 0.1 s Job waits 20 seconds. Priority inside the queue does not save you: priority decides who is picked next, not how long the consumers that are already busy stay busy.
Sizing becomes a guess. You cannot say how many consumers the queue needs, because the answer depends on the mix at that moment.
Here is the same set of arrivals served two ways, with the same 10 consumers at the same 70% utilization:

On the left, a cluster of long Jobs takes most of the consumers and the short ones pile up behind them. On the right, the short Jobs have their own consumers and never notice.
Over four simulated hours (fast Jobs at 30 per second taking 0.1 s, slow Jobs at 0.1 per second taking 40 s, 10 consumers):

| One queue, 10 consumers | By SLA, 4 + 6 consumers | |
|---|---|---|
| Fast Jobs, average time in system | 0.88 s | 0.15 s |
| Fast Jobs, p99 time in system | 21.83 s | 0.60 s |
| Slow Jobs, average time in system | 38.98 s | 42.40 s |
| Slow Jobs, p99 time in system | 172.86 s | 173.76 s |
The fast Jobs' p99 is 36 times better. The slow Jobs pay about 9% on their average and nothing measurable on their p99. Nothing was added: same consumers, same arrivals.
This looks like it contradicts the pooling rule from the headroom section. It does not. Pooling helps when the Jobs in the pool are alike, because one consumer can stand in for any other. Pooling Jobs whose W differs 400 times is not pooling, it is letting the slow class borrow the fast class's capacity at the worst possible moments.
How I define the classes
I group by the time a Job is allowed to take to complete, which is its SLA, not by who sends it:
| Class | Must complete in | Typical work |
|---|---|---|
| Real-time | under 5 s | user-facing actions, notifications, small writes |
| Near-real-time | under 60 s | enrichment, webhooks, single-file ingestion |
| Batch | minutes to hours | backfills, reports, reprocessing, anything waiting on an external publish |
Then each class is sized on its own, with its own λ and W:
consumers for a class = (λ of the class × W of the class) / target utilization
For the simulation above:
| Class | λ | W | λ × W (busy) | Target utilization | Consumers |
|---|---|---|---|---|---|
| Real-time | 30 / s | 0.1 s | 3 | 0.75 | 4 |
| Batch | 0.1 / s | 40 s | 4 | 0.67 | 6 |
That is exactly the 4 + 6 split in the animation. It came from the formula, not from tuning.
A few rules keep it working:
- Classify by expected W, not by producer. Two Jobs from the same team with W of 50 ms and 20 minutes go to different queues. Two Jobs from different teams with the same W can share one.
- Keep W homogeneous inside a class. If the slowest normal Job in a class takes more than about ten times the fastest, the class is hiding two classes.
- Watch W per class. When a Job type drifts out of its class (a "fast" call that started taking 30 s), move it. The class's W chart shows you when.
- Long waits are batch, even when the work is small. A Job that does 2 s of work but waits 14 hours for its input is a 14-hour Job for every L that holds it. Our NASA Jobs belonged in their own class with its own in-flight limit for exactly that reason.
Measuring it in production
You need three signals per queue or class, and most brokers already give you two of them.
- λ: a counter of completed Jobs, as a rate.
- L: a gauge of Jobs in flight (or the queue depth, depending on where you draw the box).
- W: a histogram of time per Job, from enqueue to ack.
In Prometheus terms, with names that are only examples:
# λ, Jobs per second over 5 minutes
rate(jobs_completed_total{class="realtime"}[5m])
# L, average Jobs in flight over the same window
avg_over_time(jobs_in_flight{class="realtime"}[5m])
# W from the histogram
rate(job_duration_seconds_sum{class="realtime"}[5m])
/ rate(job_duration_seconds_count{class="realtime"}[5m])
Then use the law as a check on your own instrumentation. If L and λ × W disagree by more than a few percent over a stable window, one of the three metrics is lying. The usual causes are retries that are not counted as completions, Jobs that crash without decrementing the in-flight gauge, or W measured from the start of execution instead of from enqueue. I have found more broken metrics this way than broken queues.
Where people get it wrong
- Mixing units. Jobs per minute times seconds. Write the units next to every number.
- Applying it to an unstable queue. If the backlog is growing, there is no steady W. Fix the capacity first.
- Using p99 as W. The law takes the average. Use p99 for SLAs and alerts, and the average for sizing.
- Measuring W from the wrong point. Time in the slot and time since enqueue are different boxes. Both are valid. Mixing them in one equation is not.
- Forgetting that waiting counts. A Job holding an in-flight place while it sleeps on a backoff is part of L for every limit that counts it.
- Sizing to 100%. The math gives you the busy count. The headroom comes from the utilization curve.
Cheat sheet
| You know | You want | Use |
|---|---|---|
| Slots and W | Throughput | λ = slots / W |
| Target rate and W | Slots or consumers | L = λ × W, then divide by target utilization |
| Queue depth and drain rate | How long a new Job waits | W = L / λ |
| Request rate and query time | Connection pool size | λ × W, plus headroom |
| Publish delay and daily volume | In-flight cap | volume per day × delay / 24 h |
| W as you add slots | Whether to scale up or out | Flat W: more slots. Growing W: more workers |
The simulation for the grouping section is a plain discrete-event model: Poisson arrivals, exponential service times, FIFO per queue, four hours of simulated time. The worker numbers come from Tesar Core's phase 3 proof, run on an Apple M5 Pro with the stack in a VM at 4 CPUs.