You are on page 1of 46

Simulation 1

Basics of Queueing Theory


Part 2.
Simulation 2
Outline
Introduction (motivation, basic definitions)
Queuing Theory Problem Statement
Queues Operational Analysis (Basic Queuing
Principles and Rules)
Standard Notation of Queuing Systems
Poisson Process, Markov Chains
Analysis of a Single Queue, Single Server
Infinite Queue M/M/1
Finite Queue M/M/1/K
Other Queuing Models
Exercise

Simulation 3
M/M/1 Queues - Model
Single queue
Single server (single transmission line)
Customers (packets) arrive according to a Poisson
process with rate per second (s
-1
)
The service time distribution is exponential with
mean 1/ seconds, service rate (s
-1
)
Infinite buffer
The M/M/1 queue is the most basic and important
queuing model.

Simulation 4
State Analysis of an M/M/1 Queue
Let n be the state of the system = the
number of packets in the system (including
the server).
Let p
n
be the steady state probability of
finding n customers waiting in the system
(including the server).
Simulation 5
M/M/1 Queue Markov Chain Model
Due to the memoryless property of
exponential random variables, the number
of customers in the system at time t, N(t),
can be expressed as a continuous-time
Markov chain

Simulation 6
Recall: The General Birth-Death Process as a
Markov Chain
(
(
(
(
(
(

3 3 3
2 2 2 2
1 1 1 1
0 0
1 0 0
1 0
0 1
0 0 1




P
1 0 2
k

k-1

k

k+1

... ...
Note that we number the states from 0 so that the state
number is the same as the population.
Simulation 7
0 1 2
At
At At
1At
At At At
1At
At
1At
At
State Diagram of an M/M/1 Queue
Consider an arbitrarily small interval t > 0
Probability(1 arrival)
Probability(1 departure) System State :
Number of packets in system
(including server)
8
In steady state the following balance equation
must hold for every state k
Steady State Analysis of B-D Processes
The Rate In = Rate Out Principle:
Mean entrance rate = Mean departure rate

=
=
0
1
i
i
p
In addition the probability of being in one of the
states must equal 1
Simulation 9
State Analysis of an M/M/1 Queue
Local Balance Equation: (What goes in must come out)

n-1 n n+1
At
At
At
At At At
At
At
Equilibrium Analysis:
Simulation 10
Recall:Equilibrium Probabilities
0 2

2

...
k k+1

k-1

k+1

0
1 1 0 0
= = k p p
0 ) (
1 1 1 1
> + = +
+ +
k p p p
k k k k k k k


What goes out must come in
Simulation 11
[
=

=
k
i
i
i
k
p p
1
1
0

; 1 1
1
0
0


=

=
= =
i
i
i
i
p p p
from other balance equation:
[

= =

=
1 1
1
0 0
1
k
k
i
i
i
p p

= =

+
=
1 1
1
0
1
1
k
k
i
i
i
p

Rearranging
Recall:Solving the problem
Recall: Geometric series
Simulation 12
Simulation 13
State Analysis of an M/M/1 Queue
The M/M/1 queue is simply a birth death process
with
k
= and
k
=. Substituting into our previous
equations we get:
0
p p
k
k
=
where =/ is known as the utilisation factor for
a stable system this is < 1

=
+
=
1
0
1
1
k
k
p


=
+
= 1
) 1 /( 1
1
0
p
k
k
p ) 1 ( = Therefore:
From the geometric series:
Simulation 14
State Analysis of an M/M/1 Queue
The result is



0
1 p =
,... 3 , 2 , 1 , ) 1 ( = = k p
k
k

Simulation 15
State Analysis of an M/M/1 Queue
Note that requiring < 1 for stability ( < )
makes intuitive sense.
Also =1-p
0
= probability of the queuing
system is NOT empty = probability of the
server is working. So is sometimes called
the server utilization
Finally note that p
n
= (1- )
n
, n = 0,1,2,3,
is a geometric distribution
Simulation 16
M/M/1: How Long is that Line?
Recall: n - the number of packets
(customers) in the system (including the
server)
So the average number in the system is

= = =


=

=
1 ) 1 (
) 1 ( ) 1 ( ) (
2
0 0 n
n
n
n
n np n E
Simulation 17
Computing Expected Time in System and Expected
Waiting Time
Recall: Littles Law says
Using Littles Law, we can find the expected time
in the system

( ) 1
( )
(1 )
E n
E T


= = =

and , the expected time in the queue (average
waiting time)
( ) ( ) E T E n =
1
( ) ( ) E W E T

= =/()
Simulation 18
Computing Expected Queue Length
Using again Littles Law
Simulation 19
M/M/1 Queue
As utilization
increases beyond
85%, queue rises
sharply
Corresponding sharp
rise in response time
Utilization must be
under 100%, but
often lower
Ex: OS CPU
scheduler often has
60-80% heuristic
Simulation 20
Outline
Introduction (motivation, basic definitions)
Queuing Theory Problem Statement
Queues Operational Analysis (Basic Queuing
Principles and Rules)
Standard Notation of Queuing Systems
Poisson Process, Markov Chains
Analysis of a Single Queue, Single Server
Infinite Queue M/M/1
Finite Queue M/M/1/K
Other Queuing Models
Exercise

Simulation 21
M/M/1/N Queue - Model
Poisson arrival process
Exponential service times
Single server
Finite capacity of N customers in the system

Simulation 22
M/M/1/N Markov Chain Model
Terminates with N in the system
Local balance equations are the same as in M/M/1 case

0 1 2
At
At At
1At
At At At
1At
At
1At
At
N-1 N
At
At
1At
At
1At
At
p
n+1
= p
n
but only for n =0,1,2N-1

Simulation 23
From p
n
=
n
p
0
for n = 0,1,2,, N < and





So
M/M/1/N Steady State Solution (1/2)
0
N
n
n
p
=

0 0
1
1
N
n
n
p p
=
=

0
1
1
1 1 1
...
(1 ) 1
1
1
(1 )
N N N
n
n
p

+
=

= = = =

+
+

=1 we have
Simulation 24
Note that this holds for any 0 . No
need to assume < 1.
We always have the stability in the finite
buffer case.
M/M/1/N Steady State Solution (2/2)
Simulation 25
Blocking Probability
So in the finite buffer case,



Note that p
N
is the probability that the
buffer is full at an arbitrary point in time.
1
(1 )
for 0,1, 2, ...,
1
n
n
N
p n N

= =

Simulation 26
Blocking Probability
Since arrivals are independent of buffer
state, we have p
N
= p
B
= probability of
dropping the arriving packet due to a full
buffer.
p
B
is called blocking probability.
Simulation 27
Blocking Probability and Buffer Size
p
B
is very important!
We can use p
B
to choose the correct buffer size.
Example:
For = 0.5, p
N
> 10
-6
for N 18, while p
N
< 10
-6

for N 19
Thus, if we desire a blocking probability less than
10
-6
, we need a buffer capable of holding 19 or
more packets.

s >
Simulation 28
Throughput in the Finite Buffer Case
The throughput of any queuing system
is the rate at which customers successfully
leave the system.
For the M/M/1 infinite buffer case, = if
the system is stable. (Everything that arrives
must eventually depart.)
Simulation 29
Throughput in the Finite Buffer Case
For the M/M/1/N finite buffer case,
=(1-p
b
)
(Everything that arrives and is not blocked
must eventually depart.)
Simulation 30
Throughput in the Finite Buffer Case
Alternate way to compute throughput of
M/M/1/N:
Look at the output side.
P (server is busy) = 1-p
0
When the server is busy, the output rate =
When the sever is idle, the output rate = 0
So the average rate =(1-p
0
) +0p
0
0
1 p

0 0
(1 ) 0 p p = +
Simulation 31
Derivation of p
N
= p
B
Using Throughput
Equating our two formulas for we get
(1-p
0
)= (1-p
b
)

Solving for p
B
we get


0
1
1 (1 )
1 ...
1
N
B N
N
p
P p


+

= = = =

Simulation 32
Outline
Introduction (motivation, basic definitions)
Basic Queuing Principles and Rules
Standard Notation of Queuing Systems
Poisson Process, Markov Chains
Analysis of a Single Queue, Single Server
Infinite Queue M/M/1
Finite Queue M/M/1/K
Other Queuing Models
*)
Exercise

*)
Based on J.Virtamo Queuing theory course
M/M/m queue (Erlangs waiting system)
Poisson arrivals
Exponential service time distribution
m parallel servers

Simulation 33
All m servers are busy
M/M/m queue (Erlangs waiting system)
Simulation 34
Balance equations
M/M/m queue (Erlangs waiting system)
P
q
blocking probability
Simulation 35
M/G/1
M (memory less): Poisson arrival process, intensity
G (general): general holding time distribution, mean S = 1/
1 : single server, load = S (in a stable queue one has < 1)

The number of customers in the system, N(t), does not
now constitute a Markov process.
The probability per time unit for a transition from the state
{N = n} to the state {N = n 1}, i.e. for a departure of a
customer, depends also on the time the customer in service
has already spent in the server
In spite of this, the mean queue length, waiting time,
and sojourn time of the M/G/1 queue can be found.
Simulation 36
Pollaczek-Khinchin (P-K) mean formula
Littles theorem: E[N
q
] = E[W]
E[W]= E[S] E[W] + E[R]
E[W]=E[R] / (1- E[S]); E[S] =
E[W]=E[R]/(1- )
Simulation 37
Recall: The hitchhikers paradox
Cars are passing a point of a road according to a Poisson
process on average every 30 minutes. A hitchhiker arrives to
the roadside point at random instant of time. How long can a
hitchhiker expect to wait for the next car?
38
Recall: The hitchhikers paradox
The time interval between two
cars is distributed exponentially
with rate
= 1/30 min
-1
.
How long does the hitchhiker
has to wait?
V

b
k
b
k+1
p

Y

Z

Solution 1:
E[V]= 30 min. Therefore, since the passenger will (on average) arrive in
the middle of the interval, he has to wait for E[Y]=E[V]/2= 15 min
But using the memoryless property, the time until the next bus is
exponentially distributed with rate , therefore E[Y]=E[V]=1/ = 30 min
and not 15 min!
Solution 2:
Using the memoryless property, the time until the next bus is
exponentially distributed with rate , therefore E[Y]=1/ = 30 min.
But note that E[Z]= 1/ therefore E[V]= E[Z]+E[Y]= 2/ = 60 min not
30 min!
Recall: Residual service time (The hitchhikers paradox
solution)
Simulation 40
S
n
2 2 2
1 1
0
2 2 2 2
2
2 2
1 1 1
( ) / 2 / 2 / 2
( ) ( )
For exponential distribution of :
( ) 1/ ; 1/
(1/ 1/ ) / 2 1/ ;
t
n n
i i
i i
n
R R d S S S
t t t n
Var S S S S S Var S
S
Var S S
R S
t t


= =
= = = =
= = +
= =
= + = =

}
P-K mean formula Residual service time
Simulation 41
The number of the triangles (arrivals) n ; mean number is t.
) 1 ( 2
] [
) 1 (
] [
] [
2
] [
] [
2
2

=
=
S E R E
W E
S E
R E
Simulation 42
P-K mean formula. Results
Mean waiting and sojourn times
Apply Littles theorem
Mean number of waiting customers and customers in system
Reminder: Variance V[S]=E[S
2
]-E[S]
2
V[S]=E[S
2
] = V[S] + E[S]
2
= (1+C
v
2
)E[S]
2

P-K mean formula Results
Mean values depend only on the expectation E[S]
and variance V[S] of the service time distribution
but not on higher moments.
Mean values increase linearly with the variance.
Randomness leads to an increased waiting time
and queue length.
The formulae are similar to those of the M/M/1
queue; the only difference is the extra factor
(1+C
v
2
)/2
Simulation 43
P-K Result for M/M/1 and M/D/1
Simulation 44
Simulation 45
Other Queuing Models
Can also model and analyze other queuing
systems
With priority
With more general arrival process
With vacations
Many others
Simulation 46
Outline
Introduction (motivation, basic definitions)
Basic Queuing Principles and Rules
Standard Notation of Queuing Systems
Poisson Process, Markov Chains
Analysis of a Single Queue, Single Server
Infinite Queue M/M/1
Finite Queue M/M/1/K
Other Queuing Models
Exercises

You might also like