Queueing Theory Dr. Anis Koubâa CS433 Modeling and Simulation

advertisement
Al-Imam Mohammad Ibn Saud University
CS433
Modeling and Simulation
Lecture 08 – Part 01
Queueing Theory
http://10.2.230.10:4040/akoubaa/cs433/
14 Dec 2008
Dr. Anis Koubâa
Goals for Today
 Lean the most important queuing models
 Single Queue: M/M/1
 Multiple Queues: M/M/m
 Multiple Servers: M/M/m/m
3
M/M/1 Queue
Poisson Arrivals, exponentially distributed service
times, 1 server and infinite capacity buffer
M/M/1 Example
λ
Queue Load
l

m

μ
Queue
Server
M/M/1 Queue
 Poisson Arrivals (rate l),
 exponentially distributed service times (rate m),
 one server,
 infinite capacity buffer.
λ
0
Click for Queue Simulator
μ
λ
1
μ
λ
2
λ
λ
μ
μ
j-1
μ
λ
j
μ
M/M/1 queue model
5
Xs
E[X]
l
m
1
m
E[W]
E[S]
M/M/1 Queue: Steady State
λ
0

μ
λ
1
λ
μ
2
λ
λ
μ
μ
j-1
μ
λ
j
μ
Using the birth-death result λj=λ and μj=μ, we obtain
l
 j     0 , j  0,1, 2,...
m
j

Probability that the Queue in Empty
Therefore
j


l 
 0 1       1
j 1  m  

0  1 
for λ/μ = ρ <1
 j  1     j , j  1, 2,...
M/M/1 Performance Metrics

Server Utilization

E U     j  1   0  1  1     
j 1

Throughput

E  R   m   j  m 1   0   m  l
j 1

Expected Queue Length



j 0
j 0
j 0
E  X    j j  1     j  j   1    
d  j 
d

d   j
d 

 1 

  1   
     1   


d   j 0 
d 
 1    
 1   
M/M/1 Performance Metrics

Average System Time
E  X   l E S   E S  
E S  

1

l 1   

1
l
EX 
1
m 1   
Average waiting time in queue
E  S   E W   E  Z   E W   E  S   E  Z 
E W  
1
1

 
m 1    m m 1   
Response Time vs. Arrivals
9
Waiting vs. Utilization
0.25
W(sec)
0.2
0.15
0.1
0.05
0
0
0.2
0.4
0.6
 %
W
1
m l
0.8
1
1.2
Stable Region
10
Waiting vs. Utilization
0.025
W(sec)
0.02
0.015
linear region
0.01
0.005
0
0
0.2
0.4
0.6
0.8
 %
CS352 Fall,2005
1
M/M/1 Performance Metrics Examples
μ=0.5
40
Ε[S]
35
Delay (time units) / Number of customers

30
Ε[W]
25
20
Ε[Χ]
15
10
5
0
0
0.1
0.2
0.3
0.4
0.5
rho
0.6
0.7
0.8
0.9
1
PASTA Property

PASTA: Poisson Arrivals See Time Averages

Let πj(t)= Pr{ System state X(t)= j }

Let aj(t)= Pr{ Arriving customer at t finds X(t)= j }

In general πj(t) ≠ aj(t)!
Suppose a D/D/1 system with interarrival times equal to 1 and service
times equal to 0.5

a
a
0

0.5
1.0
a
1.5
a
2.0
2.5
3.0
Thus π0(t)= 0.5 and π1(t)= 0.5 while a0(t)= 1 and a1(t)= 0!
Theorem

For a queueing system, when the arrival process is Poisson and
independent of the service process then, the probability that an
arriving customer finds j customers in the system is equal to the
probability that the system is at state j. In other words,
a j  t    j  t   Pr  X  t   j ,

Proof:
a j  t   lim Pr  X  t   j | a  t , t  t 
j  0,1,...
Arrival occurs in interval (t,Δt)
t  0
 lim
t 0
 lim
