Chris Collins

Tools · distributed

Capacity and queueing planner

Queueing maths for capacity planning: Little's law, M/M/1, M/D/1, M/G/1 and Kingman, M/M/c with Erlang C and exact percentiles, the utilisation-versus-latency knee, the tail at scale of fan-out requests, hedged and tied requests, a discrete-event simulator that checks the formulas, and a planner that turns a p99 target into a server count.

Added

Works with

How to use it

How busy can a server get before latency falls apart, how many servers does a p99 target need, and why does a request that fans out to a hundred machines see the tail of all of them? Each tab is a calculator with the formulas shown, and a simulator checks them.

How to use it

  • Little’s law — any two of L (items in the system), λ (throughput) and W (time in the system) give the third: L = λW. Pick what to solve, or open a worked example (connection pools, backlog drain, threads).

  • One server — arrival rate λ, mean service time E[S] and the variabilities Cs² (service) and Ca² (arrivals). Shows M/M/1 (exact), M/D/1 and M/G/1 (exact means from the Pollaczek–Khinchine formula Wq = ρ(1 + Cs²)/(2(1 − ρ))·E[S]) and Kingman’s G/G/1 approximation Wq ≈ ρ/(1 − ρ)·(Ca² + Cs²)/2·E[S], a chart of mean response time against utilisation, and M/M/1 percentiles (t_p = −ln(1 − p)/(μ − λ)).

  • M/M/c · Erlang C — c servers sharing one queue. Offered load A = λE[S] in Erlangs, utilisation, Erlang C (the probability of waiting), Erlang B (what would be blocked with no queue), mean wait and response, queue length, the service level P(wait ≤ t), exact percentiles of the waiting time, the response time and the number in the system, the response-time tail on a log scale, and a table of more or fewer servers. Erlang B is computed by its recursion B(n) = A·B(n−1)/(n + A·B(n−1)), then C = c·B/(c − A(1 − B)), so thousands of servers are fine.

  • Knee — response time (mean or p99, as a multiple of the service time) against utilisation for 1 to 64 servers, and where each curve doubles. One queue in front of many servers runs much hotter for the same latency: the case for pooling. The mean can include service variability (Allen–Cunneen); the p99 is exact M/M/c.

  • Tail at scale — the chance that a request fanning out to n servers meets at least one slow one, 1 − (1 − p)^n; the leaf percentile a user-facing p99 actually depends on, 0.99^(1/n); the largest fan-out that keeps slow requests under 1%; and Dean and Barroso’s measured table.

  • Hedged & tied — a replica’s latency as a lognormal mixture with a slow mode. A hedged request sends a second copy after the delay d (a percentile of one replica’s latency): P(R > t) = S(t)·S(t − d) past d, at the cost of S(d) extra requests (5% when d is the p95). Charts show the tail with and without hedging and the p99 against the extra load for every choice of d. Tied requests enqueue on two M/M/1 servers that cancel each other when one starts; a seeded Monte Carlo gives the percentiles and how often both servers do the work.

  • Simulator — a FCFS queue with c servers, customer by customer, in a Web Worker: service times exponential, constant, Erlang-k, lognormal or hyperexponential (H₂) with a chosen Cs², arrivals Poisson, evenly spaced or bursty H₂. It reports means with 95% confidence intervals (30 batch means after a 10% warm-up), P(wait), utilisation and percentiles next to the formula — exact M/M/c, exact Pollaczek–Khinchine for one server with Poisson arrivals, otherwise the Allen–Cunneen approximation — and plots the simulated response-time tail over the exact one.

  • Capacity planner — peak arrival rate, mean service time, a target (mean, p50 … p99.9 of the response time) and a utilisation cap. Gives the fewest servers that meet both under M/M/c, the utilisation, the share of requests that queue, the most load those servers take and the growth headroom, a table around the answer and a chart of servers against load. Check in the simulator runs the answer through the simulator.

Times are in milliseconds and rates in requests per second throughout. Everything is computed in your browser; nothing is sent anywhere.

Limits

  • The exact results assume Poisson arrivals, a single FCFS queue, identical servers and, for M/M/c and the planner, exponential service times. Real services have bursts, timeouts, retries and several queues; use the simulator and your own measurements before trusting a server count.

  • M/G/1 and M/D/1 give exact means only; their percentiles have no simple closed form. Kingman and Allen–Cunneen are approximations (typically within 10–20%, worse at light load).

  • The hedging model ignores the load the hedges add and assumes replicas are independent. The tied-request model assumes independent M/M/1 queues and instant cancellation of copies not yet started.

  • Simulated percentiles are estimates; the extreme ones need many customers.

