34
CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University Al-Imam Mohammad Ibn Saud University

CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

Embed Size (px)

Citation preview

Page 1: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

CS433Modeling and Simulation

Lecture 13

Queueing Theory

Dr. Anis Koubâa03 May 2009

Al-Imam Mohammad Ibn Saud UniversityAl-Imam Mohammad Ibn Saud University

Page 2: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

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

Page 3: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1 Queue3

Poisson Arrivals, exponentially distributed service times, 1 server and infinite capacity buffer

Page 4: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1 Example

M/M/1 Queue Poisson Arrivals (rate ), exponentially distributed service times (rate ), one server, infinite capacity buffer.

λ

0 1μ

λ

λ

j-1μ

λ

jμμ

λ λ

μ

Queue Server

λ μ

Click for Queue Simulator

Queue Load

Page 5: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1 queue model 5

1

E[W]

E[S]

Xs

E[X]

Page 6: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1 Queue: Steady State

λ

0 1μ

λ

λ

j-1μ

λ

jμμ

λ λ

μ

Using the birth-death result λj=λ and μj=μ, we obtain

0 , 0,1,2,...j

j j

Therefore

01

11j

j

for λ/μ = ρ <1

0 1

, 1, 2,...1 jj j

Probability that the Queue in Empty

Page 7: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1 Performance Metrics

Server Utilization

Throughput

01

1 1 1jj

E U

Expected Queue Length

01

1jj

E R

0 0 0

1 1j

jj

j j j

dE j jX

d

0

11 1

1 1j

j

d d

d d

Page 8: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1 Performance Metrics

Average System Time

Average waiting time in queue

1E E E ES SX X

E E E E E ES W W SZ Z

1 1

1 1E S

1 1

1 1E W

Page 9: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

Response Time vs. Arrivals9

1W

Waiting vs. Utilization

0

0.05

0.1

0.15

0.2

0.25

0 0.2 0.4 0.6 0.8 1 1.2

W(s

ec)

Page 10: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

Stable Region

CS352 Fall,2005

10

Waiting vs. Utilization

0

0.005

0.01

0.015

0.02

0.025

0 0.2 0.4 0.6 0.8 1

W(s

ec)

linear region

Page 11: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1 Performance Metrics Examples

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10

15

20

25

30

35

40

rho

Del

ay (

time

units

) /

Num

ber

of c

usto

mer

s

μ=0.5

Ε[Χ]

Ε[W]

Ε[S]

Page 12: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

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

0 0.5

1.0

1.5

2.0

2.5

3.0

a a a a

Thus π0(t)= 0.5 and π1(t)= 0.5 while a0(t)= 1 and a1(t)= 0!

Page 13: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

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, Pr , 0,1,...j ja X j jt t t

Proof:

0

lim Pr | ,j ta X j a t t tt t

Arrival occurs in interval (t,Δt)

0

Pr , ,lim

Pr ,t

X j a t t tt

a t t t

0

Pr Pr ,lim Pr

Pr ,jt

X j a t t ttX jt t

a t t t

Page 14: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/m Queue14

Poisson Arrivals, exponentially distributed service times, m identical servers and infinite capacity buffer

Page 15: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/m Queueing System

Meaning: Poisson Arrivals, exponentially distributed service times, m identical servers and infinite capacity buffer.

λ

0 1μ

λ

22μ

λ

mmμ

λ

m+1mμ3μ

λ λ

1

m…

if 0 and =

if j j

j j m

m j m

Page 16: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/m Queueing System

Using the general birth-death result

0

1, if

!

j

j j mj

Letting ρ=λ/(mμ) we get

0 , if !

jm

j

mj m

mm

0

0

if !

if !

j

jm j

mj m

j

mj m

m

1

01

11! !

j m jm

j j m

m m

j m

11

01

1! ! 1

j mm

j

m m

j m

To find π0

Page 17: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/m Performance Metrics

Server Utilization

1

1

Prm

jj

E j m X mU

1

01 ! !

j m jm

j j m

m mj m

j m

1

02 ! !1 1

j mm

j

m mmm

mj

1 1 1 11

02

1! ! ! !1 11 1

j m m mm

j

mm m m mm

mj m m

1

01

1! ! 1

j mm

j

m mm

j m

00

1m m

Page 18: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/m Performance Metrics

Throughput

Expected Number of Customers in the System

1

1

m

j jj j m

E j mR

1

00 1

...! !

j mmj

s jj j j m

m mE X j j j

j m

02! 1

mm

E mXsm