t  0
Pr  X  t   j, a  t , t  t 
Pr a  t , t  t 
Pr  X  t   j Pr a  t , t  t 
Pr a  t , t  t 
 Pr  X  t   j   j  t 
14
M/M/m Queue
Poisson Arrivals, exponentially distributed service
times, m identical servers and infinite capacity
buffer
M/M/m Queueing System

Meaning: Poisson Arrivals, exponentially distributed service
times, m identical servers and infinite capacity buffer.
1
…
m
λ
0
μ
λ
1
2μ
lj  l
λ
2
λ
λ
3μ
mμ
m
mμ
 j m if 0  j  m
and m j = 
if j  m
 mm
λ
m+1 mμ
M/M/m Queueing System



Using the general birth-death result
j
j
m
1 l
m  l 
 j     0 , if j  m  j 
 0 , if j  m


j! m 
m !  mm 
Letting ρ=λ/(mμ) we get
  m  j
 0 if j  m


 j   j!
 mm  j
 m !  0 if j  m
To find π0

 m 
m 
 0 1  

j!
m!
j 1
j m

m 1
j

m
j


m 
m  




  1   0  1  
j!
m !1    
j 1


m 1
j
m
1
M/M/m Performance Metrics

Server Utilization

 m 1  m  j
mm  j
 m
E U    j j  m Pr  X  m   0   j
j!
m!
j m
j 1
 j 1
j
m
m 1

m 
m  


  0   m   
m


m!1    
j  2  j  1 !

m 1



 m 1  m  j 1  m m 1  m m 1 m  m m 1 
  0 m  1  
 j  2  j  1!   m  1!   m  1!  m!1    


m
 m 1  m  j

m



  0 m 1  



j!
m!1    
j 1

1
l
  0 m
 m 
0
m
M/M/m Performance Metrics

Throughput
m 1

E  R   m  j j  mm   j  l
j 1



j m
Expected Queue Length

 m 1  m  j mm 

j
E  X    j j   0   j

j    ...


j!
m! j  m
j 0
 j 1

m
 m 

E  X   m 
0
2
m! 1   
Using Little’s Law

 m  m 
1
1
E  S   E  X    m 
0 
2

l
l 
m ! 1   

Average Waiting time in queue
E W   E  S   1
m
M/M/m Performance Metrics

Queueing Probability
 0  m 
m 
PQ  Pr  X  m    j   0 

m!
m!1   
j m
j m


m
Erlang C Formula
j
m
Example

Suppose that customers arrive according to a Poisson
process with rate λ=1. You are given the following two
options,



Install a single server with processing capacity μ1= 1.5
Install two identical servers with processing capacity μ2= 0.75 and
μ3= 0.75
Split the incoming traffic to two queues each with probability 0.5 and
have μ2= 0.75 and μ3= 0.75 serve each queue.
λ
μ1
Α
Β
λ
μ2
λ
μ2
μ3
μ3
C
Example


Throughput
 It is easy to see that all three systems have the same
throughput E[RA]= E[RB]= E[RC]=λ
Server Utilization
l
1
2
E U A  


m1 1.5 3
l
1
4
Therefore, each server is 2/3 utilized
E U B  


m2 0.75 3
0.5l
1
2
E U C  


m2
2  0.75 3

Therefore, all servers are similarly loaded.
Example

Probability of being idle
l 1
0A  1 
m1 3
 0
 0C
m
 m 1  m   j
m  

 1  



j!
m !1    
j 1

l
1
 1

2m2 3
1

4 

  
1
4
3




 1 

5
 3
 2
2
1   

 3

2
1
For each server
Example

Queue length and delay
l
1
EXA 

2
m1  l 1.5  1
E  X B   m 
 m 

12
0 
2
m! 1   
5
m
l/2
0.5
E  X 1C  

2
m2  l / 2 0.75  0.5
 E  X C   2  E  X1C   4
E SA  
1
l
EXA  2
1
12
E  SB   E  X B  
l
5
For each queue!
E  XC  
1
l
EXC   4
24
End of Chapter
25
M/M/∞ Queue
M/M/∞ Queueing System

