7 - Exercises on Queueing Theory

43
4 - Exercises on queueing theory Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza” Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza” 4 - Exercises on queueing theory

Transcript of 7 - Exercises on Queueing Theory

4 - Exercises on queueing theory

Ing. Alfredo Todini

Dipartimento INFOCOMUniversità di Roma “Sapienza”

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 1

Evaluate the Laplace transform of the function:

f (t) = cos(ωt).

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 1 - Solution

Writing cos(ωt) = e+jωt +e−jωt

2 and applying the definition yieldsthe result:

Lf (s) =

∫ ∞0

(e+jωt + e−jωt

2

)e−stdt =

=12

∫ ∞0

e(−s+jω)tdt +12

∫ ∞0

e(−s−jω)tdt =

=12

1s − jω

+12

1s + jω

=s

s2 + ω2 .

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 2

Give the queuing models for the following system. Define thearrival and service process, the number of servers, the size ofthe buffer and the service principle. List the relevantperformance measures.

Requests arrive to a Web server. The server can respondto M requests at a time. Responding to a request meanstransmitting a Web page of variable size. Requests thatarrive when M requests are already under service mustwait for their turn.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 2 - Solution

Web server.Arrival process: requests from Internet usersService process: transmission of a Web page (pagesize/transmission rate)Number of servers: MBuffer size: infiniteService principle: FIFONotation: M/G/mPerformance measures: response time, server utilization

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 3

Show that the uniform distribution is not memoryless.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 3 - Solution

Let X be a random variable with pX (x) = 1∆ rect∆(x − x0),

∆ = 5 and x0 = 7.5. We show that there is a t such thatPr {X < t + x |X > t} 6= Pr {X < x}.

Pr {X < x} =

0 if x < 5x − 5

5if 5 ≤ x < 10

1 if x ≥ 10.

it suffices to take t = 7.5:

Pr {X < 7.5 + x |X > 7.5} =

x

2.5if 0 ≤ x < 2.5

1 if x ≥ 2.5.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 4

You are entering a bank, where there is one clerk and there arealready three customers waiting. The service of one customertakes 10 minutes on average, with an exponential distribution.

1 Give the distribution of your waiting time.2 What is your expected waiting time, the variance of the

waiting time, and what is the probability that you have towait more then 40 minutes? Prove your answers.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 4 - Solution

1 Your waiting time will be the sum of the service times of 4customers, one under service, 3 waiting. Each service timehas an exponential distribution with parameter 1/10. Notethat due to the memoryless property of the exponentialdistribution it does not matter when the service of thecustomer at the clerk has started, his remaining servicetime is still exponential with the same expected value.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 4 - Solution

2 The average is the sum of the average service times. Thevariance is the sum of the variances of the service times,since they are independent.

W = X1 + X2 + X3 + X4

fX (t) = λe−λt E [X ] = 1/λ Var [X ] = 1/λ2 λ = 1/10

fW (t) = λ(λt)3

3!e−λt

E [W ] =4∑

i=1

E [Xi ] = 40 Var [W ] =4∑

i=1

Var [Xi ] = 400.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 4 - Solution

Note that the sum of k independent, identically distributedexponential random variables has an Erlang distribution:

f (x ; k , λ) = λ(λx)k−1

(k − 1)!e−λx

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 4 - Solution

The probability that you have to wait longer than 40 minutes isthe probability, that there was no service completion, or only 1,2 or 3 service completions during these 40 minutes. Thesequence of services forms a Poisson process, and thus youcan calculate the probabilities above.

Pr {W > 40} =3∑

i=0

(λt)i

i!e−λt

∣∣∣∣∣t=40

= 0.433.

Note that the departures from a sequence of exponentialservices form a Poisson process, only if the server is never idle,as in this case.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 4 - Solution

Alternatively, we can use the distribution of the waiting time:

Pr {W > 40} =

∫ +∞

40λ

(λt)3

3!e−λtdt = (integrating by parts)

= −[

(λt)3

3!+

(λt)2

2!+ λt + 1

]e−λt

∣∣∣∣+∞t=40

=

=3∑

i=0

(λt)i

i!e−λt

∣∣∣∣∣t=40

= 0.433

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 5

