02 Queueing Fundamental Laws
02 Queueing Fundamental Laws
Spring 2022
Alaa Alameldeen
2
Queuing Notation
• A service facility can be modelled by a Queuing system consisting
of: S
A
1. Arrival process A
2. Service time distribution S
m=1
3. Number of servers m
4. System capacity (number of buffers) B
5. Population size K
6. Service discipline SD
• This is usually expressed using the Kendall notation:
A/S/m/B/K/SD
3
Arrival Process
• Arrival times of customers are t1, t2, …., tN
• Interarrival times: i = ti – ti-1, i = 2, 3, …, N
𝒊=𝟏 𝒊
σ𝑵
• Mean interarrival time =
𝑵
• Mean arrival rate : Number of arrivals per unit of time (e.g., second)
𝑵 𝟏
= σ𝑵 =
𝒊=𝟏 𝒊 𝒎𝒆𝒂𝒏 𝒊𝒏𝒕𝒆𝒓𝒂𝒓𝒓𝒊𝒗𝒂𝒍 𝒕𝒊𝒎𝒆
6
Distributions for Interarrival and Service Times
• M Exponential
➢ Memoryless distribution: if interarrival times are exponentially distributed with mean µ=1/ then time to
next arrival is µ= 1/ independent of time since last arrival
−𝑥/µ
PDF: f(x) = e -x = 𝑒 ൗµ f(x)
➢ Mean: µ=1/ ; variance: 1/2
• Ek Erlang with parameter k
➢ A distribution of a sum of k independent exponential variables, x
each with a mean of 1/ .
f(x) = k xk-1 e -x / (k-1)!
➢ Mean: : k/ ; variance: k/2
➢ When k=1, it’s the same as the exponential distribution
• D Deterministic (constant times, variance = 0)
• G General (distribution not specified)
• For a system with infinite capacity B, infinite population K, and FCFS service discipline:
M/M/m///FCFS or M/M/m in short
Arrival Distribution (Exponential) / Service Distribution (Exponential) / # of servers / Capacity / Population / Service Discipline
7
Common Random Variables
• : Interarrival time
• : Mean arrival rate
• 1/: Mean interarrival time
• s: Service time per job (customer)
• µ: Mean service rate per server
• 1/µ: Mean service time per server
• nq: Number of jobs (customers) waiting for service (waiting in queue)
• ns: Number of jobs (customers) receiving service
• n = nq + ns : Number of jobs (customers) in system
• w: Waiting time (queuing delay)
• r: Response (Residence) time = time in system = w + s
• U: Utilization (time in use / total time)
8
Impact of Utilization on Open Queues
• Example: Single-server open queue
10
Definitions
Completions
• In this abstract system: Arrivals
System
➢T: Length of time we observe system
➢A: Observed number of request arrivals
➢C: Observed number of request completions
➢B: Length of time a resource is busy (for systems with a single resource/server)
𝑨
• Mean Arrival rate =
𝑻
𝑪
• Throughput X =
𝑻
𝑩
• Utilization U =
𝑻
𝑩
• Average Service Time per request S =
𝑪
11
The Utilization Law
𝑩 Arrivals Completions
System
Since U = ;
𝑻
𝑪 𝑩
X= ; S=
𝑻 𝑪
Utilization Law: U = 𝑿𝑺
12
Utilization Law: Example 1
• An online warehouse has a throughput of 12,000 transactions
per second. Each transaction requires 10 microseconds of
service on average. What is the fraction of time that the
warehouse is utilized?
X = 12,000 transactions / second
S = 10 microseconds = 10 x 10-6 seconds
U = X S = 12,000 x 10 x 10-6 = 0.12 = 12%
• At any point in time, the distance between the arrivals and completions
functions is the number of requests in the system
• Over any time interval, the area between arrival and completion functions
is the accumulated time (W) in the system during that interval
Example: Shaded area represents the accumulated time W=2 between T=2
and T=6
𝑾
• From W’s definition: Average number of requests in the system N =
𝑻
1 Named after MIT Professor John Little who formulated the law in 1954 15
Little’s Law
• Can be applied to any system with very few assumptions
➢Can help check consistency of measurement data
• Can help figure out any of the three values if we know the
other two:
➢ N = XR; R = N/X; X = N/R
• Can be applied to different levels in a system
➢A single resource
➢A subsystem
➢The whole system
16
Little’s Law: Example 1
• In a convenience store with a single checkout counter, 40
customers are served every hour on average, and each customer
stays in the store 6 minutes on average. What is the average
number of customers in the store at any point during that hour?
X = 40 customers / hour
R = 6 minutes = 0.1 hours
N = X R = 40 x 0.1 = 4 customers
N = 1000 cars
X = 800 cars/minute
R = N / X = 1000 / 800 = 1.25 minutes = 75 seconds
Wait time = Response time – Service time ( since R = w + s )
(important formula)
= 75 – 10 = 65 seconds
20
Little’s Law: Example 5
• A computer system with a single CPU runs sequential programs with variable service time
requirements. For example, programs can have total runtimes of 5, 0.2, 30, 5000 milliseconds.
Prove that the “Shortest Job First” scheduling algorithm leads to the minimum average response
time per program.
Assume we have P programs to run, and the total runtime to run them all is T. Assume the programs run in
the order t1, t2, … , tp
T = σ𝑷
𝒊=𝟏 𝒕𝒊 Where ti is the runtime for program i
System throughput X = total programs / total time = P/T
Response time per program i = 𝑹𝒊 = σ𝒊𝒋=𝟏 𝒕𝒋
𝒊
σ𝑷
𝒊=𝟏 𝑿 𝑹𝒊
𝑿 σ𝑷
𝒊=𝟏 σ𝒋=𝟏 𝒕𝒋
Average number of programs in system N = =
𝑷 𝑷
𝑿
= 𝑷 𝒕𝟏 + 𝒕𝟏 + 𝒕𝟐 + 𝒕𝟏 + 𝒕 𝟐 + 𝒕𝟑 + ⋯ + 𝒕𝟏 + 𝒕𝟐 + … + 𝒕𝑷
𝑿
= 𝑷𝒕𝟏 + 𝑷 − 𝟏 𝒕𝟐 + ⋯ + 𝒕𝑷
𝑷
𝑵 𝟏
Average response time per program R = 𝑿
= 𝑷 𝑷𝒕𝟏 + 𝑷 − 𝟏 𝒕𝟐 + ⋯ + 𝒕𝑷
21
Little’s Law: Example 5 (Cont)
𝑵 𝟏
Average response time per program R = = 𝑷𝒕𝟏 + 𝑷 − 𝟏 𝒕𝟐 + ⋯ + 𝒕𝑷
𝑿 𝑷
Assume ti’s are ordered from smallest to largest leading to Response time RSJF.
That is, for every k > j : tk ≥ tj
For any other order O of ti’s (say switch tj and tk where k > j) Response time RO
𝟏 𝟏
= RSJF – 𝑷 − 𝒋 + 𝟏 𝒕𝒋 + 𝑷 − 𝒌 + 𝟏 𝒕𝒌 + 𝑷 − 𝒌 + 𝟏 𝒕𝒋 + 𝑷 − 𝒋 + 𝟏 𝒕𝒌
𝑷 𝑷
𝟏
= RSJF + 𝒌 − 𝒋 𝒕𝒌 − 𝒌 − 𝒋 𝒕𝒋
𝑷
𝟏
= RSJF + 𝒌 − 𝒋 (𝒕𝒌 −𝒕𝒋
𝑷
Since k > j and tk ≥ tj and P ≥ 1
Therefore for any other order O except SJF: RSJF ≤ RO
22
Little’s Law with Think Time servers
.
(Think) Centers
.
.
Little’s Law: N = 𝑿𝑹
servers
.
(Think).Centers
.
.
(Think) Centers
.
.
25
Response Time Law: Example 1
• A web server serves a total of 1 million subscribers to a streaming
service. The server completes 20,000 requests per hour on
average. Each subscriber, on average, waits two days after
finishing one request before requesting service again. What is the
average response time for each request?
N = 1,000,000 customers .
.
X = 20,000 requests/hour .
Z = 48 hours
R = N / X - Z = 1,000,000 / 20,000 - 48 = 2 hours
26
Response Time Law: Example 2
• A hotel has an open buffet restaurant that serves breakfast between 6 AM and 9
AM daily. On average, 80% of all hotel guests eat breakfast at the restaurant.
Each guest, on average, spends 30 minutes per day at the restaurant during
breakfast hours. The restaurant serves 200 guests per hour on average during
breakfast hours. What is the average number of guests staying at the hotel?
X = 200 guests/hour
R = 0.5 hours .
Z = 2.5 hours (time not at restaurant) .
.
N = X (R + Z) = 200 x (0.5 + 2.5) = 600 guests
Since N represents 80% of hotel guests, total guests = 600 x 100/80 = 750
27
Response Time Law: Example 3
• A cloud service provider has an average CPU utilization of 60%
across all CPUs in its data center. Each job has an average service
requirement of 30 microseconds. The response time for each job is
0.2 seconds. The system has 1,000,000 users on average. What is
the average think time per user?
.
N = 1,000,000 users, R = 0.2 seconds .
S = 30 x 10-6 seconds, U = 0.6 .
28
Fundamental Laws Recap
𝑩 𝑩
Mean Arrival rate = 𝑨/𝑻 Throughput X = 𝑪/𝑻 Utilization U = Average Service Time per request S =
𝑻 𝑪
Utilization Law: U = 𝑿𝑺
Little’s Law: N = 𝑿𝑹
servers
.
(Think) Centers
.
.
• In a system where customers may receive service from different resources, potentially
more than once, before leaving system
If Vk is the visit count of resource k
𝑪𝒌
𝑽𝒌 = (Completions at resource k as a ratio of all system completions)
𝑪
which can be rewritten as: 𝑪𝒌 = 𝑽𝒌 𝑪
Since throughput X is the number of completions over an observed time interval:
31
Forced Flow Law: Example 1
• A database system is limited by disk accesses. The system has one disk that is
busy 40% of the time on average. Each transaction requires 50 disk accesses
on average, with an average service time of 5 milliseconds per access. How
many transactions per minute are executed on this database system?
Udisk = 40% = 0.4
Sdisk = 5 ms; Vdisk = 50
Ddisk = Vdisk Sdisk = 50 x 5 ms = 250 ms = 0.25 seconds
Since Udisk = Ddisk X
X = Udisk / Ddisk = 0.4 / 0.25 = 1.6 transactions/second
= 1.6 x 60 = 96 transactions/minute
• In a balanced system, we can assume that the number of arrivals is the same as the
number of completions over time
36
Demo of Unstable System
• An open system with a single server has a fixed arrival rate of 1 customer/second, and a
service rate of one customer every 2 seconds
Time Event N (#Customers in R (Response Time for departing
System) customer)
1 Cust 1 arrives 1
2 Cust 2 arrives 2
3 Cust 3 arrives, Cust 1 departs 2 2
4 Cust 4 arrives 3
5 Cust 5 arrives, Cust 2 departs 3 3
6 Cust 6 arrives 4
7 Cust 7 arrives, Cust 3 departs 4 4
8 Cust 8 arrives 5
9 Cust 9 arrives, Cust 4 departs 5 5