Special case of the M/M/m system with m going to ∞
λ
λ
λ
λ
λ
0
1
μ
2μ
lj  l

3μ
and m j =j m
mμ
m (m+1)μ m+1
for all j
Let ρ=λ/μ then, the state probabilities are given by
j 

2
λ
j
j!
0


j 
 0 1     1   0  e 
j 1 j ! 

j 
System Utilization and Throughput
E U   1   0  1  e  
E  R  l
 j e 
j!
M/M/∞ Performance Metrics

Expected Number in the System


j 0
j 0
E  X    j j   j
j
j!

e   e  
j 1
 j 1
 j  1!

Number of busy servers

Using Little’s Law
E S  
1
l
EX  
1l
lm

1
m
No queueing!
M/M/1/K – Finite Buffer Capacity

Meaning: Poisson Arrivals, exponentially distributed service
times, one server and finite capacity buffer K.
λ
λ
λ
λ
λ
0
μ
1
μ
2
μ
μ
K-1
μ
K
Using the birth-death result λj=λ and μj=μ, we obtain
j
l
 j     0 , j  0,1, 2,...K
m
 Therefore
1 
0 
K 1
j
1


K

l 
for λ/μ = ρ
 0 1       1
j

1




j 1  m  

j 
, j  1, 2,...K
K 1
1 

M/M/1/K Performance Metrics

Server Utilization
E U   1   0  1 


1   
1   K 1
 1   K 

1   K 1
Throughput
1  K
E  R   m 1   0   l
l
K 1
1 
Blocking Probability
PB   K 
1     K
1   K 1
Probability that an arriving customer
finds the queue full (at state K)
M/M/1/K Performance Metrics

Expected Queue Length
j
K
K
K d 
1   
1    
j
E  X    j j 
j 

K 1 
K 1 
d
1 
1 
j 0
j 0
j 0
 
1     d  K

K 1




1




d
1




j

   


K 1
K 1
d   j 0  1  
d 
1 
 1    

1      1   K 1   1     K  1  K 


2
K 1 


1 
1






 1  K
K 

 K 
K 1 
1   1 

Net arrival rate (no losses)
System time
E  X   l 1   K  E  S 
M/M/m/m – Queueing System

Meaning: Poisson Arrivals, exponentially distributed service
times, m servers and no storage capacity.
λ
λ
λ
λ
λ
0
μ
1
2μ
2
3μ (m-1)μ m-1
mμ
m
Using the birth-death result λj=λ and μj=μ, we obtain
j
1 l
 j     0 , j  0,1, 2,...m
j! m 
 Therefore
j 1
m
  
0    
j
m

1 l 
j 0 j ! 

 0       1 for λ/μ = ρ
j
 j 0 j !  m  
j 
 0 , j  1, 2,...m
j!

M/M/m/m Performance Metrics

Blocking Probability
PB   m 
 m / m!

m
Erlang B Formula
j
j 0 j !
Probability that an arriving customer
finds all servers busy (at state m)

Throughput

 m / m! 
E  R   l 1   m   l 1  m  j   l
 

j
!
j

0


M/M/1//N – Closed Queueing
System

Meaning: Poisson Arrivals, exponentially distributed service
times, one server and the number of customers are fixed to N.

μ
1
λ
…
N!

j
 
 0  
 j  0  N  j ! 
N
N
Nλ
0
μ
(N-1)λ
1
Using the birth-death result,
we obtain
N!
j 
 j  0 , j  1, 2,...N
 N  j !
μ
(N-2)λ
2
μ
λ
2λ
μ
1
N-1
μ
N
M/M/1//N – Closed Queueing System
Nλ
0

(N-1)λ
1
μ
Response Time

μ
(N-2)λ
2
μ
λ
2λ
μ
N-1
N
Time from the moment the customer entered the queue until it
received service.

For the queue, using Little’s law we get,
E  X   m 1   0  E  S 

In the “thinking” part,
1
E  N  X   m 1   0 
l
1
Therefore
N  m 1   0 
N
1
l
E S  


m 1   0 
m 1   0  l

μ
Download