Customers arrive to a restaurant according to a Poissonprocess with rate 10 customers/hour. The restaurant opensdaily at 9:00 am. Find the following:

1 When the restaurant opens at 9:00 am, the workers need30 min to arrange the tables and chairs. What is theprobability that they will finish the arrangement before thearrival of a customer?

2 What is the probability that there are 15 customers in therestaurant at 1:00 pm, given that there were 12 customersin the restaurant at 12:50 pm?

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 5

3 Given that a new customer arrived at 9:13 am, what is theexpected arrival time of the next customer?

4 If a customer arrive to restaurant at 2:00 pm what is theprobability that the next one will arrive before 2:10 pm?

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 5 - Solution

1

Pr {workers finish the arrangement before the arrival of a customer} = Pr {No arrivals in 30 min} =

= P0(30/60) = e−10(0.5) = 0.006674

2

Pr {there are 15 customers in the restaurant at 1:00 | there were 12 customers in the restaurant at 12:50} =

= Pr {exactly 3 customers arrived between 12:50 and 1:00} =

= P3(10/60) =(10/6)3

3!e−10/6 = 0.14574

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 5 - Solution

3

E [arrival time of the next customer | a new customer arrived at 9:13 am] =

= 9:13 am + E [interarrival times] = 9:13 am +1λ

=

= 9:13 am +1

10hr = 9:19 am

4

Pr {next customer will arrive before 2:10 pm | a new customer arrive at the restaurant at 2:00 pm} =

= Pr {interarrival time < 10 min} =

= 1− e−10(10/60) = 0.811

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 6

Calculate the state probabilities in steady-state for the followingMarkov-chain with the help of global or local balance equations(λ = 100 and µ = 150).

λ λ λ

2μ 2μ 2μ

0 1 2 3 4

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 6 - Solution

Just write local balance equations:

p0λ = p12µp1(λ+ 2µ) = p22µp2(λ+ 2µ) = p0λ+ p32µp32µ = p1λ+ p42µp42µ = p2λp0 + p1 + p2 + p3 + p4 = 1

⇒ p = (p0,p1,p2,p3,p4) =

(2759,

959,1259,

759,

459

).

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 7

Consider a queueing system with Poisson arrival process andexponential service time having the following rates:

λ0 = λ n = 0λn = λ/n n = 1,2,3,4µn = µ n = 0,1,2,3,4,5

1 Draw the state diagram for this system.2 Write the balance equations for each state.3 Solve the balance equations to get the steady state

distribution of the system pn.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 7 - Solution

λ λ λ/2

μ μ μ

0 1 2 3 4

μ

5

λ/3 λ/4

μ

2

n = 0 λp0 = µp1

n = 1 (λ+ µ)p1 = λp0 + µp2

n = 2 (λ/2 + µ)p2 = λp1 + µp3

n = 3 (λ/3 + µ)p3 = (λ/2)p2 + µp4

n = 4 (λ/4 + µ)p4 = (λ/3)p3 + µp5

n = 5 µp5 = (λ/4)p4

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 7 - Solution

3

p1 = (λ/µ)p0

p2 = (λ/µ)2 p0

p3 = (2!)−1 (λ/µ)3 p0

p4 = (3!)−1 (λ/µ)4 p0

p5 = (4!)−1 (λ/µ)5 p0∑5i=0 pi = 1

⇒ p0 =

[1 +

λ

µ+

µ

)2

+12!

µ

)3

+13!

µ

)4

+14!

µ

)5]−1

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 8

You have designed a first-come first-service data processingsystem. You based the design on an M/M/1 queuing model.Now the users complain about poor response times. The log ofthe system shows that there are on average N = 19 jobs in thesystem and that the average processing time (service time) forone job is X = 2 seconds.

1 Estimate the system utilization, the job arrival intensity andthe average waiting time, based on the M/M/1 model.

2 What is the probability that a job would wait more thantwenty seconds?

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 8 - Solution

1 We have µ = 0.5/sec. Hence

N =ρ

1− ρ⇒ ρ = 0.95, λ =

ρ

X= 0.475/sec

W =ρ

µ− λ= 38sec.

2 On the other hand:

Pr {W > 20sec} = ρe−(µ−λ)20 = 0.95e−0.5 = 0.5762.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 9