Sources

  • J. D. C. Little, “A Proof for the Queuing Formula: L = λW”, Operations Research 9(3), 1961.

  • A. K. Erlang, “Solution of some problems in the theory of probabilities of significance in automatic telephone exchanges” (1917) — the B and C formulas.

  • L. Kleinrock, Queueing Systems, Volume 1: Theory (Wiley, 1975): M/M/1, M/M/c, M/G/1 and the Pollaczek–Khinchine mean-value formula, waiting-time distributions.

  • M. Harchol-Balter, Performance Modeling and Design of Computer Systems: Queueing Theory in Action (Cambridge University Press, 2013): M/M/k, the square-root staffing intuition, the inspection paradox and why variability matters.

  • J. F. C. Kingman, “The single server queue in heavy traffic”, Proc. Cambridge Philosophical Society 57(4), 1961. Allen–Cunneen: A. O. Allen, Probability, Statistics, and Queueing Theory (Academic Press, 1990).

  • J. Dean and L. A. Barroso, “The Tail at Scale”, Communications of the ACM 56(2), 2013 — fan-out, Table 1, hedged and tied requests.

  • Erlang B table values used in the tests: 10 circuits at 1% blocking carry 4.461 Erlangs; 5 circuits carry 1.361 Erlangs.

Related: load balancing and resilience (retries, hedging and admission control simulated), cache simulator (hit ratio cuts the load a backend sees), latency numbers, LLM serving planner (batching and the decode queue), probability and statistics.

Linking to an example

Share link copies a URL that reopens the tool with all its inputs. Hand-written links work too; add the tab after #: little, single, mmc, knee, tail, hedge, sim or plan. For example ?lam=10&es=1000&c=11#mmc or ?p=1&n=100#tail.

Parameter Meaning Example

L, X, W, solve

Little’s law: items in the system, throughput (req/s), time (ms), and which to solve (L, X or W)

X=2000&W=50&solve=L

lam1, es1, cs2, ca2

One server: arrival rate (req/s), mean service time (ms), service and arrival Cs² / Ca²

lam1=80&es1=10&cs2=0

lam, es, c, t

M/M/c: arrival rate (req/s), mean service time (ms), servers, the answer-within time (ms)

lam=10&es=1000&c=11

kmetric, kcs2, kmax

Knee chart: mean or p99, service Cs², y-axis top (10, 20 or 50)

kmetric=p99&kmax=50

p, n, slow

Tail at scale: % of one server’s responses that are slow, fan-out, what slow means (ms)

p=1&n=100&slow=1000

med, sig, ps, smed, hq

Hedging: median (ms), σ of ln latency, slow share (%), slow median (ms), hedge percentile

hq=99

trho, tes, toff, tcan

Tied requests: utilisation, mean service (ms), second-copy offset (ms), cancel delay (ms)

trho=0.9

sc, slam, ses, dist, scs2, arr, sca2, sn, seed

Simulator: servers, arrival rate, service time, service distribution (exp, det, erlang, logn, h2), its Cs², arrivals (poisson, det, h2), their Ca², customers, seed

sc=4&dist=h2&scs2=10

plam, pes, metric, target, umax

Planner: peak rate (req/s), service time (ms), mean, p50, p90, p95, p99 or p999, target (ms), utilisation cap (%)

metric=p99&target=200

example

One of the presets below; parameters written beside it override the preset’s

example=plan-p99

Presets (?example=…, which also opens the right tab):

example= Shows

pool-sizing

2,000 req/s at 50 ms keep 100 requests in flight (open)

mm1-80

One server 80% busy: mean response 5× the service time (open)

md1-half-wait

Constant service (M/D/1) waits half as long as M/M/1 (open)

bursty-gg1

Bursty arrivals and variable service, Ca² = Cs² = 4: Kingman’s 4× the M/M/1 wait (open)

erlang-c-10-11

10 Erlangs on 11 servers: 68% of arrivals wait (open)

pooling

Latency against utilisation for 1–64 servers (open)

knee-p99

The p99 knee (open)

tail-at-scale

1% slow at 1 s, 100-way fan-out → 63% of user requests slow (open)

hedge-p95

Hedge after the p95: ~5% more requests, a far shorter tail (open)

sim-mm2

Simulate M/M/2 at 80% against Erlang C (open)

sim-heavy-tail

Hyperexponential service, Cs² = 10, on 4 servers against Allen–Cunneen (open)

plan-p99

1,000 req/s at 40 ms, p99 ≤ 200 ms, ≤ 80% busy: how many servers (open)

Runs entirely in your browser; nothing you type leaves this page.