Post on 16-Aug-2018
Queueing theory
primer
Lecturer: Massimo Tornatore Original material prepared by:
Professor James S. Meditch
Typesetter: Dr. Anpeng Huang
Courtesy of: Prof. Biswanath Mukherjee 1
A change of focus
• So far we have investigated «static» problems
– Traffic requests are given and constant in time
• E.g., Multi commodity flow problem
• In general, mathematical programming, optimization and graph
theory, heuristics…
• Now we move to a class of dynamic problems
– Random or stochastic flow problems
– The times at which the demands arrive are uncertain
and also the size of the demands are unpredictable
• Queueing (in our case «traffic») theory
2
Source
• Notes taken mainly from – L. Kleinrock, Queueing Systems (Vol 1: Theory)
• Chapter 1 and 2
– L. Kleinrock, Queueing Systems (Vol. 2: Computer
Applications)
• Chapter 1
3
Delay and Congestion, why?
• The reason for this behaviour is the irregularity
(i.e, statistical distribution) of:
– Arrivals (i.e., interarrival times)
– Services (i.e., service times)
R C
If R>C, we expect congestion (intuitive)
If R<C, there might still be congestion (why?)
4
A. Notation and terminology
5
cn = customer n = arrival time of cn
tn = – = interarrival time →
wn = waiting time for cn →
xn = service time for cn →
sn = system time for cn →
sn = wn + xn
n
n
t~
1n
s~
x~
w~
*Note that these distributions do not depend by n (same distribution for all arrivals/services) 6
Arrival process Service process
kttE
ttE
dt
tdAta
ttPtA
])~
[(
1]
~[
)()(
]~
[)(
k
kxxE
xxE
dx
xdBxb
xxPxB
])~[(
1]~[
)()(
]~[)(
k
7
CDF
mean
kth moment
Laplace transform/moment generating fn
kk
sk
kk
xs
tsst
tds
sAdA
eEsB
tfEeEdtetasA
)1()(
)0(
][)(
)]([][)()(
0
*)(*
~*
~
0
*
8
Queueing system performance
Input variables: system defined by and
Output variables: performance defined by
1. N(t) no. of customers in system at time t
2. wn waiting time
3. sn system time
HP: (statistical equilibrium,
stationarity)
t~ x~
NtNt )(,
9
N w s
k
k
k
N
k
N
zPzQzE
NNE
kNPP
kNPkF
0
)(][
][
][
][)(
)(][
]~[
)()(
]~[)(
*~
sWeE
WwE
dy
ydWyw
ywPyW
ws
)(][
]~[
)()(
]~[)(
*~
sSeE
TsE
dy
ydSys
ysPyS
ss
10
Other performance variables:
I = idle period
D = interdeparture time
G = busy period
Nq = no. of customers in queue
11
Kendall’s notation for queueing systems
A/B/m A/B/m/K/M no. of users
no. of servers queue size
M exponential(Markovian) D deterministic
Er r-stage Erlangian G general
Hr R-stage hyperexponential
12
B. General results
1. Utilization factor
10
avg.) (on the usein capacity system offraction
workdo tosystem theofcapacity
arrivesork at which w rate avg.
C
R
13
G/G/1
• Let us start with no assumptions on arrival and
service distribution and one single server
• It can be generally proven that:
sec / service of rate avg.
sec / arrivals no. avg.
x
1
where
x
14
G/G/m
• In case of multiple (m) servers:
)10 wherefor except (
10 requiresStability
serversbusy offraction avg.
servereach for timeservice avg. 1
,
D/D/m
mm
x
15
2. System time
WxT
wExEsE
wxs
]~[]~[]~[
~~~
16
3. Little’s result
WNTN
TN
q
,
The average number of customers in a queueing system
is equal to the average arrival time of customers to that
system, times the average time spent in that system
17
t)(0, interval theduring system in the customers of no. avg.
t)(0, during arrived who
customers allover averagedcustomer per timesystem
)area!grey the(i.e, t time toup system in thespent have
customers all time totalsec)-(customer )()(0
t
t
t
N
T
dssNt
0(t)- (t)N(t)
t)(0,in departures no.)(
t)(0,in arrivals no.)(
t
t
18
N
)(
)()(Ncan But we
t)(0,in systemin customers no. Avg. )(
N
t)(0,in customer per timesystem Avg. erssec/custom )(
)(
t)(0,in rate arrival Avg. sec
)()(
t
t
t
tt
t
T
t
t
t
t
t
t
t
tT
customers
t
tt
19
m , ://
get also weand
)(
:tproven tha becan it Similarly,
(q.e.d) then exist, lim and lim If
mNNmGG
WxT
NNNxN
WN
TNTT
q
qs
s
q
ttt t
20
C. Poisson process
])0(in arrivals[ Pr
,1,0,!
)()(
1,0,1]
~[
d,distributelly exponentia
tindependen : timesalInterarriv
,tk
kek
ttP
ttettP
t
tk
k
t
i
Pure birth system (see p. 60-63, 65,Vol. 1) 21
1. Derivation of the Poisson process
rate) (arrivalintensity process
t)o(t1
]in arrival 1Pr[1]in arrival 0Pr[
t)o(t]in arrival 1Pr[
ΔtΔt
Δt
)()()()()(
)()(]1)[()(
1
1
tottPttPtPttP
tottPttPttP
kkkk
kkk
22
1)0( that note )()(
)2(
)(]1)[()(
,2,1 )()()(
)1(
000
00
1
PtPdt
tdP
tottPttP
ktPtPdt
tdPkk
k
If I divide by «dt», I obtain:
Similarly for P0:
Solving the the first-order differential equation (2):
then inserting P0(t) in (1) for k=1:
then continuing by induction:
tetP )(0
0,0,!
)()( tke
k
ttP t
k
k
ttetP )(1
]~
[1)( )!on!distributi neg. exp.with (relation note Final* 0 ttPetP t
23
2. Properties of the Poisson Process
2
2
1
)1(
1
)1(
0
)(
2
)(
0
1
1
)s!(memoryles ddistributelly exponentia are timesalInterarriv
)(
1]~
[ iv.
),(
][)( iii.
ii.
rate arrival avg.
)()( i.
t
eta
ettPA(t)
tetdz
tzdQ
ezEztPQ(z,t)
t
ttkPtN
t
t
z
zt
z
zt
k
tNk
k
tN
k
k
24
Random process
• Poisson Process is a stochastic (or
random) process
• Now we will use some more advanced
stochastic processes (Markov chains)
• But… what is a stochastic process?
– It is «family» of random variables X(t)
indexed by time t
– A possible (intuitive) case is when the
random process represents the sum of
simple random variables at instant t 25
Example of a random process
S1(t), S2(t) S3(t)…. are
random variables
X(t) is random process
X(t,w) = Number of servers
busy at time t of realization
w of the process= one
realization of the process
Assumptions
Stationarity
• E[to,to+][X(t, w)] = A(t0, w)
= A (w)= A(w)
Ergodicity
• A(w) = A
S1
S2
S3
S4
X(t)
4
3
2
1
0
´
´
´
´
´
´
´
´
H 1
H 2
H 3
H 3
H 6 H 1
H 5 H 4
H 5 H 2
H 4 H 8
H 7
t 0
H 7
H 3 H 4 H 7 H 6 H 5
H 6 H 7 H 8
H 8
t 0 + t
26
D. Markov chains
• A random process is called a “chain” if the state space
is discrete (i.e., if X(t) can assume only discrete
values)
– Note: S = {0, 1, . . ., K} finite state
S = {0, 1, . . .} infinite state (countable)
• A chain can be
– Discrete-time
• If t can assume only discrete values, i.e., if X(t) can change values on at
discrete instants in time
– Continuous-time
• If t can assume any continuous value
• A chain is a Markov chain if … see next slide
27
D.1. Discrete-time Markov chains
][
],,,[
11
001111
nnn
nnn
iXjXP
iXiXiXjXP
28
NNSSXn },...,,1,0{,1) It’s a chain since:
3) It’s a Markov
Chain since:
2) It’s a discrete-time chain since the time («x-axis») is slotted
State probabilities
i
(n)
i
)(
1
)(
0
)()(
1
][ ][ define usLet
nnn
n
n
i iXP
(One-step) transition probabilities
j
n
ij
n
ij
n
nn
n
ij
niPPP
iXjXPP
, 1 ][
][ define usLet
)()1()1(
1
)1(
29
State equations
given ,2,1 )0(
)1()1()(
n
P nnn
Homogeneous chain
j
ijij
nnij
ij
n
ij
iPPP
niXjXPP
nPP
each for 1 ][
][
timeoft independen i.e, ,
1
)(
30
1
)state"steady (" iesprobabilit mequilibriu
thenexists, lim If
1 given
,2,1
)(
i
)(
i
)0(
)0()(
)1()(
i
i
n
n
nn
nn
P
P
nP
n
31
Proof of π(n) = π(n-1) P
32
Proof- Contd.
...
...]......[
......
2
1
0
)1()1(
2
)1(
1
)1(
0
)1(
2
)1(
21
)1(
10
)1(
0
)(
si
i
i
i
n
s
nnn
si
n
s
i
n
i
n
i
nn
i
P
P
P
P
P
PPP
i-th column of P
33
Example
Discrete-time birth-death (arrival-departure) process with no
waiting room.
P(1 arrival at any time n) = a
P(1 departure at any time n) = d
s = {0,1} π = [π0 π1]
34
Example – Contd.
101
100
)1()(
)1(
)1(
1
1
da
da
Pn
P
dd
aaP
nn
35
Example – Contd.
da
a
da
d
d
a
d
aad
10
010
0101
1)1(1
36
D.2. Continuous-time Markov chains
NNSStX },...,,1,0{,)(
37
1) It’s a chain since:
3) It’s a Markov Chain since:
2) It’s a continuos-time chain since the times t can assume any real value
])()([])(...,,)()([
...0.
1111
121
nnnnnn
nn
itXjtXPitXitXjtXP
ttttanyandnallForDef
t1 t2 t3…..
Finite or
countable
Real
Time spent in a state
r.v. geometric a is state ain
spent Chain time Markov time-discrete ain :Note
exp.) (negative 1][
..
Chain Markov time-continuos ofProperty
t
i
i
ietP
withvraisSEstateintime
38
Neg. Exp. Is «Memoryless»
39
tT
ee
ee
tT
tTttT
tT
ttTttTttT
t
t
ttt
Pr
111
11
Pr
PrPr
Pr
Pr Pr
0
00
0
00
0
0000
Pr T t t 0 T t0 Pr T t
t 0
et
e t t0
D.2.a. General Case
D.2.a.1. Transition probabilities
ieachfortq
jit
tttptq
t
tttptq
matrixratetransitiont
ItPtQ
tttptP
stisXjtXPtsp
j
ij
ij
ij
iiii
ij
ij
0)(
),(lim)(
1),(lim)(
)(lim)(
)],([)(
])()([),(
If these limits do not exist, we do not have a continuous-time Markov chain
Δt→0
Δt→0
Δt→0
40
D.2.a.2 State Probabilities
t
j
j
N
j
dssQt
tgiven
tQtdt
td
Ntttt
SjjtXPt
0
10
])(exp[)0()(
1)()0(
)()()(
)],(...)()([)(
])([)(
41
D.2.b. Homogenous case
tQ
ij
ijij
ijij
etQtdt
td
constqtq
sofindeptssptp
)0()()()(
][
.)(
.),()(
42
Homogenous case – Contd.
1
0
:)0(
)(lim
)(
j
jj
Q
oftindependen
t
existsitifstateSteady
t→∞
43
Models used in this course Birth-death processes
• We want to apply the previously seen random processes
to model queues in telecom equipment
• The state changes only
– When a packet arrives (birth)
– When a packet leaves (death)
• Basically you can only move between adjacent states
– State k State k+1 (birth)
– State k State k-1 (death)
• Continuous time
– Packet arrive and depart at any time!
• Mathematical treatment follows in the next slides
44
E. Continuous-time birth-death processes aka arrival-departure processes
(1) Continuous-time Markov chain dealing with a population
of size N at time t
LLS
SkktNPtPk
}...,,1,0{
])([)(
(2) System state changes by at most one (up or down, or no
change) in Δt
45
1j-k if 0,
,1
,1
jk
kk
kkk
p
pdt
pdt
(3) Births and deaths independent
– Follows from Markovianity
(4) Transitions
ratedeath
totktNtttindexactlyP
totktNtttindexactlyP
ratebirth
totktNtttinbexactlyP
totktNtttinbexactlyP
k
k
k
k
k
k
)(1])(),(0[
)(])(),(1[
)(1])(),(0[
)(])(),(1[
Contd.
46
Transitions - State Eqns.
)(1)( )3
0 )()()()()( )2
1 )()(
)()()()()( )1
0
1010000
,11
,11,
LtP
ktptPtptPttP
ktptP
tptPtptPttP
L
k
k
kkk
kkkkkkk
47
- 3 (set of) equations regulate the birth-death process
State Eqns. – Contd.
)]()[()](1)[()(
)]()[()]()[(
)](1)][(1)[()(
11000
1111
tottPtottPttP
tottPtottP
tottottPttP
kkkk
kkkk
48
- Solving of previous equations
*Similar derivation as seen in the Poisson process
State Eqns. – Contd.
0
0)()()(
1
)()()()()(
11000
1111
t
ktPtPdt
tdP
k
tPtPtPdt
tdPkkkkkkk
k
49 *Solving these equations is quite complex, so, in practice, the approach used
is the one shown in the next slide (inspection over a state diagram)
State-Transition Rate Diagrams
tPtPE kkkkk 1111 into Flow
flowy probabilit ofNotion
tPE kkkk ofout Flow
... 1, 0,k
E ofout Flow - E into Flow
k11k11-k
kk
tPtPtP
dt
tdP
kkkk
k
Note: a simple «inspection» technique to find the same equations
50
1,2,...k
:
P Hence, 0dP
um)(equilibri balancedboundary across flows want weif
11
11
kk
k
k
kk
kkkk
k
PP
PP
Note
Ptdt
t
51
(Generic M/M/1) Queue
...,1,00)(
,
sec/
sec/
kdt
tdP
tbehaviorEquilibrum
jobsrateservice
jobsratearrival
k
k
k
52
System Representation
1
1
0 1
0
1
0 1
0
0
21
1020
1
01
0
1100
1111
1
1
...,,
1
00
1,)(0
)(;.1
k
k
i i
i
k
i i
ik
k
k
kkkkkkk
kkkk
p
pp
pppp
p
kpp
kppp
ptPanddependentState
53
Classical M/M/1
1
0
0
1
1
1
,,
k
k
k
k
kk
p
kpp
kall
54
k k+1
k-1
10 2
Classical M/M/1 – Contd.
0)1(
)1(1
10
1
11 ,1
0
01
kp
pp
If
k
k
k
k
k
k
k
k
55
2
2
0
22
20
00 0
1
0 0
)1(
)(
1
)1(1
1
)(
)1(
N
k
kN
k
k
k
k
k k
kk
k k
k
k
pNk
N
d
d
d
d
d
dkk
kpkN
56
Contd.
1
1
TTN
NW
WWxT
1
1
/
1
/11
57
Contd.
10
][
)1(][
1
2
iffvalidareresultsAbove
kNP
pkNP
NWN
k
ki
i
ki
i
58
M/M/m Queue Model
1
m
mkm
mkkk
0
Equivalently,
59
Use state-dependent birth-death model to determine 0, kpk
320
3
13
210
2
12
10011
3!3
22
ppp
ppp
ppp
02
2
12
0
1
11
01
!
!
!
pmm
p
pmm
p
pm
p
m
m
m
m
m
m
1
0
11
0 1
11
0
1
1)()(
1
1
1
1
m
k
mk
m
k
mk
ρm!
mρ
k!
mρ
/mρρ
/mρm!
ρ
k!
ρp
mkpm
m
mkpk
m
pkm
k
k
0
0
!
0!
)(
60
M/M/m Queue system characteristics
mkpm
m
mkpk
mp
pkm
k
k
0
0
!
0!
)(
1
0
0
1
1)()(
1m
k
mk
ρm!
mρ
k!
mρp
mk
kpqueueingp ][
0)1(!
)(][ p
m
mmp
m
mNpN
pmN
smq
m
1
1
1 sq N
xN
WN
T
Where
mp
61
62
Backup slides
M/G/1 Queue
Poisson arrival process: customers/sec
General service process: kxxxB ,),(
queueing discipline is FCFS
1. Pollaczek-Khinchin (P-K) relations
)1(2
)1(2
1][][
22
2
22
xNWxN
WxTx
W
xxExxEx
63
Ex.
sec33.633.42
53.2
)3
13(4.08.0
sec33.4
3
13
)2.0(2
)3
13)(4.0(
)1(2
8.0)2)(4.0(
sec3
13
2
1
sec2
sec/4.0
2
2
3
1
22
TWxT
N
WN
W
xW
x
dxxx
x
cust
64
2. P-K transform relations
a.
zs
sx
k
k
k
k
sBzB
where
zzB
zzBzQ
dxexbxbLsB
zQZpzpzQ
|)()(
)(
)1)(1()()(
)()]([)(
)]([,)(
**
*
*
0
*
1
0
b.
)(yw prob. density fn. of waiting time
0)],([)(
)(
)1()(
)]([)(
*1
*
*
*
ysWLyw
sBs
ssW
ywLsW
)(ys prob. density fn. of system time
)]([)(
)()(
)1()(
)]([)(
*1
*
*
*
sSLys
sBsBs
ssS
ysLsS
65
yeys
s
s
ss
s
sss
ssS
)(
2
*
)()(
)1(
)(
)1(
)/(
)1()(
66
3. Modeling
a. Imbedded Markov Chain
nq no. customers left behind by nC
nv no. customers which enter during nx
,...1,0,
0
01
1
1
1
nq
qv
qvqq
n
nn
nnn
n
Cont. –time Markov chain
b. Tagged job
)1/(
)1(
)(
)(
RW
RW
WRWxRW
R
xWRW
Residual work (residual life time)
67
Residual Life - R
x
z
Random Arrival
Service process:
b x x x( ), , 2
F x P Z xZ ( ) [ | system busy at time of arrival]
r = E[Z | system busy]
Intuition: r =x
2 ? Wrong!
68
Chances are higher that x arrives during longer periods
f x density fn. for length of service period
during which arrival occurs, given system busy
f x x) Kx b(x) (x)
f (x) d(x) K x b(x) dx = kx = 1, K =1
x
f (x) = x b(x)
x
r = x
2
x b(x)
x d(x) =
x
2x
Z
Z
Z00
Z
0
2
( )
( ) (
Residual Life - Cont’d
69
R = E[Z | system busy] E[system busy]
=x
x . x =
1
2 x
W =
1
2x
x
22
22
2
1 2 1
( ) ( )
Markovian queueing Networks
N-node interconnection of queueing systems
queueing and service at each node
Exponential service times at each node
Model multi-service processes
Residual Life - Cont’d
70
1
3
4
2
r11
r12
r21
r31
r32
r22
r23
r44
r43
r34
1 1 43 44 ( )r r
1 31 32 34 ( )r r r 3
1. Open Networks
N nodes
Each node – single queue, servers
Exponential service time
mi
xi
i
1
sec
71
External arrivals – Poisson process (indep.) jobs/second
= P[that a job which completes service at node will proceed next
to node ]
P[that a job which completes service at node will leave
the network]
Avg. arrival rate at node from both external sources ands other
nodes (including itself)
i
rij ij
11
rijj
N
ii
i
rii
r i1
r i2
rNi
i
i
1
2i
N i i j jij
Nr
1
Flow Equations:
= [ 1 2 N
....... ]
[ ....... ]
[ ]
1 2 N
jiR r
R
72
Jackson’s theorem (1957)
Let p(k k k p[k jobs at node 1, k jobs at node 2, ....., k jobs at node N]
and
p k p[k jobs at node i]
Then
p(k k k p k p k p k
Each node in the network can be treated as an
M / M / m queue, m 1
1 2 N 1 2 N
i i i
1 2 N 1 1 2 2 N N
i i
, ....., )
( )
, ....., ) ( ) ( )........... ( )
73
1
2
N-1
N
……………
N = N ii=1
N
= ii=1
N
T =N
74
Example:
1 2 3
r12 r23
I/O I/O CPU
r11 r22
r11 02 . r12 08 .
r22 04 . r23 06 .
101
1 . sec
10 05
2 . sec
10 9
3 . sec
1 job / sec
75
Node 1
1 11 1 1 1
11
1
1
1
1 0 2 125
01251
01429
r . .
. . N1
Node 2
2 12 1 22 2 2 2
22
2
2
2
08 125 0 4 16667
0 08331
0 0909
r r . ( . ) . .
. . N2
Node 2
3 22 2
33
3
3
3
0 6 16667 1
0 91
0 9
9 2338
9 23
r . ( . )
. .
.
. sec
N
N = N + N + N
T =N
3
1 2 3
76
1
4
3
2 r12
r21
r14
r42
r22
r23
r33
r43
2. Closed Networks
N nodes; K jobs circulating through the network
No external arrivals or departures
Each node – single queue, servers Exponential service time mixi
i
1
sec
r24
r32
i ij
N
r
0 1
1 2
for each i
K K R = [r
(flow vector)
R
j=1
N
ii=1
N
ij ]
[ .......... ]
77
Gorjon and Newell (1967)
p(k k k 1
G(K)
x
k
{x satisfy
x x i = 1,2,....., N
G(K) =x
k
with k = (k ,k ,......., k ) and
A = set of all k vectors for which k + k +.....+k = k
(3) kk
1 2 Ni
k
i i
i
i i j
i
k
i ik
1 2 N
1 2 N
i i
i
i
, ....., )( )
( ) }
( )( )
( )
i
N
j jij
N
i
N
A
where
r
1
1
1
1
2
i i i
i i
k m
i i
ii
i
, k m
m m , k m
Utilization at node i: x
m i = 1,2, ..... , N
i i
!
!
78
Example: (Application-interactive computing)
Multi-Processor
.
.
.
.
.
.
. . . . . . . .
Node 1
Nodes 2,3, …….N
K terminals k jobs
N = avg. " think" time at each terminal (exp. distribution think times)
T =K
seconds
T = avg. responce time
1
79
),( M/M/1 2. kk
1k
1k
P
1,2,...k
P
mEquilibriu
k
k
P
P
0
k
0
0
2
12
01
1P
subject to
P
P
toleads This
k
k
k PP
PP
P
80