Calls arrive to a call-center according to a Poisson process withintensity of 2 calls per minute. The call holding times areexponentially distributed with an average of 5 minutes. Callsthat find all operators busy are blocked.

1 Give the Kendall notation of the system.2 Consider a call that has lasted already 5 minutes. What is

the probability that it lasts at least 5 minutes more?3 How many operators are necessary to keep the blocking

probability below 5%?

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 9 - Solution

1 M/M/m/m with λ = 2 call/min, µ = 1/5 call/min, ρ = 10.2 We can write

Pr {call on for another 5 minutes|already on for 5 minutes} =

=Pr {call on for more than 5 minutes} =

=1−(1− e−5µ) =

1e

.

3 Using an Erlang table

B(m, ρ) =ρm

m!p0 =

ρm/m!∑mn=0

ρn

n!

≤ 0.05 ⇒ m = 15.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 10

Consider a gas station located on a highway with 5 pumps.Cars arrive to the gas station according to a Poisson process atrate 50 cars/hour. Any car able to enter the gas station stops byone of the available pumps. If all pumps are occupied, thedriver will not enter the gas station. The gas station has threeworkers to service the cars. Each car takes an exponentialamount of time for service with average of 5 minutes. Theworkers remember the order in which cars arrived so theyservice the cars on a first come first serviced basis. In the longrun:

1 What is the probability that all workers are idle?2 What is the probability that an arriving car will be able to

enter the gas station?

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 10

3 What is the probability that a car will have to wait for aworker?

4 On average, how many cars will find all pumps occupied inone hour?

5 On average, how many cars will be in the station?6 On average, how many cars waiting for service in the

station?7 Assume that a driver is in a hurry, so he will enter the gas

station if and only if he will be serviced immediately. Whatis the probability that he will enter this gas station?

8 On average, how long a car will have to wait for service?

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 10 - Solution

We can model the system as M/M/3/5 with µ = 60/5 = 12car/hr.

1

Pr {all workers are idle} = p0 = 0.015173

2

Pr {an arriving car will be able to enter the gas station} = 1− p5 =

= 1− 0.352882 =

= 0.647118

3

Pr {car will have to wait for a worker} = p3 + p4 + p5 =

= 0.1829 + 0.2541 + 0.3529 = 0.7899

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 10 - Solution

4

E [number cars will find all pumps occupied in one hour] = λp5 = (50)(0.3529) =

= 17.645 cars/hour

5

E [number of cars will be in the station] = N =

= 3.656 cars

6

E [number of cars waiting for service] = Nq =

= 0.96 cars

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 10 - Solution

7

Pr {driver will be serviced immediately} = p0 + p1 + p2 =

= 1− 0.7899 = 0.2101

8

E [waiting time for service] = Wq =Nq

λ(1− p5)=

=0.96

50(0.6472)= 0.03 hours = 1.78 min

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 11

Authorities at Ciampino Airport have established a new terminalfor departure. It is estimated that passengers will arrive to thenew terminal at rate 20 passenger per hour. Each passengerneeds an average of 8 minutes for check-in. The authoritieswant to decide how many check-in counters should be opened.Assume that the arrival process is Poisson and the service timeis exponential. Find:

1 The minimum number of counters so that the averagequeue length does not grow to∞.

2 The minimum number of counters such that the averagenumber of passengers in line is less than five.

3 The minimum number of counters such that the averagetime for check-in and receiving the boarding pass is lessthan 15 minutes.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 11 - Solution

We have µ = 60/8 = 7.5 passenger/hr.1 We need λ < mµ for stability.

m = 1⇒ λ

mµ= 2.66 m = 2⇒ λ

mµ= 1.33

m = 3⇒ λ

mµ= 0.889.

Hence m ≥ 3.2 Using the formulas for M/M/m queue:

m = 3 ⇒ N = 9.05m = 4 ⇒ N = 3.42.

Hence m ≥ 4.Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 11 - Solution

3 Using the formulas for M/M/m queue:

m = 3 ⇒ W = 0.45 hours = 27.1 minm = 4 ⇒ W = 0.17 hours = 10.3 min.

Hence m ≥ 4.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 12

