By the Numbers / Queues
Systems don't fall over when they're full. They fall over when they're busy, and busy starts a lot earlier than you'd think.
This page works it out from a handful of formulas. Every chart puts the formula, in ink, next to a small simulation running in your browser, as terracotta dots, so you can watch where the math holds and where it quietly stops working.
This is one checkout. Shoppers arrive at random and take a random time to serve, slowed down so you can watch. The scale under the slider is the average wait in service times. Drag past 90% and keep an eye on the line.
Here is a trick that works on almost anything with a line. Count how fast things arrive and how long each one stays. Multiply, and you know how many are inside.
A supermarket that lets in two shoppers a minute, each staying fifteen minutes, holds thirty shoppers on average. You don't need to know the layout, how many tills are open or who is holding up the deli counter. A service handling 2,000 queries a second, each holding a database connection for 4 ms, keeps eight connections busy. Same arithmetic.
People leaned on this for decades before anyone proved it. John Little, the first doctoral student in operations research in the United States, was a young professor at the Case Institute of Technology in Cleveland when he published the proof in 1961. Until then it was a formula that kept turning up in specific queue models, with no general proof. He lived to 96.
The catch is that it only talks about averages. Multiply p99 latency by the request rate and you get nothing useful. Count only what actually got in: if you're shedding load, rejected requests never took up any room. And measure over a long window on a system that isn't growing. While a backlog is building, the formula describes the past, not what the next request will face. The agent preset shows this: 90-second tasks measured over a 48-second window don't add up.
You can draw the box anywhere. Around the waiting line alone, it gives you the average line length. Around the servers alone, it gives you how many are busy, which is utilization. That's the number the rest of this page is about.
One sample path. Bars are requests: ink arrived inside the window, indigo were already in flight. Bottom: L(t).
Toy assumptions: Poisson arrivals, time in system lognormal with the mean W you set (coefficient of variation 1), unlimited concurrency. The identity does not care about any of these. The window holds about 40 arrivals so edge effects stay visible; when W is long compared with the window, the measured numbers drift apart, which is the window's fault, not the law's.
You've felt this at the supermarket. The store gets a little busier and the line gets a lot longer. That isn't bad luck. For one checkout with shoppers arriving at random, the average wait in line, counted in service times, is
where ρ (rho) is the share of time the cashier is busy. Try a few values. Half busy, you wait one service time. At 80%, four. At 90%, nine. At 99%, ninety-nine.
So the step from 80% to 90% more than doubles the wait. The last ten points of utilization cost more than the first eighty, which is why a database at 95% isn't efficient. It's one bad minute away from a very long line.
Randomness is the other ingredient. In 1961, the same year as Little's proof, John Kingman, a Cambridge mathematician just out of his undergraduate degree, showed how much it matters. (He went on to run the University of Bristol.) His approximation works for any pattern of arrivals and service:
The two c² terms measure how uneven things are: the gaps between arrivals, and the time each job takes. Random is 1 and clockwork is 0. Because they multiply the utilization term, smoothing things out works like adding capacity. Split long queries from short ones, or spread out bursty clients, and the line shrinks as if you'd bought hardware. If everything were perfectly regular there would be no line at all, even at 99% busy. Nothing real works that way, but it tells you where the waiting comes from.
One thing never changes: going from 80% to 90% still multiplies the wait by 2.25, however uneven things are. Variability moves the whole curve up or down. It doesn't change the shape.
It's built for busy systems. It is exact for the fully random case, and whenever arrivals are random it matches the exact Pollaczek–Khinchine result. With non-random arrivals at moderate load it can be well off: set ca² to 0 or 4 at 50% and compare the dots with the curve. It also only gives you the average. Near saturation the wait is roughly exponential with that average, so p99 is about 4.6 times the mean there heavy traffic only.
Mean wait in queue, in service times, against utilization
Toy assumptions: one first-come-first-served server, mean service time 1, gaps and service times drawn from gamma distributions with the chosen c² (0 means constant). Each dot averages 150,000 to 400,000 simulated customers after a 10% warm-up. Error bars come from 20 batch means; they are wide near saturation because the queue has a long memory there.
Ever notice that the other line always moves faster? With three checkouts, it usually does. The chance that yours is the fastest is only one in three.
Airport security gets around this with one long snake feeding every lane. It looks worse and works far better. With 8 lanes, 80% busy and a minute per traveler, the shared snake averages about 17 seconds of waiting. Eight separate lines average four minutes, fourteen times longer, because with one line no lane sits idle while people are stuck behind a slow traveler next door.
The math behind this comes from Copenhagen. In 1908 the Copenhagen Telephone Company hired a schoolteacher named Agner Krarup Erlang. Its chief engineer, Johan Jensen (the Jensen of Jensen's inequality), had met him through the Danish mathematical society, and he put Erlang in charge of a new lab. By 1909 Erlang had shown that phone calls arrive at random in exactly the sense this page uses. By 1917 he had formulas for how many lines and operators an exchange needed, which is the same question as how many database connections your service needs.
Here c is the number of servers, a is how many are busy on average (Little's Law again) and C is Erlang's formula for the chance you have to wait at all. Bigger pools can also run hotter for the same wait, which is why huge call centers look so efficient.
Software builds separate lines by accident all the time: a connection pool per pod, a worker pool per shard, sticky routing, a thread pool per tenant. The fixes are a shared dispatcher, sending each job to the shortest line, or checking two lines at random and picking the shorter. A shared line has one requirement. The work has to be interchangeable, or one slow kind of job blocks everyone behind it.
A connection pool is Erlang's telephone exchange with connections instead of operators. Hold time is everything between checking a connection out and handing it back: the query, the network round trips and any application code that runs inside the transaction. Little's Law gives you the floor (rate × hold time), and Erlang adds the headroom so checkouts rarely wait.
The ceiling usually comes from a rule of thumb on the PostgreSQL wiki that HikariCP's docs made famous: (core_count × 2) + effective_spindle_count. It's easy to misuse. It counts connections on the database server across every app instance, so 20 pods with pools of 10 are already asking for 200. It means physical cores, not hyperthreads. The spindle part dates from spinning disks, and HikariCP's own page says nobody has worked out how it holds on SSDs. It also ignores time a connection sits idle while your app thinks, which raises the floor without raising the ceiling. Use it as a place to start benchmarking, not as an answer.
If the floor ends up above the ceiling, a bigger pool won't save you. It just moves the line out of the pool, where it's cheap and you can see it, into the database, where it turns into lock and CPU contention. Shorten the hold time or get a bigger database. The Postgres page covers what each connection costs the server in its Connections section.
If one thread can hold several connections at once, the pool needs at least Tn × (Cm − 1) + 1 of them, where Tn is the number of threads and Cm is the most connections one thread holds at the same time. Any fewer and every thread can end up holding some connections while it waits for one more.
Mean wait in service times (log scale) against utilization
Formula on top, simulated underneath. Toy assumptions: Poisson arrivals, exponential service with mean τ, first come first served. Separate lines each get a random share of arrivals, like random load balancing over per-pod pools. 100,000 simulated customers each.
Floor: Erlang C, treating connections as servers with exponential hold times, smallest pool meeting the p99 checkout target. Per-instance pools assume even load balancing and at least one connection per instance. Ceiling: (2 × cores) + spindles, the PostgreSQL wiki starting point. Both are toy models; benchmark around them.
Drive across town through 100 traffic lights, each red only 1% of the time. You'll still stop at least once on 63% of trips. A request that has to hear back from 100 servers makes the same drive.
The 63% isn't a quirk of these particular numbers. Whenever the fan-out is the inverse of the slow rate (100 servers at 1%, or 1,000 at 0.1%), the answer settles near 1 − 1/e, about 63%.
In February 2013 two senior Google engineers, Jeff Dean and Luiz André Barroso, wrote this up as "The Tail at Scale." Their point was that a big system can't get rid of slowness any more than a city can get rid of red lights, so it has to be built to live with it. They described a few ways:
All of this assumes slowness comes from the server, not the request. A backup request rescues a server that's paused for garbage collection or stuck next to a noisy neighbor. It does nothing for a query that's simply expensive, because that query is slow on every copy. Hedge it and you double the load at the worst possible moment. Move the last slider to watch the formula and the simulation split apart. Hedges are extra traffic too, so cap them (gRPC's retry throttling covers hedges) and cancel the loser.
Share of requests touching at least one slow shard, against fan-out (shards, log scale)
Hedged p99 sits on a cliff here. About 1% of requests hit a shard that is slow on both copies (n·p² ≈ 1%), so p99 can land anywhere from tens of milliseconds to over 500 ms depending on a handful of samples. Read the "slower than 100 ms" row instead; percentiles near a step in the distribution are just as fragile on production dashboards.
Formula on top, simulated underneath. Toy assumptions: a normal shard answers in about 5 ms (lognormal, σ = 0.4); a slow one takes 0.5 to 1.5 s, echoing the paper's one-second example. Request latency is the slowest shard. A hedge goes to an independent replica; with "caused by the request" above 0, that share of slow shards are slow on the replica too. Formula columns assume independence. Simulation: up to 5,000 requests.
In 1967 IBM's Gene Amdahl made an argument that still ends design meetings. If part of a job has to run one step at a time, no amount of parallel hardware gets you past it. Picture a kitchen where every plate passes one inspector. Hire more cooks and the inspector becomes the restaurant's speed limit.
Amdahl's curve flattens out, but it never goes down, and real systems do go down. Neil Gunther, a performance analyst, ran into this while modeling tightly coupled Unix multiprocessors and added a second cost: keeping everyone in sync. Think of a team where everyone has to talk to everyone. Ten people means 45 conversations; twenty means 190. He set it out in full in his 2007 book Guerrilla Capacity Planning as the Universal Scalability Law:
σ (sigma) is contention: waiting for something shared, like a lock, a hot row or a single writer. κ (kappa) is the cost of staying in sync: cache lines bouncing between cores, locks changing hands, nodes invalidating each other's copies. If κ is above zero at all, the curve has a peak at N* = √((1 − σ)/κ). Past that point, adding workers lowers throughput. The PostgreSQL wiki describes this exact shape for database connections, a climb, a knee and then a fall, and it's the other reason the pool ceiling above exists.
You can fit the law to a handful of load-test results. Rearranged, it becomes a simple quadratic, N/X(N) = (1/λ)(1 + σ(N−1) + κN(N−1)), so an ordinary least-squares fit gives you λ, σ and κ. Paste your own numbers into the tool.
Be careful with the fit. If your data stops before the knee, κ and the peak are guesses, and the tool will say so. Fitting it this way gives the low-N points extra weight. A negative σ means things got better than linear, usually because caches warmed up. And the law describes rather than diagnoses: it tells you there's a syncing cost, not where it lives.
Throughput against concurrency
The preset datasets are synthetic samples generated from known σ and κ plus 3% noise, so you can check how well the fit recovers them. Paste your own load-test results to replace them.
Here's the strangest failure on this page. A server can be 100% busy and 0% useful.
It goes like this. Something knocks the system over for a moment: a traffic spike, or a few seconds of lost capacity. Requests start timing out, so clients retry. The server still finishes the abandoned originals, which means it spends all its time on work nobody is waiting for, while the retries keep the line full. Then the trigger goes away and the system stays down. Nathan Bronson and three colleagues named this a metastable failure at HotOS in 2021. A year later, Lexiang Huang and colleagues took apart 22 of them across 11 organizations, and cited AWS's outage of 7 December 2021 as a fresh case. The simulation on the right fails the same way, and you can try the fixes on it.
Retries also multiply on the way down the stack, like a chain letter. If each of d layers tries r + 1 times, one click can turn into (r + 1)d attempts at the bottom. Google's SRE book counts 64 database attempts for three layers that each try four times. AWS's Builders' Library counts 243 for five layers that each try three times. Retries are great for one-off glitches. They're poison during overload, because they add load at the exact moment there's none to spare.
The fixes the industry has settled on over the last fifteen years:
Worst case, when every attempt fails. The budget line assumes each layer caps retries at 10% of its traffic, a common style of budget; check your own library's rule.
Requests per second over a 40 s run. Shaded: the capacity dip.
Toy assumptions: one server, 1,000 requests/s capacity (exponential service, 1 ms mean), Poisson users, a retry 0 to 20 ms after a timeout or a fast rejection. The server finishes abandoned requests unless "Drop expired" is on. Retry budget: 0.1 token per new request, bucket of 10. Controlled delay: once the queue has been non-empty for 100 ms, shed anything that waited over 5 ms. The dip starts at 8 s.
An airport checkpoint that screens 600 people an hour has an easy morning when they trickle in and an awful one when four tour buses pull up at once. Same number of people. The difference is how they arrive, and most capacity plans assume the gentle version: random, independent arrivals, which the textbooks call Poisson.
Agent workloads are tour buses by design framing. One planning step fires off a batch of tool calls, lookups or queries within a few milliseconds, then goes quiet while the model thinks. Real LLM traffic already looks lumpy. BurstGPT, built from 10.31 million requests to Azure OpenAI services over 213 days, traced memory-related failures in serving systems back to short bursts. ServeGen (2025) found that the Poisson model often fits poorly.
The simplest tour bus is a batch of b requests arriving together, with the batches themselves arriving at random. The average rate and utilization don't change. The exact average wait does:
At 70% busy, batches of eight wait 14 service times on average, six times what a Poisson plan predicts. Some of that you pay even on an idle server, because the last person off the bus waits for the seven ahead. That part comes from the burst, not the load, so no amount of spare capacity removes it. Shaping does: add jitter, cap how many calls each agent can have in flight, or give each agent a token bucket.
Treat each bus as one big job whose size is the sum of b service times, apply the Pollaczek–Khinchine formula to the buses, then add the average wait behind your own busmates, (b−1)/2 service times. Set b = 1 and you get back the ordinary single-checkout result.
Real bursts vary in size and spread out over a few milliseconds, so identical, simultaneous batches are the pessimistic simple case. Bursts that line up across agents (the same schedule, prompt template or upstream event) are worse than independent ones, and no single-queue formula sees that. LLM calls also vary enormously in how long they take, because output length varies, which raises cs² on top.
The same mean rate, two ways
Mean wait in queue, in service times, against utilization
Toy assumptions: one first-come-first-served server, exponential service with mean τ, batches of exactly b arriving together, batch arrivals Poisson. 150,000 simulated requests per dot.
Queue math is easy to underestimate, so check your gut. Commit to a number first. The reveal runs the formula and a fresh simulation side by side.
One server, Poisson arrivals, exponential service with a 10 ms mean. Response time is wait plus service; in this model it is exponential with mean τ/(1−ρ), so its p99 is ln(100) ≈ 4.6 times that mean. Simulation: 1,000,000 requests.
Worst case: the database is down, so every attempt at every layer fails and every layer spends its full retry allowance on each call it receives.
"Run at 70%" means nothing without c². Smoothing arrivals and separating work classes is capacity you get without buying hardware.
Every fan-out multiplies the chance of meeting a p99. Budget latency per hop from the end-to-end percentile, and hedge only server-caused slowness.
Queues, retries, in-flight requests and pools all need explicit limits. An unbounded queue is a latency bomb with a delayed fuse.
Budget them globally, add jitter, and retry at one layer only. Per-request retry counts multiply across layers.
Metastable systems stay broken after the trigger is gone. Test recovery from a dip, not just peak throughput, and shed or drop stale work.
Capacity changes with every deploy, cache state and neighbour. Limits that track latency have replaced hand-tuned constants at Netflix and Uber.
CoDelNichols and Jacobson control queue delay rather than queue length; published as RFC 8289 (Experimental) in 2018.
The Tail at ScaleDean and Barroso make tail tolerance a design goal: hedged and tied requests, micro-partitions.
Fail at Scale; backoff with jitterFacebook publishes controlled delay, adaptive LIFO and client concurrency caps. AWS shows jitter cuts contention from synchronized retries.
SRE book; SDK retry bucketsGoogle's cascading-failures chapter: retry budgets, 64× amplification, small queues. AWS SDKs gain token-bucket retry limits.
gRPC retry designRetry and hedging policies ship with built-in throttling.
Adaptive concurrency limitsNetflix open-sources limits derived from TCP congestion control.
Metastable failuresBronson and colleagues name the pattern and its sustaining effects.
Metastable failures in the wild22 incidents across 11 organizations, written as AWS's December 2021 outage unfolded.
CinnamonUber runs TCP-Vegas-style adaptive concurrency across a wide range of services.
LLM traffic is burstyBurstGPT and ServeGen trace production LLM serving and find arrivals that Poisson models poorly.
One decision spawns a tree of calls with heavy-tailed service times. Batch-Poisson is a first cut; there is no standard model yet open.
Bronson and colleagues called a systematic defence against unknown metastable failures an open problem. A 2026 preprint offers a causal characterization and a prediction methodology; whether it becomes tooling is open.
CoDel-style control assumes requests of similar cost. LLM calls and analytical queries differ by orders of magnitude, so delay alone is a weak signal framing.
A database or branch per agent means many small separate pools: the expensive configuration from the many-servers section, multiplied. Shared poolers help only if the work is interchangeable framing.
Near ρ = 1 queues build in seconds while scale-out takes minutes. How much headroom a given scale-out lag requires is still answered by load tests rather than formulas framing.
Mor Harchol-Balter, Performance Modeling and Design of Computer Systems: Queueing Theory in Action (Cambridge University Press, 2013). The book that brings queueing theory back to computer science. It is organized around puzzles a systems designer actually faces, such as one fast machine or n slow ones, and its exercises are where the counterintuitive lessons live.
Neil J. Gunther, Guerrilla Capacity Planning (Springer, 2007). The full presentation of the Universal Scalability Law, written for people who plan capacity three months ahead with whatever data they have. Read chapters 4 to 6 before fitting your own load tests.
Betsy Beyer, Chris Jones, Jennifer Petoff and Niall Richard Murphy (eds.), Site Reliability Engineering (O'Reilly, 2016). Chapter 22, on cascading failures, is the clearest practitioner account of retry budgets, queue sizing and load shedding, and it is free to read online.
Leonard Kleinrock, Queueing Systems, Volume 1: Theory (Wiley, 1975). The classic graduate text from UCLA, with birth-death chains, M/G/1 and G/G/1 worked through step by step. Dense, but the classic M/M/c and M/G/1 results on this page are derived in it.
Every simulation runs in your browser with a fixed random seed, so the same settings give the same dots. Interpretive or uncertain claims carry a flag.
MusicChordsRhythmBluesJazz HarmonySynthesisMIDIVoiceSoftwarePostgresInfrastructureThe GridData CentersEarthHurricanesEarthquakesStartupsFounder Equity