Lectures 5 & 6
6.263/16.37
Introduction to Queueing Theory
Eytan Modiano
MIT, LIDS
Eytan Modiano
Slide 1
Packet Switched Networks
Packet Network
PS
PS
PS
PS
PS
PS
PS
Buffer
Packet
Switch
Messages broken into
Packets that are routed
To their destination
Eytan Modiano
Slide 2
Queueing Systems
? Used for analyzing network performance
? In packet networks, events are random
– Random packet arrivals
– Random packet lengths
? While at the physical layer we were concerned with bit-error-rate, at
the network layer we care about delays
– How long does a packet spend waiting in buffers ?
– How large are the buffers ?
? In circuit switched networks want to know call blocking probability
– How many circuits do we need to limit the blocking probability?
Eytan Modiano
Slide 3
Random events
? Arrival process
– Packets arrive according to a random process
– Typically the arrival process is modeled as Poisson
? The Poisson process
– Arrival rate of λ packets per second
– Over a small interval δ,
P(exactly one arrival) = λδ + ο(δ)
P(0 arrivals) = 1 - λδ + ο(δ)
P(more than one arrival) = 0(δ)
Where 0(δ)/ δ ?> 0 ?? δ ?> 0.
– It can be shown that:
P(n arrivalsininterval T)=
( λT )
n
e
?λT
n!
Eytan Modiano
Slide 4
The Poisson Process
P(n arrivalsininterval T)=
( λT )
n
e
?λT
n!
n = number of arrivals in T
It can be shown that,
E[n] = λT
E[n
2
] = λT + (λT)
2
σ
2
= E[(n -E[n])
2
] = E[n
2
] - E[n]
2
= λT
Eytan Modiano
Slide 5
Inter-arrival times
? Time that elapses between arrivals (IA)
P(IA <= t) = 1 - P(IA > t)
= 1 - P(0 arrivals in time t)
= 1 - e
-λt
? This is known as the exponential distribution
– Inter-arrival CDF = F
IA
(t) = 1 - e
-λt
– Inter-arrival PDF = d/dt F
IA
(t) = λe
-λt
? The exponential distribution is often used to model the service times (I.e.,
the packet length distribution)
Eytan Modiano
Slide 6
Markov property (Memoryless)
P(T ≤ t
0
+ t | T > t
0
) = P(T ≤ t)
Pr oof :
P(T ≤ t
0
+ t | T > t
0
) =
P(t
0
< T ≤ t
0
+ t)
P(T > t
0
)
t
0
+t
∫
λe
?λt
dt
?e
?λt
|
t
0
t
0
+ t
?e
?λ( t +t
0
)
+ e
?λ( t
0
)
t
0
= = =
∞
∞
e
?λ( t
0
)
∫
λe
?λt
dt
?e
?λt
|
t
0
t
0
= 1 ? e
?λt
= P(T ≤ t)
? Previous history does not help in predicting the future!
? Distribution of the time until the next arrival is independent of when the
last arrival occurred!
Eytan Modiano
Slide 7
Example
? Suppose a train arrives at a station according to a Poisson process
with average inter-arrival time of 20 minutes
? When a customer arrives at the station the average amount of time
until the next arrival is 20 minutes
– Regardless of when the previous train arrived
? The average amount of time since the last departure is 20 minutes!
? Paradox: If an average of 20 minutes passed since the last train
arrived and an average of 20 minutes until the next train, then an
average of 40 minutes will elapse between trains
– But we assumed an average inter-arrival time of 20 minutes!
– What happened?
Eytan Modiano
Slide 8
Properties of the Poisson process
? Merging Property
λ
1
λ
2
∑
λ
i
λ
k
Let A1, A2, … Ak be independent Poisson Processes
of rate λ1, λ2, …λk
A =
∑
A
i
is also Poisson of rate =
∑
λ
i
? Splitting property
– Suppose that every arrival is randomly routed with probability P to
stream 1 and (1-P) to stream 2
– Streams 1 and 2 are Poisson of rates Pλ and (1-P)λ respectively
P
1-P
λP
λ
λ(1?P)
Eytan Modiano
Slide 9
Queueing Models
Customers
Queue/buffer
? Model for
– Customers waiting in line
– Assembly line
– Packets in a network (transmission line)
? Want to know
– Average number of customers in the system
– Average delay experienced by a customer
? Quantities obtained in terms of
– Arrival rate of customers (average number of customers per unit time)
– Service rate (average number of customers that the server can serve
per unit time)
server
Eytan Modiano
Slide 10
Little’s theorem
Network (system)
(N,T)
λ packet per second
? N = average number of packets in system
? T = average amount of time a packet spends in the system
? λ = arrival rate of packets into the system
(not necessarily Poisson)
? Little’s theorem: N = λT
– Can be applied to entire system or any part of it
– Crowded system -> long delays
On a rainy day people drive slowly and roads are more congested!
Eytan Modiano
Slide 11
Proof of Little’s Theorem
α(t), β(t)
t1 t2 t3 t4
? ?α(t) = number of arrivals by time t
? β(t) = number of departures by time t
? t
i
= arrival time of i
th
customer
? T
i
= amount of time i
th
customer spends in the system
? N(t) = number of customers in system at time t = α(t) - β(t)
? Similar proof for non First-come-first-serve
α(t)
T1
T2
T3
T4
β(t)
Eytan Modiano
Slide 12
Proof of Little’s Theorem
t
1
N
t
=
∫
N (τ)dτ = timeave.numberof customersinqueue
t
0
N = Limit
t→∞
N
t
= steadystatetimeave.
λ
t
=α(t)/ t, λ = Limit
t→∞
λ
t
= arrival rate
α
∑
( t)
T
i
T
t
=
i= 0
α(t)
= timeave.systemdelay, T = Limit
t →∞
T
t
? Assume above limits exists, assume Ergodic system
α ( t)
N (t) =α(t) ?β(t ) ? N
t
=
∑
i=1
T
i
t
α (t ) α( t )
α ( t)
N = lim
t →∞
∑
i =1
T
i
, T = lim
t →∞
∑
i =1
T
i
?
∑
i=1
T
i
=α(t)T
t α(t)
α ( t) α ( t)
Eytan Modiano
N =
∑
i=1
T
i
= (
α(t)
)
∑
i=1
T
i
=λT
Slide 13
t t α(t)
Application of little’s Theorem
? Little’s Theorem can be applied to almost any system or part of it
? Example:
Customers
server
Queue/buffer
1) The transmitter: D
TP
= packet transmission time
– Average number of packets at transmitter = λD
TP
= ρ = link utilization
2) The transmission line: D
p
= propagation delay
– Average number of packets in flight = λD
p
3) The buffer: D
q
= average queueing delay
– Average number of packets in buffer = N
q
= λD
q
4) Transmitter + buffer
– Average number of packets = ρ + N
q
Eytan Modiano
Slide 14
Application to complex system
λ
1
λ
λ
2
3
λ
1
λ
2
λ
3
? We have complex network with several traffic streams moving through it
and interacting arbitrarily
? For each stream i individually, Little says N
i
= λ
i
T
i
? For the streams collectively, Little says N = λT where
? N = ∑
i
N
i
& λ = ∑
i
λ
i
i= k
? From Little's Theorem: T =
∑
i=1
λ
i
T
i
i= k
Eytan Modiano
∑
i=1
λ
i
Slide 15
Single server queues
buffer
λ packet per second
? M/M/1
Server
μ packet per second
Service time = 1/μ
– Poisson arrivals, exponential service times
? M/G/1
– Poisson arrivals, general service times
? M/D/1
– Poisson arrivals, deterministic service times (fixed)
Eytan Modiano
Slide 16
Markov Chain for M/M/1 system
λδ λδ λδ λδ
0 1 2
1?λδ
k
μδ μδ μδ μδ
? State k => k customers in the system
? P(I,j) = probability of transition from state I to state j
– As δ => 0, we get:
P(0,0) = 1 - λδ, P(j,j+1) = λδ
P(j,j) = 1 - λδ ?μδ P(j,j-1) = μδ
P(I,j) = 0 for all other values of I,j.
? Birth-death chain: Transitions exist only between adjacent states
– λδ, μδ are flow rates between states
Eytan Modiano
Slide 17
Equilibrium analysis
? We want to obtain P(n) = the probability of being in state n
? At equilibrium λP(n) = μP(n+1) for all n
– Local balance equations between two states (n, n+1)
– P(n+1) = (λ/μ)P(n) = ρP(n), ρ = λ/μ
? It follows: P(n) = ρ
n
P(0)
∑
i
∞
= 0
P(n) = 1
? Now by axiom of probability:
∞ P(0)
?
∑
i =0
ρ
n
P(0) =
1? ρ
= 1
? P(0) = 1 ?ρ
P(n) = ρ
n
(1 ? ρ)
Eytan Modiano
Slide 18
Average queue size
∞ ∞
N =
∑
nP(n) =
∑
nρ
n
(1 ?ρ) =
ρ
n=0 n=0
1? ρ
N =
ρ
=
λ / μ
=
λ
1 ?ρ 1 ?λ /μ μ?λ
? N = Average number of customers in the system
? The average amount of time that a customer spends in the
T =
1
system can be obtained from Little’s formula (N=λT => T = N/λ)
μ?λ
? T includes the queueing delay plus the service time (Service time
= D
TP
= 1/μ )
1
– W = amount of time spent in queue = T - 1/μ =>
W =
μ? λ
?
1
μ
? Finally, the average number of customers in the buffer can be
obtained from little’s formula
λ
N
Q
= λW =
μ?λ
?
λ
= N ? ρ
μ
Eytan Modiano
Slide 19
Example (fast food restaurant)
? Customers arrive at a fast food restaurant at a rate of 100 per hour
and take 30 seconds to be served.
? How much time do they spend in the restaurant?
– Service rate = μ = 60/0.5=120 customers per hour
– T = 1/μ?λ = 1/(120-100) = 1/20 hrs = 3 minutes
? How much time waiting in line?
– W = T - 1/μ = 2.5 minutes
? How many customers in the restaurant?
– N = λT= 5
? What is the server utilization?
– ρ = λ/μ = 5/6
Eytan Modiano
Slide 20
Packet switching vs. Circuit switching
1
λ/M
λ/M
N
λ/M
1 2 3 M 1 2 3 M
TDM, Time Division Multiplexing
Each user can send μ/N packets/sec and
has packet arriving at rate λ/N packets/sec
D = M /μ+
M (λ / μ)
M/M/1
(μ?λ)
formula
Packets generated at random times
λ/M
λ
Buffer
μ packets/sec
Statistical
Mutliplexer
D = 1/μ+
( λ / μ)
M/M/1
λ/M
(μ?λ)
formula
Eytan Modiano
Slide 21
2
Circuit (tdm/fdm) vs. Packet switching
Average Packet Service Time
(slots)
1
10
100
0 0.2 0.4 0.6 0.8 1
Total traffic load, packets per slot
A
v
er
ag
e S
e
r
v
i
c
e T
i
m
e
TDM with 20
sources
Ideal Statistical
Multiplexing
(M/D/1)
Eytan Modiano
Slide 22
M server systems: M/M/m
buffer
λ packet per second
Server
M servers
μ packet per
second, per
server
? Departure rate is proportional to the number of servers in use
? Similar Markov chain:
λδ λδ λδ
m
λδ
m+1
λδ
0 1 2
1?λδ
μδ 2μδ 3μδ mμδ mμδ
Server
Eytan Modiano
Slide 23
?
?
? ?
M/M/m queue
λP(n ? 1) = nμP(n) n ≤ m
? Balance equations:
λP(n ? 1) = mμP(n) n > m
?
P(0)( mρ)
n
/ n! n ≤ m
, ρ =
λ
≤ 1P(n ) =
?
?
P(0)( m
m
ρ
n
)/ m! n > m
mμ
? Again, solve for P(0):
?
m ?1
(mρ)
n
( mρ)
m
?
?1
P(0) =
?
?
∑
n =0
n!
+
m!(1? ρ)
?
?
n=∞
P
Q
=
∑
P( n) =
P(0)(mρ)
m
n= m
m!(1 ? ρ)
n=∞ n=∞ m + n
ρ
N
Q
=
∑
nP(n + m) =
∑
nP(0)(
m
m
ρ
) = P
Q
(
1 ?ρ
)
n=0 n =0
m!
W =
N
λ
Q
, T = W + 1/ μ, N =λT =λ / μ+ N
Q
Eytan Modiano
Slide 24
Applications of M/M/m
? Bank with m tellers
? Network with parallel transmission lines
m lines, each of rate μ
Use
λ
Node
A
Node
B
M/M/m
formula
VS
One line of rate mμ
Use
λ
Node
A
Node
B
M/M/1
formula
? When the system is lightly loaded, PQ~0, and Single server is m times faster
? When system is heavily loaded, queueing delay dominates and systems are
roughly the same
Eytan Modiano
Slide 25
M/M/Infinity
? Unlimited servers => customers experience no queueing delay
? The number of customers in the system represents the number of
customers presently being served
λδ λδ λδ
n
λδ
n+1
λδ
0 1 2
1?λδ
μδ 2μδ 3μδ nμδ (n+1)μδ
λP(n ? 1) = nμP(n), ?n > 1, ? P( n) =
P(0)(λ / μ)
n
n!
∞
?1
P(0) =
[
1 +
∑
n=1
(λ / μ)
n
/ n!
]
= e
?λ / μ
P(n ) = (λ / μ)
n
e
?λ/ μ
/ n! => Poissondistribution!
N = Averagenumberinsystem =λ /μ, T = N /λ =1/ μ= servicetime
Eytan Modiano
Slide 26
Blocking Probability
? A circuit switched network can be viewed as a Multi-server
queueing system
– Calls are blocked when no servers available - “busy signal”
– For circuit switched network we are interested in the call blocking
probability
? M/M/m/m system
– m servers => m circuits
– Last m indicated that the system can hold no more than m users
? Erlang B formula
– Gives the probability that a caller finds all circuits busy
– Holds for general call arrival distribution (although we prove
Markov case only)
P
B
=
∑
(
m
λ / μ)
m
/ m!
n= 0
(λ / μ)
n
/ n!
Eytan Modiano
Slide 27
M/M/m/m system: Erlang B formula
λδ λδ λδ λδ
0 1 2
1?λδ
m
μδ 2μδ 3μδ mμδ
λP(n ? 1) = nμP(n ), 1 ≤ n ≤ m, ? P(n) =
P(0)( λ / μ)
n
n!
?1
m
P(0) =
[
∑
n= 0
(λ /μ)
n
/ n!
]
P
B
= P( Blocking) = P(m) =
(
m
λ/ μ)
m
/ m!
∑
n= 0
(λ / μ)
n
/ n!
Eytan Modiano
Slide 28
Erlang B formula
? System load usually expressed in Erlangs
– A= λ/μ = (arrival rate)*(ave call duration) = average load
P
B
=
(
m
A)
m
/ m!
– Formula insensitive to λ and μ but only to their ratio
∑
n= 0
( A)
n
/ n!
? Used for sizing transmission line
– How many circuits does the satellite need to support?
– The number of circuits is a function of the blocking probability that we can tolerate
Systems are designed for a given load predictions and blocking probabilities (typically small)
? Example
– Arrival rate = 4 calls per minute, average 3 minutes per call => A = 12
– How many circuits do we need to provision?
Depends on the blocking probability that we can tolerate
Circuits P
B
20 1%
15 8%
7 30%
Eytan Modiano
Slide 29
Multi-dimensional Markov Chains
? K classes of customers
– Class j: arrival rate λ
j
; service rate μ
j
? State of system: n = (n1, n2, …, nk); nj = number of class j customers in
the system
? If detailed balance equations hold for adjacent states, then a product form
solution exists, where:
– P(n,.n2, …, nk) = P
1
(n1)*P
2
(n2)*…*P
k
(nk)
? Example: K independent M/M/1 systems
P
i
(n
i
) = ρ
i
n
i
(1 ?ρ
i
), ρ
i
=λ
i
/ μ
i
? Same holds for other independent birth-death chains
– E.g., M.M/m, M/M/Inf, M/M/m/m
Eytan Modiano
Slide 30
Truncation
? Eliminate some of the states
– E.g., for the K M/M/1 queues, eliminate all states where n1+n2+…+nk > K1 (some constant)
? Resulting chain must remain irreducible
– All states must communicate
Product form for stationary distribution of the truncated system
? E.g., K independent M/M/1 queues
nK
nK
P(n
1
, n
2
,...n
k
) =
ρ
1
n1
ρ
2
n2
....ρ
K
, G =
∑
ρ
n1
ρ
2
n2
....ρ
K1
G
n∈S
? E.g., K independent M/M/inf queues
P(n
1
, n
2
,...n
k
) =
(ρ
1
n1
/ n
1
!)(ρ
2
n2
/ n
2
!)....(ρ
K
nK
/ n
k
!)
G
nK
/ n
k
!)
, G =
∑
(ρ
1
n1
/ n
1
!)(ρ
n2
/ n
2
!)....(ρ
K2
n∈S
– G is a normalization constant that makes P(n) a distribution
– S is the set of states in the truncated system
Eytan Modiano
Slide 31
Example
? Two session classes in a circuit switched system
– M channels of equal capacity
– Two session types:
Type 1: arrival rate λ1 and service rate μ1
Type 2: arrival rate λ2 and service rate μ2
? System can support up to M sessions of either class
– If μ1= μ2, treat system as an M/M/m/m queue with arrival rate λ1+ λ2
– When μ1=! μ2 need to know the number of calls in progress of each session type
– Two dimensional markov chain state = (n1, n2)
– Want P(n1, n2): n1+n2 <=m
? Can be viewed as truncated M/M/Inf queues
– Notice that the transition rates in the M/M/Inf queue are the same as those in a
truncated M/M/m/m queue
i = m
j = m ?i
P(n
1
, n
2
) =
(ρ
1
n1
/ n
1
!)(ρ
2
n2
/ n
2
!)
, G =
∑ ∑
(ρ
i
/ i!)(ρ
2
j
/ j!), n1+ n2≤ m
1
G
i =0 j =0
– Notice that the double sum counts only states for which j+i <= m
Eytan Modiano
Slide 32
PASTA: Poisson Arrivals See Time Averages
? The state of an M/M/1 queue is the number of customers in the system
? More general queueing systems have a more general state that may
include how much service each customer has already received
? For Poisson arrivals, the arrivals in any future increment of time is
independent of those in past increments and for many systems of interest,
independent of the present state S(t) (true for M/M/1, M/M/m, and M/G/1).
? For such systems, P{S(t)=s|A(t+δ)-A(t)=1} = P{S(t)=s}
– (where A(t)= # arrivals since t=0)
? In steady state, arrivals see steady state probabilities
Eytan Modiano
Slide 33
Occupancy distribution upon arrival
? Arrivals may not always see the steady-state averages
? Example:
– Deterministic arrivals 1 per second
– Deterministic service time of 3/4 seconds
λ = 1 packets/second T = 3/4 seconds (no queueing)
N = λT = Average occupancy = 3/4
? However, notice that an arrival always finds the system empty!
Eytan Modiano
Slide 34
Occupancy upon arrival for a M/M/1 queue
a
n
= Lim
t-> inf
(P (N(t) = n | an arrival occurred just after time t))
P
n
= Lim
t-> inf
(P(N(t) = n))
For M/M/1 systems a
n
= P
n
Proof: Let A(t, t+δ) be the event that and arrival occurred between t and t+δ
a
n
(t) = Lim
t-> inf
(P (N(t) = n| A(t, t+δ) )
= Lim
t-> inf
(P (N(t) = n, A(t, t+δ) )/P(A(t, t+δ) )
= Lim
t-> inf
P(A(t, t+δ)| N(t) = n)P(N(t) = n)/P(A(t, t+δ) )
? Since future arrivals are independent of the state of the system,
P(A(t, t+δ)| N(t) = n)= P(A(t, t+δ))
? Hence, a
n
(t) = P(N(t) = n) = P
n
(t)
? Taking limits as t-> infinity, we obtain a
n
= P
n
? Result holds for M/G/1 systems as well
Eytan Modiano
Slide 35