4 - Exercises on queueing theory
Ing. Alfredo Todini
Dipartimento INFOCOM Università di Roma “Sapienza”
Exercise 1
Evaluate the Laplace transform of the function: f (t) = cos(ωt).
Exercise 1 - Solution
Writing cos(ωt) = e+jωt+e2 −jωt and applying the definition yields the result: Lf(s) = Z ∞ 0 e+jωt+e−jωt 2 e−stdt = = 1 2 Z ∞ 0 e(−s+jω)tdt + 1 2 Z ∞ 0 e(−s−jω)tdt = = 1 2 1 s − jω + 1 2 1 s + jω = s s2+ ω2.
Exercise 2
Give the queuing models for the following system. Define the arrival and service process, the number of servers, the size of the buffer and the service principle. List the relevant
performance measures.
Requests arrive to a Web server. The server can respond to M requests at a time. Responding to a request means transmitting a Web page of variable size. Requests that arrive when M requests are already under service must wait for their turn.
Exercise 2 - Solution
Web server.
Arrival process: requests from Internet users
Service process: transmission of a Web page (page size/transmission rate)
Number of servers: M Buffer size: infinite Service principle: FIFO Notation: M/G/m
Exercise 3
Exercise 3 - Solution
Let X be a random variable with pX(x ) = ∆1rect∆(x − x0),
∆ =5 and x0=7.5. We show that there is a t such that
Pr {X < t + x |X > t} 6= Pr {X < x }. Pr {X < x } = 0 if x < 5 x − 5 5 if 5 ≤ x < 10 1 if x ≥ 10. it suffices to take t = 7.5: Pr {X < 7.5 + x |X > 7.5} = x 2.5 if 0 ≤ x < 2.5
Exercise 4
You are entering a bank, where there is one clerk and there are already three customers waiting. The service of one customer takes 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 to wait more then 40 minutes? Prove your answers.
Exercise 4 - Solution
1 Your waiting time will be the sum of the service times of 4
customers, one under service, 3 waiting. Each service time has an exponential distribution with parameter 1/10. Note that due to the memoryless property of the exponential distribution it does not matter when the service of the customer at the clerk has started, his remaining service time is still exponential with the same expected value.
Exercise 4 - Solution
2 The average is the sum of the average service times. The
variance 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 X i=1 E [Xi] =40 Var [W ] = 4 X i=1 Var [Xi] =400.
Exercise 4 - Solution
Note that the sum of k independent, identically distributed exponential random variables has an Erlang distribution:
f (x ; k , λ) = λ(λx )
k −1
(k − 1)!e
Exercise 4 - Solution
The probability that you have to wait longer than 40 minutes is the probability, that there was no service completion, or only 1, 2 or 3 service completions during these 40 minutes. The sequence of services forms a Poisson process, and thus you can calculate the probabilities above.
Pr {W > 40} = 3 X i=0 (λt)i i! e −λt t=40 =0.433.
Note that the departures from a sequence of exponential services form a Poisson process, only if the server is never idle, as in this case.
Exercise 4 - Solution
Alternatively, we can use the distribution of the waiting time:
Pr {W > 40} = Z +∞ 40 λ(λt) 3 3! e −λtdt = (integrating by parts) = − (λt) 3 3! + (λt)2 2! + λt + 1 e−λt +∞ t=40 = = 3 X i=0 (λt)i i! e −λt t=40 =0.433
Exercise 5
Customers arrive to a restaurant according to a Poisson process with rate 10 customers/hour. The restaurant opens daily at 9:00 am. Find the following:
1 When the restaurant opens at 9:00 am, the workers need
30 min to arrange the tables and chairs. What is the probability that they will finish the arrangement before the arrival of a customer?
2 What is the probability that there are 15 customers in the
restaurant at 1:00 pm, given that there were 12 customers in the restaurant at 12:50 pm?
Exercise 5
3 Given that a new customer arrived at 9:13 am, what is the
expected arrival time of the next customer?
4 If a customer arrive to restaurant at 2:00 pm what is the
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
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 10 hr = 9:19 am 4
Pr {next customer will arrive before 2:10 pm | a new customer arrive at the restaurant at 2:00 pm} =
Exercise 6
Calculate the state probabilities in steady-state for the following Markov-chain with the help of global or local balance equations (λ = 100 and µ = 150).
λ λ λ
2μ 2μ 2μ
0 1 2 3 4
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) = 27 59, 9 59, 12 59, 7 59, 4 59 .
Exercise 7
Consider a queueing system with Poisson arrival process and exponential 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
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+ µp5Exercise 7 - Solution
3 p1= (λ/µ)p0 p2= (λ/µ)2p0 p3= (2!)−1(λ/µ)3p0 p4= (3!)−1(λ/µ)4p0 p5= (4!)−1(λ/µ)5p0 P5 i=0pi =1 ⇒ p0= " 1 + λ µ+ λ µ 2 + 1 2! λ µ 3 + 1 3! λ µ 4 + 1 4! λ µ 5#−1Exercise 8
You have designed a first-come first-service data processing system. You based the design on an M/M/1 queuing model. Now the users complain about poor response times. The log of the system shows that there are on average N = 19 jobs in the system and that the average processing time (service time) for one job is X = 2 seconds.
1 Estimate the system utilization, the job arrival intensity and
the average waiting time, based on the M/M/1 model.
2 What is the probability that a job would wait more than
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:
Exercise 9
Calls arrive to a call-center according to a Poisson process with intensity of 2 calls per minute. The call holding times are
exponentially distributed with an average of 5 minutes. Calls that 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
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µ = 1
e.
3 Using an Erlang table
B(m, ρ) = ρ m m!p0= ρm/m! Pm n=0 ρn n! ≤ 0.05 ⇒ m = 15.
Exercise 10
Consider a gas station located on a highway with 5 pumps. Cars arrive to the gas station according to a Poisson process at rate 50 cars/hour. Any car able to enter the gas station stops by one of the available pumps. If all pumps are occupied, the driver will not enter the gas station. The gas station has three workers to service the cars. Each car takes an exponential amount of time for service with average of 5 minutes. The workers remember the order in which cars arrived so they service the cars on a first come first serviced basis. In the long run:
1 What is the probability that all workers are idle?
Exercise 10
3 What is the probability that a car will have to wait for a
worker?
4 On average, how many cars will find all pumps occupied in
one 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. What is the probability that he will enter this gas station?
Exercise 10 - Solution
We can model the system as M/M/3/5 with µ = 60/5 = 12 car/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
Exercise 10 - Solution
4E [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=
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
Exercise 11
Authorities at Ciampino Airport have established a new terminal for departure. It is estimated that passengers will arrive to the new terminal at rate 20 passenger per hour. Each passenger needs an average of 8 minutes for check-in. The authorities want to decide how many check-in counters should be opened. Assume that the arrival process is Poisson and the service time is exponential. Find:
1 The minimum number of counters so that the average
queue length does not grow to ∞.
2 The minimum number of counters such that the average
number of passengers in line is less than five.
3 The minimum number of counters such that the average
time for check-in and receiving the boarding pass is less than 15 minutes.
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.05
Exercise 11 - Solution
3 Using the formulas for M/M/m queue:
m = 3 ⇒ W = 0.45 hours = 27.1 min
m = 4 ⇒ W = 0.17 hours = 10.3 min.
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 a coin to decide randomly with probability 1 − p to re-enter the queue for another service, or leaves the system altogether with probability p.
Exercise 12
The individual service times have a general distribution with pdf
etc. given as per our usual notation as b(t), B(t), LB(s) and
mean X . Note that because of the immediate feedback, a particular job entering at A, may get served for one or more such service times before it finally leaves the system.
Consider the system state (i. e. number in the system) at the imbedded time instants just after a job finally leaves the
system. For these imbedded points, find p0and the
Exercise 12 - Solution
Let q = 1 − p. We start evaluating the effective service time distribution Laplace-transform: LB∗(s) = ∞ X k =1 pLB(s) [qLB(s)]k −1= pLB(s) 1 − qLB(s) , with mean effective service time
X∗ = ∞ X k =1 pqk −1k X = pX (1 − q)2 = X p and effective traffic
Exercise 12 - Solution
Drawing an analogy with the basic M/G/1 queue, we can then write Gn(z) = p0 (1 − z)LB∗(λ − λz) LB∗(λ − λz) − z with p0=1 − ρ∗. Simplifying, we get Gn(z) = " 1 − λX p # p(1 − z)LB(λ − λz) (p + qz)LB(λ − λz) − z , with p0=1 − λX p = p − ρ p .
Exercise 13
Consider arrivals coming in a random time interval (pdf b(t), cdf
B(t) and Laplace-transform LB(s)) from a Poisson process with
rate λ. We define Ak as the probability of there being k or more
arrivals in such a time interval. Show analytically that
Ak = Z +∞ 0 (λx )k −1 (k − 1)!e −λx[1 − B(x )] λdx k = 1, 2, · · · , +∞. (1)
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+ Z ∞ 0 (λx )k k ! e −λxb(x )dx ⇒ Ak +1=Ak− Z ∞ 0 (λx )k k ! e −λxb(x )dx . (2)
We prove (1) by mathematical induction by first showing that it holds for k = 1 and then using the recursion of (2) to show that if it holds for k then it will also hold for k + 1.
Exercise 13 - Solution
For k = 1 A1= ∞ X j=1 Z ∞ 0 (λx )j j! e −λxb(x )dx =Z ∞ 0 1 − e−λxb(x )dx = =1 − Z ∞ 0 e−λxb(x )dx .Integrating by parts, we can show that Z e−λxb(x )dx = e−λxB(x ) + λ Z e−λxB(x )dx , (3) and hence Z ∞ Z ∞
Exercise 13 - Solution
Moreover 1 = λ Z ∞ 0 e−λxdx , therefore A1= Z ∞ 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= λ Z ∞ 0 (λx )k −1 (k − 1)!e −λx[1 − B(x )] dx −Z ∞ 0 (λx )k k ! e −λxb(x )dx . (4)
Exercise 13 - Solution
Integrating by parts, we can show that λ Z ∞ 0 (λx )k −1 (k − 1)!e −λx[1 − B(x )] dx = = Z ∞ 0 (λx )k k ! e −λx[λ(1 − B(x )) + b(x )] dx . (5)
Substituting (5) in (4), we get the desired result Ak +1= Z ∞ 0 (λx )k k ! e −λx{[λ(1 − B(x)) + b(x)] − b(x)} dx = = Z ∞(λx )k e−λxλ [1 − B(x )] dx .