Using Little’s Law, the average response time

02

1 1

! 1

mm

E E mS Xsm

Average Waiting time in queue 1E EW S

Page 19: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/m Performance Metrics

Queueing Probability

00Pr

! ! 1

mm j

Q jj m j m

mmP X m

m m

Erlang C Formula

Page 20: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

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

μ3

λ

Β

μ2

μ3

λ

C

Page 21: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

Example

Throughput It is easy to see that all three systems have the same

throughput E[RA]= E[RB]= E[RC]=λ Server Utilization

1

1 2

1.5 3AE U

2

1 4

0.75 3BE U

Therefore, each server is 2/3 utilized

2

0.5 1 2

2 0.75 3CE U

Therefore, all servers are similarly loaded.

Page 22: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

Example

Probability of being idle

01

11

3A

For each server02

11

2 3C

124

14 31523 2 1

3

11

01

1! ! 1

j mm

j

m m

j m

Page 23: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

Example

Queue length and delay

1

12

1.5 1AE X

For each queue!

02

12

! 51

m

B

mE mX

m

12

/ 2 0.52

/ 2 0.75 0.5CE X

12A AE ES X

12 4C CE X E X

1 12

5B BE ES X

14C CE X E X

Page 24: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

End of Chapter24

Page 25: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/∞ Queue25

Page 26: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/∞ Queueing System

Special case of the M/M/m system with m going to ∞λ λ λ λ

0 1μ 22μ

λ

mmμ m+1(m+1)μ3μ

λ

and = for all j j j j

0!

j

j j

Let ρ=λ/μ then, the state probabilities are given by

0 01

1 1!

j

j

ej

!

j

j

e

j

System Utilization and Throughput

01 1E eU E R

Page 27: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/∞ Performance Metrics

Expected Number in the System

1

0 0 1! !1

j j

jj j j

E j j e eXj j

Using Little’s Law

1 1 1E ES X

No queueing!

Number of busy servers

Page 28: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1/K – Finite Buffer Capacity

Meaning: Poisson Arrivals, exponentially distributed service times, one server and finite capacity buffer K.

Using the birth-death result λj=λ and μj=μ, we obtain

0 , 0,1,2,...j

j j K

Therefore

01

11jK

j

for λ/μ = ρ

0 1

1

1 K

1

1, 1, 2,...

1

j

j Kj K

λ

0 1μ

λ

λ

K-1μ

λ

Kμμ

λ

Page 29: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1/K Performance Metrics

Server Utilization

Throughput

0 1 1

1 11 1

1 1

K

K KE U

Blocking Probability

0 1

11

1

K

KE R

1

1

1

K

B K KP

Probability that an arriving customer finds the queue full (at state K)

Page 30: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1/K Performance Metrics

Expected Queue Length

1 10 0 0

1 1

1 1

jK K Kj

j K Kj j j

dE j jX

d

1

1 10

1 1 1

1 1 1

KKj

K Kj

d d

d d

1

21

111 1

1 1

KK

K

K

1

1

1 1

KK

KK

System time

1 KE E SX

Net arrival rate (no losses)

Page 31: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/m/m – Queueing System

Meaning: Poisson Arrivals, exponentially distributed service times, m servers and no storage capacity.

Using the birth-death result λj=λ and μj=μ, we obtain

0

1, 0,1,2,...

!

j

j j mj

Therefore

00

11

!

jm

j j

for λ/μ = ρ

1

00 !

jm

j j

0 , 1, 2,...!

j

j j mj

λ

0 1μ

λ

22μ

λ

m-1(m-1)μ

λ

mmμ3μ

λ

Page 32: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/m/m Performance Metrics

Throughput

Blocking Probability

!0

/ !11 j

m

mmjj

mE R

!0

/ !j

m

B m m

jj

mP

Probability that an arriving customer finds all servers busy (at state m)

Erlang B Formula

Page 33: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

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.

0 1μ

(N-1)λ

N-1μ

λ

Nμμ

(N-2)λ

λ

μ

1

N

Using the birth-death result, we obtain

0

!, 1, 2,...

!j

j

Nj N

N j

1

00

!

!

Nj

j

N

N j

Page 34: CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University

M/M/1//N – Closed Queueing System

Response Time Time from the moment the customer entered the queue until it

received service.

01E E SX

0 1μ

(N-1)λ

N-1μ

λ

Nμμ

(N-2)λ

For the queue, using Little’s law we get,

0

11E N X

In the “thinking” part,

0

0 0

11 1

1 1

N NE S

Therefore