Subscribe
AI
6 min read

What Is Queueing Theory? The 1909 Telephone Math Behind Every AI Wait

Erlang's telephone math from 1909 explains LLM API latency, why KV cache memory tracks request duration, why agents feel slow, and why batch endpoints cost exactly half.

Olivetti-style brochure graphic asking What Is Queueing Theory, with a dotted queue feeding a telephone exchange panel
Olivetti-style brochure graphic asking What Is Queueing Theory, with a dotted queue feeding a telephone exchange panel

Every AI product decision that touches speed or price is a decision about a waiting line. Queueing theory is the 117-year-old branch of mathematics that describes what happens when random arrivals meet a shared server, and it turns out to be the right framework for LLM APIs: reasoning time is the service time, your requests are the calls, and the provider's GPUs are the exchange.

A telephone engineer got there first

The field starts with Agner Krarup Erlang, a mathematician working for the Copenhagen Telephone Company. In 1909 he published "The Theory of Probabilities and Telephone Conversations," which showed that random telephone call arrivals follow a Poisson distribution. His 1917 paper, "Solution of some Problems in the Theory of Probabilities of Significance in Automatic Telephone Exchanges," derived the classic formulas for call loss and waiting time, and a 1920 paper handled waiting times with constant holding times (Erlang biography, Wikipedia).

The unit of telephone traffic still carries his name: one erlang is one circuit occupied continuously for one hour (Erlang (unit), Wikipedia)). In 1953 David G. Kendall, who also introduced the first use of the term "queueing system," proposed the A/B/c shorthand (M/M/1, M/G/c and so on) that classifies queues by arrival distribution, service distribution and server count (Kendall's notation, Wikipedia; INFORMS history of queueing models). Leonard Kleinrock carried the same mathematics into packet-switched networks in the early 1960s, which is why the theory arrived in computing half a century before the transformer (INFORMS, same link).

The curve that governs every wait

Waiting mass accumulating under a rising hyperbolic curve, in Olivetti brochure style

The central quantity is utilization, usually written ρ (rho): the fraction of time the server is busy. For a single-server queue with Poisson arrivals and exponential service times, the model known as M/M/1, the long-run average number of jobs in the system is ρ/(1-ρ) (Queueing theory, Wikipedia).

That denominator is the whole story. At 50% utilization the expected number of jobs in system is 1. At 90% it is 9. At 99% it is 99. John Kingman formalized what happens near the cliff in his 1962 heavy-traffic results: as utilization approaches 1, the waiting time distribution converges to an exponential, and wait times grow explosively regardless of small tweaks to the arrival or service distributions (Heavy traffic approximation, Wikipedia).

The practical consequence for any shared model endpoint: a provider running its GPUs at 60% is in a different physical regime from one running at 95%, even though the utilization figures differ by a third. Average latency is not a linear function of load. The queue does not fill gradually; it fills hyperbolically, and it fills most in the tail, which is the part users feel.

Little's law explains why the KV cache eats memory

The second result you need is Little's law, proved by John Little in 1961 in Operations Research: for a stable system, the average number of items in the system equals the arrival rate multiplied by the average time each item spends in it, L = λW (Little, 1961, doi:10.1287/opre.9.3.383; Little's law, Wikipedia). It holds with almost no assumptions about arrival or service distributions, which is why it survives every model change.

LLM serving makes the law unusually visible. A chat request occupies a GPU slot from the moment it arrives until its last token is generated, because the key-value cache for that sequence must persist while decoding continues. Little's law then says the number of requests a server can hold in flight equals throughput times average request duration. Reasoning models, which spend thousands of tokens thinking before answering, inflate W directly, and every unit of extra thinking time costs the provider a unit of concurrent-request capacity. The memory that must scale with W is the KV cache, the bottleneck that systems like vLLM attack with paged memory management.

What the serving engines actually do

Staggered token blocks flowing into a control panel with dials, in Olivetti brochure style

The LLM inference literature is, read sideways, applied queueing theory. Orca, the 2022 OSDI paper that popularized continuous batching, schedules at the level of single iteration steps so that finishing requests free their slot immediately instead of forcing the whole batch to wait for the longest sequence, which raises effective service capacity on the same hardware (USENIX OSDI '22). vLLM's PagedAttention, presented at SOSP 2023, treats the KV cache like virtual memory so batch size stops being limited by fragmentation, and reported 2-4x throughput improvements over state-of-the-art systems including Orca at the same latency level (Kwon et al., arXiv:2309.06180). Both are attacks on ρ: the more jobs the server can serve simultaneously and the less idle time per step, the further down the ρ/(1-ρ) curve a given traffic load sits.

Agents inherit the tail

Jeff Dean and Luiz André Barroso's 2013 Communications of the ACM paper "The Tail at Scale" made the point that matters most in the agent era: when one user action fans out into many requests, rare slow responses become routine, because the probability of hitting at least one slow leg grows with the number of legs (Google Research page). In their Google measurement, waiting for all leaves of a fan-out query instead of 95% of them doubled p99 from 70 ms to 140 ms.

A single chat completion is one leg. A coding agent that runs 20 model calls per task is 20 legs. If each call individually stays under its p95 latency 95% of the time, the chance that a 20-call episode hits at least one slow step is 1 - 0.95^20, roughly 64%. Queueing variance does not average out across a multi-step agent loop; it compounds, which is why agents feel slower than their per-token benchmarks suggest.

The price list is a queue priority table

Providers now sell waiting time directly. OpenAI's Batch API processes uploads asynchronously, completes within a stated 24-hour window (often sooner) and charges 50% of synchronous prices (OpenAI batch docs). Anthropic's Message Batches API works the same way: 50% off input and output token prices, batches expire after 24 hours, and Anthropic states most complete within one hour, with limits of 100,000 requests or 256 MB per batch (Anthropic batch docs).

Read through Erlang, these are not discounts. They are admission-control policies with a price attached. A batch endpoint promises throughput (jobs per hour), not latency (time per job), and lets the provider pack the queue without the head-of-line reservations that interactive traffic demands. That packing is what pays for the half price. When you buy synchronous access you are buying a shorter expected wait, and the 1909 math says the marginal cost of that shorter wait rises sharply as the shared pool gets busy.

What the model does not promise

Queueing theory's limits are worth stating. The classical models assume arrivals that are roughly Poisson and service times with known averages; real AI traffic is burstier than that, and LLM service times depend on output length, which is not known at admission. The theory gives shape, not point forecasts: the hyperbola near full utilization, the multiplication of tails across fan-out, the identity between in-flight work and memory. These three facts, all derived between 1909 and 1961, explain more about why your AI is slow than any benchmark table does.

Sources

AILLMeducational