Consider the M/G/1 queue with immediate feedback as shown.Arrivals come from a Poisson process at rate λ at point A.Immediately after a service time completion, the job tosses acoin to decide randomly with probability 1− p to re-enter thequeue for another service, or leaves the system altogether withprobability p.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 12

The individual service times have a general distribution with pdfetc. given as per our usual notation as b(t), B(t), LB(s) andmean X . Note that because of the immediate feedback, aparticular job entering at A, may get served for one or moresuch service times before it finally leaves the system.

Consider the system state (i. e. number in the system) atthe imbedded time instants just after a job finally leaves thesystem. For these imbedded points, find p0 and thegenerating function Gn(z).

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 12 - Solution

Let q = 1− p. We start evaluating the effective service timedistribution Laplace-transform:

LB∗(s) =∞∑

k=1

pLB(s) [qLB(s)]k−1 =pLB(s)

1− qLB(s),

with mean effective service time

X ∗ =∞∑

k=1

pqk−1kX =pX

(1− q)2 =Xp

and effective traffic

ρ∗ = λX ∗ =λXp

p.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 12 - Solution

Drawing an analogy with the basic M/G/1 queue, we can thenwrite

Gn(z) = p0(1− z)LB∗(λ− λz)

LB∗(λ− λz)− zwith p0 = 1− ρ∗.

Simplifying, we get

Gn(z) =

[1− λX

p

]p(1− z)LB(λ− λz)

(p + qz)LB(λ− λz)− z,

with

p0 = 1− λXp

=p − ρ

p.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 13

Consider arrivals coming in a random time interval (pdf b(t), cdfB(t) and Laplace-transform LB(s)) from a Poisson process withrate λ. We define Ak as the probability of there being k or morearrivals in such a time interval.Show analytically that

Ak =

∫ +∞

0

(λx)k−1

(k − 1)!e−λx [1− B(x)]λdx k = 1,2, · · · ,+∞.

(1)

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 13 - Solution

Note that we can write:

Ak = Pr {k or more arrivals in the time interval}Ak+1 = Pr {k + 1 or more arrivals in the time interval}

⇒ Ak = Ak+1 + Pr {k arrivals in the time interval} .

Hence

Ak = Ak+1 +

∫ ∞0

(λx)k

k !e−λxb(x)dx

⇒ Ak+1 = Ak −∫ ∞

0

(λx)k

k !e−λxb(x)dx . (2)

We prove (1) by mathematical induction by first showing that itholds for k = 1 and then using the recursion of (2) to show thatif it holds for k then it will also hold for k + 1.

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 13 - Solution

For k = 1

A1 =∞∑

j=1

∫ ∞0

(λx)j

j!e−λxb(x)dx =

∫ ∞0

(1− e−λx

)b(x)dx =

= 1−∫ ∞

0e−λxb(x)dx .

Integrating by parts, we can show that∫e−λxb(x)dx = e−λxB(x) + λ

∫e−λxB(x)dx , (3)

and hence ∫ ∞0

e−λxb(x)dx = λ

∫ ∞0

e−λxB(x)dx .

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 13 - Solution

Moreover1 = λ

∫ ∞0

e−λxdx ,

thereforeA1 =

∫ ∞0

e−λx [1− B(x)]λdx ,

as given by (1) for the case k = 1. Using the recursion of (2)and assuming (1) holds for k , we get the following for k + 1

Ak+1 = λ

∫ ∞0

(λx)k−1

(k − 1)!e−λx [1− B(x)] dx−

∫ ∞0

(λx)k

k !e−λxb(x)dx .

(4)

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory

Exercise 13 - Solution

Integrating by parts, we can show that

λ

∫ ∞0

(λx)k−1

(k − 1)!e−λx [1− B(x)] dx =

=

∫ ∞0

(λx)k

k !e−λx [λ(1− B(x)) + b(x)] dx .

(5)

Substituting (5) in (4), we get the desired result

Ak+1 =

∫ ∞0

(λx)k

k !e−λx {[λ(1− B(x)) + b(x)]− b(x)}dx =

=

∫ ∞0

(λx)k

k !e−λxλ [1− B(x)] dx .

Ing. Alfredo Todini Dipartimento INFOCOM Università di Roma “Sapienza”

4 - Exercises on queueing theory