HomeSociety & EconomicsQueueing Theory

🎫 Queueing Theory

Interactive M/M/c queue simulator. Tune arrival rate λ, service rate μ and the number of servers c. Compare live metrics to Erlang-C theory and watch the queue explode as utilisation ρ approaches 1.

Society & Economics3DModerate60 FPS
queue-theory ↗ Open standalone

About this simulation

This simulation runs a live discrete-event M/M/c queue: customers arrive one at a time following a Poisson process with rate λ, and are served by c parallel servers, each with an independent exponential service time at rate μ. The engine advances the simulation clock, draws random inter-arrival and service times, and accumulates time-weighted averages for queue length and waiting time as customers pass through. Every measured statistic is compared live against the closed-form Erlang-C formula, so you can see simulation noise converge toward theory as time passes.

🔬 What it shows

Customers (blue dots) arrive at random intervals drawn from an exponential distribution with mean 1/λ, join a FIFO or LIFO waiting line if all c servers are busy, and are served for a random exponential time with mean 1/μ. The system tracks utilisation ρ = λ/(cμ), the number in system L, the number waiting Lq, and the average time in system W and time waiting Wq — each shown as a live simulated value next to the Erlang-C theoretical prediction.

🎮 How to use

Drag Arrival rate λ and Service rate μ (per server) to change the load, and Servers c to add or remove parallel servers — the load bar at the bottom turns red once ρ ≥ 1, meaning the queue will grow without bound. Switch between FIFO and LIFO to compare disciplines, use Simulation speed to fast-forward, and try the Stable, Near-saturation, Multi-server bank and Understaffed presets to jump straight to interesting regimes. Reset stats clears the running averages so you can watch them build up from a clean state.

💡 Did you know?

The Erlang-C formula was derived in 1917 by Danish engineer Agner Krarup Erlang to size telephone exchanges so that callers rarely got a busy signal. The same mathematics is now the basis of call-centre staffing, hospital bed planning, and cloud-server autoscaling — anywhere random arrivals compete for a limited number of servers.

Frequently asked questions

What is an M/M/c queue?

M/M/c is Kendall's notation for a queueing system with Markovian (Poisson) arrivals, Markovian (exponential) service times, and c parallel servers. The first M means the time between arrivals is exponentially distributed, the second M means each server's service time is exponentially distributed, and c is the number of identical servers working in parallel. This simulation implements exactly that model, running arrivals and departures as discrete random events on a simulated clock.

What does utilisation ρ mean, and why does the queue explode near ρ = 1?

Utilisation ρ = λ/(cμ) is the fraction of total service capacity being used, where λ is the arrival rate and cμ is the combined service rate of all c servers. When ρ is comfortably below 1, servers can keep up and the queue stays short. As ρ approaches 1, servers are almost always busy, so any random burst of arrivals has nowhere to go and the waiting line grows increasingly long; at ρ ≥ 1, arrivals outpace capacity entirely and the queue grows without bound, which is exactly what the red load bar warns about.

What is the Erlang-C formula and what does it predict?

Erlang-C is a closed-form formula that computes exact steady-state statistics for an M/M/c queue directly from λ, μ and c, without needing to run a simulation. It gives the probability an arriving customer has to wait at all, P(wait > 0), and from that derives the expected number waiting Lq, expected number in the whole system L, expected waiting time Wq, and expected total time in system W (via Little's law, W = Wq + 1/μ). This page shows the theoretical Erlang-C values in yellow right next to the live simulated measurements in blue, so you can see how closely random simulation matches the mathematical prediction.

Why do the live (blue) and theoretical (yellow) numbers not match exactly?

The live statistics are time-weighted averages accumulated from actual random events — exponential inter-arrival and service times drawn fresh each time — so they carry statistical noise, especially soon after a reset or preset change. The Erlang-C numbers are the exact mathematical steady-state averages the system would reach given infinite time. The longer the simulation runs at a fixed λ, μ and c, the closer the blue numbers converge to the yellow ones, which is a live demonstration of the law of large numbers.

What is the difference between the FIFO and LIFO presets in this simulation?

FIFO (first-in, first-out) serves customers in the order they arrived, like a typical checkout line — this is the discipline assumed by the classic Erlang-C formula. LIFO (last-in, first-out) instead serves whichever customer joined the queue most recently, which can leave early arrivals waiting indefinitely under heavy load even though the average waiting time Wq stays the same as FIFO. Switching disciplines does not change any of the Erlang-C averages, but it changes who experiences the longest individual waits, visible as the 'Longest wait' statistic.

⚙ Under the hood

An M/M/c queue with Poisson arrivals and exponential service. Watch the line form and compare live metrics (utilisation ρ, queue length Lq, wait Wq) against Erlang-C theory — see the queue explode as ρ→1.

SocietyQueueing TheoryM/M/cErlang-CPoisson Process

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)