Queuing Theory

Queuing theory is a mathematical study of waiting lines, or queues. It is used to analyze systems where customers arrive, wait for service, and then depart. The goal of queuing theory is to understand the behavior of queues and to optimize the performance of the system by balancing the cost of providing service against the cost of waiting. This is crucial in many real-world applications, from call centers and supermarkets to manufacturing processes and computer networks.

Single Server Models

In a single server model, there is only one service facility. Customers arrive and, if the server is busy, they wait in a single queue. Once the server becomes free, the next customer in line is served. This is the simplest queuing model and is a good starting point for understanding more complex systems.

Basic Concepts

  • Arrival Rate (λ): The average number of customers arriving per unit of time.
  • Service Rate (μ): The average number of customers the server can handle per unit of time.
  • Traffic Intensity (ρ): The ratio of arrival rate to service rate (ρ = λ/μ). This represents the average utilization of the server.
  • Queue Length (Lq): The average number of customers waiting in the queue.
  • System Length (Ls): The average number of customers in the system (waiting or being served).
  • Waiting Time in Queue (Wq): The average time a customer spends waiting in the queue.
  • Waiting Time in System (Ws): The average time a customer spends in the system (waiting and being served).

M/M/1 Model (Poisson Arrivals, Exponential Service, Single Server)

This is one of the most fundamental queuing models. It assumes that customer arrivals follow a Poisson distribution, service times follow an exponential distribution, and there is a single server.

For the M/M/1 model, assuming the system is stable (ρ < 1):

  • Average number of customers in the queue (Lq): Lq = (λ^2) / (μ * (μ - λ))
  • Average number of customers in the system (Ls): Ls = λ / (μ - λ)
  • Average waiting time in the queue (Wq): Wq = λ / (μ * (μ - λ))
  • Average waiting time in the system (Ws): Ws = 1 / (μ - λ)

Little's Law is a key principle in queuing theory: Ls = λ * Ws and Lq = λ * Wq. It states that the average number of customers in a system (or queue) is equal to the average arrival rate multiplied by the average time a customer spends in that system (or queue). This law holds true for any stable queuing system, regardless of the arrival or service distributions.

Mnemonic for M/M/1 Formulas: Think of 'M' for 'Markovian' (Poisson/Exponential). The formulas involve λ and μ. For Ls, it's λ / (μ - λ). For Lq, it's λ * Lq = λ * (Ls - λ/μ). For Ws, it's 1 / (μ - λ). For Wq, it's Ws - 1/μ.

Example: Single Server Bank Teller

Suppose customers arrive at a bank teller at an average rate of λ = 20 customers per hour. The teller can serve customers at an average rate of μ = 30 customers per hour. We want to find the average queue length and waiting time.

First, calculate the traffic intensity: ρ = λ/μ = 20/30 = 2/3. Since ρ < 1, the system is stable.

  • Average number of customers in the queue (Lq): Lq = (20^2) / (30 * (30 - 20)) = 400 / (30 * 10) = 400 / 300 = 4/3 ≈ 1.33 customers
  • Average waiting time in the queue (Wq): Wq = Lq / λ = (4/3) / 20 = 4/60 = 1/15 hours. To convert to minutes: (1/15) * 60 = 4 minutes.

This means, on average, there will be about 1.33 customers waiting in line, and a customer will wait about 4 minutes before being served.

Multi-Server Models

In a multi-server model, there are multiple parallel servers. Customers arrive and join a single queue. When a server becomes free, the next customer from the queue is directed to that server. This setup is common in places like supermarkets with multiple checkout counters or call centers with many agents.

M/M/c Model (Poisson Arrivals, Exponential Service, c Servers)

This model assumes Poisson arrivals, exponential service times, and 'c' identical servers. It's a generalization of the M/M/1 model.

The formulas for the M/M/c model are more complex than M/M/1. The probability that an arriving customer has to wait (P(wait)) is given by:

P(wait) = P_c = ( (λ/μ)^c * P_0 ) / ( c! * (1 - (λ/(cμ))) )

Where P_0 is the probability that there are no customers in the system:

P_0 = [ (Σ_{n=0}^{c-1} (λ/μ)^n / n!) + ( (λ/μ)^c / (c! * (1 - (λ/(cμ)))) ) ]^-1

And the average number of customers in the queue (Lq) is:

Lq = P_c * (λ/μ) / (c * (1 - (λ/(cμ))))

Average waiting time in the queue (Wq) is then derived using Little's Law: Wq = Lq / λ.

Average number of customers in the system (Ls) = Lq + λ/μ.

Average waiting time in the system (Ws) = Wq + 1/μ.

Key takeaway for M/M/c: The complexity arises from multiple servers. The core idea is that having more servers reduces the probability of waiting and the waiting time, but at an increased cost. The formulas account for the probability of all servers being busy.

Example: Multi-Server Supermarket Checkouts

A supermarket has 4 checkout counters (c=4). Customers arrive at a rate of λ = 60 customers per hour. Each cashier can serve customers at an average rate of μ = 20 customers per hour. So, the total service capacity of the system is cμ = 4 * 20 = 80 customers per hour.

Calculate the traffic intensity for the system: ρ = λ/(cμ) = 60/80 = 0.75. Since ρ < 1, the system is stable.

