Anda di halaman 1dari 44

Queuing Analysis:

M/M/* Queues

Hongwei Zhang
http://www.cs.wayne.edu/~hzhang

Acknowledgement: this lecture is partially based on the slides of Dr. Yannis A. Korilis.
Outline

 M/M/1 Queue
 Poisson Arrivals See Time Averages (PASTA)
 M/M/* Queues
 Introduction to Sojourn Times
Outline

 M/M/1 Queue
 Poisson Arrivals See Time Averages (PASTA)
 M/M/* Queues
 Introduction to Sojourn Times
The M/M/1 Queue
 Arrival process: Poisson with rate λ
 Service times: iid, exponential with parameter µ
 Service times and interarrival times: independent
 Single server
 Infinite waiting room
 N(t): Number of customers in system at time t (state)
λ λ λ λ

0 1 2 n n+1
µ µ µ µ
Exponential Random Variables
 X: exponential RV with Proof:
parameter λ P{min{ X , Y } > t} = P{ X > t , Y > t} =
= P{ X > t}P{Y > t} =
 Y: exponential RV with = e − λt e − µ t = e − ( λ + µ ) t ⇒
parameter µ P{min{ X , Y } ≤ t} = 1 − e− ( λ + µ )t

X, Y:: independent P{ X < Y } = ∫


∞ y

0 ∫
0
f XY ( x, y ) dx dy =
∞ y
Then: =∫ ∫ λ e− λ x ⋅ µ e− µ y dx dy =
0 0
∞ y
1. min{X, Y}: exponential RV with = ∫ µ e− µ y ∫ λ e− λ x dx dy =
0 0

parameter λ+µ = ∫ µ e− µ y (1 − e− λ y ) dy =
0
∞ µ ∞
= ∫ µ e− µ y dy −
λ+µ ∫
2. P{X<Y} = λ/(λ+µ) (λ + µ )e− ( λ + µ ) y dy =
0 0

µ λ
=1− =
λ+µ λ+µ
M/M/1 Queue: Markov Chain Formulation
 Jumps of {N(t): t ≥ 0} triggered by arrivals and departures
{N(t): t ≥ 0} can jump only between neighboring states

Assume process at time t is in state i: N(t) = i ≥ 1


 Xi: time until the next arrival – exponential with parameter λ
 Yi: time until the next departure – exponential with parameter µ
 Ti =min{Xi,Yi}: time process spends at state i
 Ti : exponential with parameter νi= λ+µ
 Pi,i+1=P{Xi < Yi}= λ/(λ+µ), Pi,i-1=P{Yi < Xi}= µ/(λ+µ)
 P01=1, and T0 is exponential with parameter λ
qi ,i +1 = ν i Pi ,i +1 = λ , i ≥ 0
{N(t): t ≥ 0} is a continuous-time Markov chain with qi ,i −1 = ν i Pi ,i −1 = µ , i ≥ 1
qij = 0, | i − j |> 1
M/M/1 Queue: Stationary Distribution?
λ λ λ λ

0 1 2 n n+1
µ µ µ µ

 Birth-death process → DBE


µ pn = λ pn −1 ⇒
λ
pn = pn −1 = ρ pn −1 = ... = ρ n p0
µ

 Normalization constant

 ∞
n

n=0
pn = 1 ⇔ p0 1 + ∑ ρ
 n =1 
 = 1 ⇔ p0 = 1 − ρ , if ρ < 1

 Stationary distribution
pn = ρ n (1 − ρ ), n = 0,1,...
M/M/1 Queue (contd.)
 Average number of customers in system?
∞ ∞ ∞
N = ∑ npn = (1 − ρ )∑ n ρ =(1 − ρ ) ρ ∑ n ρ n −1
n

n=0 n=0 n =0

1 ρ λ
⇒ N = ρ (1 − ρ ) = =
(1 − ρ ) 2 1 − ρ µ − λ
 Little’s Theorem: average time in system?
N 1 λ 1
T= = =
λ λ µ −λ µ −λ
 Average waiting time and number of customers in the queue –
excluding service?

1 ρ ρ2
W =T − = and N Q = λW =
µ µ −λ 1− ρ
M/M/1 Queue (contd.)

 ρ=λ/µ: utilization factor 10

 => ρ=1-p0 8

 holds for any M/G/1 queue 6

too

N
4

 Long term proportion of time 2

that server is busy 0


0 0.2 0.4 0.6 0.8 1
ρ

 Stability condition: ρ<1


 Arrival rate should be less
than the service rate
M/M/1 Queue: Discrete-Time Approach
 Focus on times 0, δ, 2δ,… (δ arbitrarily small)
 Study discrete time process Nk = N(δk)
lim P{N (t ) = n} = lim P{N k = n}
t →∞ k →∞

Transition probabilities?
P00 = 1 − λδ + ο (δ )
Pii = 1 − λδ − µδ + ο (δ ), i ≥ 1
Pi ,i +1 = λδ + ο (δ ), i≥0
Pi ,i −1 = µδ + ο (δ ), i≥0
Pij = ο (δ ), |i − j |> 1
 Discrete time Markov chain, omitting o(δ)
λδ λδ λδ λδ

0 1 2 n n+1
µδ µδ µδ µδ
1 − λδ 1 − λδ − µδ 1 − λδ − µδ 1 − λδ − µδ
M/M/1 Queue: Discrete-Time Approach
λδ λδ λδ λδ

0 1 2 n-1 n
µδ µδ µδ µδ
1 − λδ 1 − λδ − µδ 1 − λδ − µδ 1 − λδ − µδ

 Discrete-time birth-death process → DBE:


[ µδ + ο (δ )]π n = [λδ + ο (δ )]π n −1 ⇒
n
λδ + ο (δ )  λδ + ο (δ ) 
πn = π n −1 = L =   π0
µδ + ο (δ )  µδ + ο (δ ) 

 Taking the limit δ→0:


n n
 λδ + ο (δ )  λ
lim π n = lim  lim π ⇒ p =  µ  p0
δ →0 µδ + ο (δ )  δ →0
0 n
δ →0
   

Done!
Transition Probabilities?
 Ak: number of customers that arrive in Ik=(kδ, (k+1)δ]
 Dk: number of customers that depart in Ik=(kδ, (k+1)δ]
 Transition probabilities Pij depend on conditional probabilities: Q(a,d | n)
= P{Ak=a, Dk=d | Nk-1=n}
 Calculate Q(a,d | n) using arrival and departure statistics
 Use Taylor expansion e-λδ=1-λδ+o(δ), e-µδ=1-µδ+o(δ), to express as a
function of δ
 Poisson arrivals: P{Ak ≥ 2}=o(δ)
 Probability there are more than 1 arrivals in Ik is o(δ)
 Show: probability of more than one event (arrival or departure) in Ik is
o(δ)
☺ See details in textbook
Example: Slowing Down
µ µ/m
λ λ /m

ρ λ/µ λ ρ′ λ/µ λ
N= = = N′ = = = =N
1− ρ 1− λ / µ µ − λ 1− ρ′ 1− λ / µ µ − λ
N 1 N′ m
T= = T′ = = = mT
λ µ −λ λ /m µ −λ
ρ λ/µ ρ′ m(λ / µ )
W= = W′ = = = mW
µ −λ µ −λ µ /m −λ /m µ −λ

 M/M/1 system: slow down the arrival and service rates by the same factor m
 Utilization factors are the same ⇒stationary distributions the same, average
number in the system the same
 Delay in the slower system is m times higher
 Average number in queue is the same, but in the 1st system the customers move out
faster
Example: Statistical Multiplexing vs. TDM
µ/m
λ /m
µ
λ
m
µ/m
λ /m

m
T′ = = mT
µ −λ

 m identical Poisson streams with rate λ/m; link with capacity 1; packet lengths iid,
exponential with mean 1/µ
 Alternative: split the link to m channels with capacity 1/m each, and dedicate one
channel to each traffic stream
 Delay in each “queue” becomes m times higher
Statistical multiplexing vs. TDM or FDM
When is TDM or FDM preferred over statistical multiplexing?
Outline

 M/M/1 Queue
 Poisson Arrivals See Time Averages (PASTA)
 M/M/* Queues
 Introduction to Sojourn Times
“PASTA” Theorem
 Markov chain: “stationary” or “in steady-state:”
 Process started at the stationary distribution, or
 Process runs for an infinite time t→∞

Probability that at any time t, process is in state i is equal to


the stationary probability
Ti (t )
pi = lim P{N (t ) = i} = lim
t →∞ t →∞ t

 Question: For an M/M/1 queue: given t is an arrival time,


what is the probability that N(t)=i?
Answer: Poisson Arrivals See Time Averages (PASTA)!
PASTA Theorem (contd.)
 Steady-state probabilities:
pn = lim P{N (t ) = n}
t →∞

 Steady-state probabilities upon arrival:


an = lim P{N (t − ) = n | arrival at t}
t →∞

 Lack of Anticipation Assumption (LAA): Future inter-arrival times


and service times of previously arrived customers are independent

Theorem: In a queueing system satisfying LAA:


1. If the arrival process is Poisson:
an = pn , n = 0,1,...
2. Poisson is the only process with this property
(necessary and sufficient condition)
PASTA Theorem (contd.)

Doesn’t PASTA apply for all arrival processes?


 Deterministic arrivals every 10 sec
 Deterministic service times 9 sec
Upon arrival: system is always empty a1=0
Average time with one customer in system: p1=0.9

1
0 9 10 20 30 30 39

 “Customer” averages need not be time averages


 Randomization does not help, unless Poisson!
PASTA Theorem: Proof
 Define A(t,t+δ), the event that an arrival occurs in [t, t+ δ)
 Given that a customer arrives at t, probability of finding the system in
state n:
P{N (t − ) = n | arrival at t} = lim P{N (t − ) = n | A(t , t + δ )}
δ →0
 A(t,t+δ) is independent of the state before time t, N(t-)
 N(t-) determined by arrival times <t, and corresponding service times
 A(t,t+δ) independent of arrivals <t [Poisson]
 A(t,t+δ) independent of service times of customers arrived <t [LAA]
P{N (t − ) = n, A(t , t + δ )}
=> −
an (t ) = lim P{N (t ) = n | A(t , t + δ )} = lim
δ →0 δ →0 P{ A(t , t + δ )}
P{N (t − ) = n}P{ A(t , t + δ )}
= lim = P{N (t − ) = n}
δ →0 P{ A(t , t + δ )}

an = lim an (t ) = lim P{N (t − ) = n} = pn


t →∞ t →∞
PASTA Theorem: Intuitive Proof
 ta and to : randomly selected arrival and observation times, respectively
 The arrival processes prior to ta and to respectively are stochastically
identical
 The probability distributions of the time to the first arrival before ta and to
are both exponentially distributed with parameter λ (why?)
 Extending this to the 2nd, 3rd, etc. arrivals before ta and to establishes the
result
 State of the system at a given time t depends only on the arrivals (and
associated service times) before t
Since the arrival processes before arrival times and random times are
identical, so is the state of the system they see
Arrivals that Do not See Time-Averages
Example 1: Non-Poisson arrivals
 IID inter-arrival times, uniformly distributed between in 2 and 4 sec
 Service times deterministic 1 sec
Upon arrival: system is always empty
λ=1/3, T=1 → N=T/λ=1/3 → p1=1/3

Example 2: LAA violated


 Poisson arrivals
 Service time of customer i: Si= αTi+1, α < 1
Upon arrival: system is always empty
Average time the system has 1 customer: p1= α
Distribution after Departure
 Steady-state probabilities after departure:

d n = lim P{ X (t + ) = n | departure at t}
t →∞
 Under very general assumptions:
 N(t) changes in unit increments
 limits an and dn exist (i.e., system reaches steady state with all n
having positive steady-state distribution)
an = dn, n=0,1,…
=> In steady-state, system appears stochastically identical to an arriving and
departing customer
 Poisson arrivals + LAA: an arriving and a departing customer see a
system that is stochastically identical to the one seen by an observer
looking at an arbitrary time
Outline

 M/M/1 Queue
 Poisson Arrivals See Time Averages (PASTA)
 M/M/* Queues
 Introduction to Sojourn Times
M/M/* Queues
 Poisson arrival process
 Interarrival times: iid, exponential
 Service times: iid, exponential
 Service times and interarrival times: independent
 N(t): Number of customers in system at time t (state)

{N(t): t ≥ 0} can be modeled as a continuous-time Markov chain


Transition rates depend on the characteristics of the system
PASTA Theorem always holds
M/M/1/K Queue
λ λ λ λ

0 1 2 K-1 K
µ µ µ µ

 M/M/1 with finite waiting room


 At most K customers in the system
 Customer that upon arrival finds K customers in system is dropped
n
 Stationary distribution: pn = ρ p0 , n = 1, 2,..., K
1− ρ
p0 =
1 − ρ K +1
 Stability condition: always stable – even if ρ≥1
 Probability of loss – using PASTA theorem:
ρ K (1 − ρ )
P{loss} = P{N (t ) = K } =
1 − ρ K +1
M/M/1/K Queue (proof)
λ λ λ λ

0 1 2 K-1 K
µ µ µ µ
 Exactly as in the M/M/1 queue:
pn = ρ n p0 , n = 1, 2,..., K

 Normalization constant:
K K
1 − ρ K +1

n =0
pn = 1 ⇒ p0 ∑ ρ = 1 ⇒ p0
n =1
n

1− ρ
=1
1− ρ
⇒ p0 =
1 − ρ K +1

Generalize: Truncating a Markov chain


Truncating a Markov Chain
 {X(t): t ≥ 0} continuous-time Markov chain with stationary distribution
{pi: i=0,1,…}
 S a subset of {0,1,…}: set of states; Observe process only in S
 Eliminate all states not in S
 Set q% ji = q%ij = 0, j ∈ S , i ∉ S

 {Y(t): t ≥ 0}: resulting truncated process; If irreducible:


 Continuous-time Markov chain
 Stationary distribution  pj
 p if j ∈ S
p% j =  ∑ i
i∈S

 0 if j ∉ S
Truncating a Markov Chain: proof
 Possible sufficient condition (GBE)
p j ∑ q ji = ∑ pi qij , j∈S
i∉S i∉S

 Verify that distribution of truncated process


1. Satisfies the GBE
pj pi
p j ∑ q ji = ∑ pi qij ⇒ p j ∑ q ji = ∑ pi qij ⇒ ∑ q ji = ∑ qij
i i i∈S p( S ) i∈S
i∈S i∈S p( S )
⇒ p% j ∑ q ji = ∑ p% i qij ⇒ p% j ∑ q% ji = ∑ p% i q%ij , j ∈ S
i∈S i∈S i∈S i∈S

2. Satisfies the probability conservation law:


pi p( S )
∑ p% i =∑
i∈S i∈S
=
p( S ) p( S )
= 1, p ( S ) ≡ ∑ pi
i∈S

 Relates to “reversibility”
 Holds for multidimensional chains
M/M/1 Queue with State-Dependent Rates
λ0 λ1 λn−1 λn

0 1 2 n n+1
µ1 µ2 µn µn+1

 Interarrival times: independent, exponential, with parameter λn when


at state n
 Service times: independent, exponential, with parameter µn when at
state n
 Service times and interarrival times: independent
{N(t): t ≥ 0} is a birth-death process
Stationary distribution:
−1
n −1
λ  ∞ n −1
λ 
pn = p0 ∏ i , n ≥ 1 p0 = 1 + ∑∏ i 
i = 0 µi +1  n =1 i =0 µi +1 
M/M/c Queue
λ λ λ λ

0 1 2 c c+1
µ 2µ cµ cµ

 Poisson arrivals with rate λ


 Exponential service times with parameter µ
 c servers
 Arriving customer finds n customers in system
 n < c: it is routed to any idle server
 n ≥ c: it joins the waiting queue – all servers are busy

Birth-death process with state-dependent death rates


nµ , 1 ≤ n ≤ c
µn = 
 cµ , n≥c
[Time spent at state n before jumping to n -1 is the minimum of
Bn= min{n,c} exponentials with parameter µ]
M/M/c Queue
λ λ λ λ

0 1 2 c c+1
µ 2µ cµ cµ

 Detailed balance equations


n
λ λ λ λ 1 λ (cρ )n λ
1 ≤ n ≤ c : pn = pn −1 = L = L p0 =   p0 = p0 , ρ≡
nµ n µ ( n − 1) µ µ n!  µ  n! cµ
n−c c n −c n
 λ  1 λ  λ  cc  λ  cc ρ n
n > c : pn =   pc =     p0 =   p0 = p0
 cµ  c!  µ   cµ  c!  cµ  c!

 Normalizing
−1 −1

 c −1
(cρ ) k
(cρ ) c ∞
k −c   (cρ )
c −1
(cρ ) 1 k c

∑ pn = 1 ⇒ p0 =  ∑ k!
1 + + ∑ ρ  = ∑ k ! +
c ! 1 − ρ 
n =0  k =1 c! k =c   k =0
M/M/c Queue
 Probability of queueing – arriving customer finds all servers busy

( cρ )c ∞ n −c (c ρ )c 1
PQ = P{queueing} = ∑ pn = p0 ∑ ρ = p0
n =c c ! n =c c ! 1 − ρ

 Erlang-C Formula: used in telephony and circuit-switching


 Call requests arrive with rate λ; holding time of a call exponential
with mean 1/µ
 c available circuits on a transmission line
 A call that finds all c circuits busy, continuously attempts to find a
free circuit – “remains in queue”
 M/M/c/c Queue: c-server loss system
 A call that finds all c circuits busy is blocked
 Erlang-B Formula: popular in telephony
M/M/c Queue
 Expected number of customers waiting in queue – not in service
(cρ ) c (cρ )c ρ
N Q = ∑ n =c ( n − c) pn = p0 ∑
∞ ∞ n −c
( n − c) ρ = p0
c! n=c
c ! (1 − ρ )2
ρ ρ
= PQ (1 − ρ ) = PQ
(1 − ρ )2 1− ρ
 Average waiting time (in queue)
NQ ρ
W= = PQ
λ λ (1 − ρ )
 Average time in system (queued + serviced)
1 ρ 1
T =W + = PQ +
µ λ (1 − ρ ) µ

 Expected number of customers in system


ρ
N = λT = PQ + cρ
(1 − ρ )
M/M/c/c Queue: c-Server Loss System
λ λ λ

0 1 2 c
µ 2µ cµ

 c servers, no waiting room


 An arriving customer that finds all servers busy is blocked
 Stationary distribution:
−1
(λ / µ ) n  c (λ / µ ) k 
pn =  ∑
n !  k =0 k !   , n = 0,1,..., c

 Probability of blocking (using PASTA):


−1
(λ / µ )c  c (λ / µ )k 
pc = ∑
c !  k =0 k ! 

 Erlang-B Formula: used in telephony and circuit-switching


Results hold for an M/G/c/c queue
M/M/∞ Queue: Infinite-Server System
λ λ λ λ

0 1 2 n n+1
µ 2µ nµ (n + 1)µ

 Infinite number of servers – no queueing


 Stationary distribution:
(λ / µ ) n − λ / µ
pn = e , n = 0,1,...
n!
Poisson with rate λ/µ
 Average number of customers & average delay:
λ N 1
N= , T= =
µ λ µ

The results hold for an M/G/∞ queue


M/M/c/c and M/M/∞ Queues (proof)
λ λ λ λ

0 1 2 n n+1
µ 2µ nµ (n + 1)µ

 DBE:
λ λ λ λ ⋅ λ Lλ
( nµ ) pn = λ pn −1 ⇒ pn = pn −1 = pn −2 = L = p0
nµ nµ ( n − 1) µ n µ ⋅ ( n − 1) µ L µ
(λ / µ ) n
⇒ pn = p0 , n = 0,1,...
n!

 Normalizing:  c (λ / µ )k 
−1

p0 =  ∑  , for M/M/c/c
 k =0 k ! 

−1
 ∞ (λ / µ ) k 
p0 =  ∑  = e−λ / µ , M/M/∞
for M/M/c/c
 k =0 k ! 
Outline

 M/M/1 Queue
 Poisson Arrivals See Time Averages (PASTA)
 M/M/* Queues
 Introduction to Sojourn Times
Sum of IID Exponential RV’s
 X1, X2,…, Xn: iid, exponential with parameter λ
 T = X1+ X2+…+ Xn
The probability density function of T is:
(λ t )n −1 − λ t
f T (t ) = λ e , t≥0
(n − 1)!
[Gamma distribution with parameters (n, λ)]
If Xi is the time between arrivals i -1 and i of a certain type of events,
then T is the time until the nth event occurs
For arbitrarily small δ:
th (λ t ) n −1 − λt
P{n arrival occurs in [t , t + δ )} = δ f T (t ) = λδ e
( n − 1)!
Cummulative distribution function:
t(λ s ) n −1 − λ s
P{tn ≤ t} = ∫ λ e ds = 1 − P{n th arrival occurs after t}
0 ( n − 1)!
Sum of IID Exponential RV’s
Example 1: Poisson arrivals with rate λ
 τ1: time until arrival of 1st customer
 τi: ith interarrival time
 τ1, τ2,…, τn: iid exponential with parameter λ
 n t = τ1+ τ2+…,+τn: arrival time of n-th customer
tn follows Gamma with parameters (n, λ).
(λ t ) n −1 − λt t (λ t ) n −1 − λt
f (t ) = λ e , t ≥ 0; P{tn ≤ t} = ∫ λ e dt
( n − 1)! 0 ( n − 1)!
For arbitrarily small δ:
th (λ t ) n −1 − λt
P{n arrival occurs in [t , t + δ )} = δ f T (t ) = λδ e
( n − 1)!
Sojourn Times in a M/M/1 Queue

 M/M/1 Queue – FCFS


 Ti: time spent in system (queueing + service) by customer i
 Ti: exponentially distributed with parameter µ-λ

 Example of a sojourn time of a customer: describes the


evolution of the queue together with the specific customer
M/M/1 Queue: Sojourn Times (proof)
M/M/1 Queue: Sojourn Times (proof)
Summary

 M/M/1 Queue
 Poisson Arrivals See Time Averages (PASTA)
 M/M/* Queues
 Introduction to Sojourn Times
Homework #9

 Problems 3.23 and 3.26 of R1

 Hints:
 Prob. 3.23: see book R1
 Prob. 3.26: define system state as the “number of operational machines”

 Grading:
 Overall points 100
 50 points for 3.23
 50 points for 3.26