Calculating P_0 and P_c involves several steps, but let's assume (for illustration) that after calculation, we find P_c (probability of waiting) is approximately 0.2.

  • Average number of customers in the queue (Lq): Lq = P_c * (λ/μ) / (c * (1 - (λ/(cμ)))) = 0.2 * (60/20) / (4 * (1 - 0.75)) = 0.2 * 3 / (4 * 0.25) = 0.6 / 1 = 0.6 customers
  • Average waiting time in the queue (Wq): Wq = Lq / λ = 0.6 / 60 = 0.01 hours. In minutes: 0.01 * 60 = 0.6 minutes.

With 4 servers, the average wait time is significantly reduced compared to a single server handling the same total load. If λ were 80/hour, the system would be saturated.

Erlang Service Distributions

While exponential distributions are common in queuing theory for their mathematical simplicity, real-world service times are not always exponentially distributed. The Erlang distribution is a generalization that can better model situations where service times have less variability than the exponential distribution.

Erlang-k Distribution

The Erlang-k distribution is characterized by two parameters: k (the number of stages) and θ (the average service time). The mean service time is E[S] = kθ, and the variance is Var[S] = kθ^2. As k increases, the variance decreases, making the distribution less spread out. An Erlang-1 distribution is equivalent to an exponential distribution.

M/E_k/1 Model (Poisson Arrivals, Erlang-k Service, Single Server)

In this model, arrivals are Poisson, service times follow an Erlang-k distribution, and there is a single server.

The formulas for Lq and Wq are more complex and often involve calculating the probability of waiting.

The key advantage of using Erlang distributions is that they can better capture the variability (or lack thereof) in service times. If service times are very consistent (low variance), an Erlang distribution with a high 'k' value might be a more accurate model than an exponential one.

For M/E_k/1, the variance of service time is Var[S] = (1/k) * (E[S])^2. This is less than the variance of an exponential distribution, which is (E[S])^2. A lower variance generally leads to shorter queue lengths and waiting times, all else being equal.

When to Use Erlang

Use Erlang distributions when you observe that service times are relatively consistent and not as spread out as an exponential distribution would suggest. For example, if it takes a fixed amount of time to process a standard document, an Erlang distribution might fit better than an exponential one.

Cost Models and Optimization

The primary goal of applying queuing theory in practice is to make decisions that minimize total costs. Total cost is typically a combination of two opposing costs:

  1. Cost of Service: The cost incurred by providing the service. This includes the cost of servers (staff salaries, equipment, maintenance). More servers mean higher service costs.
  2. Cost of Waiting: The cost incurred by customers (or the organization) due to waiting in the queue. This can include lost productivity, customer dissatisfaction, lost sales, and the cost of maintaining inventory while waiting for a service. Longer queues and waiting times mean higher waiting costs.

Optimization Objective

The objective is to find the optimal number of servers (or service rate) that minimizes the sum of these two costs:

Total Cost = (Cost per server * Number of servers) + (Cost per customer waiting * Average number of customers waiting)

Or, more generally:

Total Cost = (Cost of providing service) + (Cost of waiting experienced by customers)

Example: Optimizing Call Center Staffing

A company runs a call center with agents as servers. Let's consider the following:

  • Average call arrival rate: λ = 100 calls/hour.
  • Average service time per call: 1/μ = 3 minutes = 0.05 hours. So, μ = 1/0.05 = 20 calls/hour per agent.
  • Cost of operating one agent per hour: $20.
  • Cost of customer waiting time per hour (estimated cost of lost goodwill, potential sales, etc.): $5 per customer in the system (waiting or being served).

We need to find the optimal number of agents ('c') to minimize total cost.

Number of Agents (c) Total Service Capacity (cμ) Traffic Intensity (ρ = λ/(cμ)) Ls (Avg. Customers in System) Total Service Cost ($/hr) Total Waiting Cost ($/hr) Total Cost ($/hr)
5 100 1.0 (Unstable) - 100 - -
6 120 0.83 ~7.0 120 7.0 * 5 = 35 155
7 140 0.71 ~2.3 140 2.3 * 5 = 11.5 151.5
8 160 0.625 ~1.3 160 1.3 * 5 = 6.5 166.5

Note: Ls values are approximate and calculated using M/M/c formulas. For c=5, ρ=1 means the system is unstable and queue grows infinitely, so we start with c=6.

From the table, the minimum total cost occurs with 7 agents, where the total cost is approximately $151.50 per hour. Adding more agents increases service costs more than it reduces waiting costs. Having fewer than 7 agents leads to higher waiting costs due to longer queues and wait times.

Optimization Shortcut: Start by ensuring c > λ/μ for stability. Calculate total costs for a few values of 'c' around the point where is slightly larger than λ. The minimum cost is often found within this small range. Plotting cost vs. 'c' can visualize the optimal point.

Key Considerations in Cost Models

  • Accurate Estimation: The accuracy of the optimization heavily relies on the accurate estimation of service costs and waiting costs.
  • System Dynamics: Queuing models assume steady-state conditions. Real systems can have fluctuating arrival rates (e.g., peak hours) and service rates.
  • Customer Behavior: Models often assume customers will wait. In reality, customers might balk (not join the queue if it's too long) or renege (leave the queue after waiting for some time).
  • Server Availability: Models assume servers are always available. Breakdowns or idle time need to be factored in.

By understanding the principles of queuing theory and applying cost models, organizations can make informed decisions about resource allocation, service capacity, and operational efficiency to improve customer satisfaction and profitability.