Solutions to COMP9334 Week 8 Sample Problems Problem 1: Customers arrive at a grocery store s checkout counter according to a Poisson process with rate 1 per minute. Each customer carries a number of items that is uniformly distributed between 1 and. The store has 2 checkout counter, each capable of processing items at a rate of 15 per minute. To reduce the customer waiting time in the queue, the store manager considers dedicating one of the two counters to customers with x items or less and dedicating the other counter to customers with more than x items. Write a small computer program to find the value of x that minimizes the average customer waiting time. Solution: First note that one counter is not sufficient to serve all the customers. If we consider all the customers together, each customer carries on average 20.5 items, which requires 20.5 = 1.37 minutes to serve. Since the customer arrival rate is 1 per minute, the 15 utilization will be above 1 if only one counter is used. Assume that Counter 1 serves customers with x items or less and Counter 2 serves customers with more than x items, where 1 x 39. Let λ i denote the customer arrival rate to Counter i, i = 1, 2, and r be the rate of processing items at each counter. By definition, we have r = 15 items per minute. Let us consider Counter 1 first. Since only customers with x items or less go to Counter 1, λ 1 = x per minute. The customers arriving at Counter 1 bring with them 1, 2,..., x items uniformly distributed. Let S 1 denote the customer service time at Counter 1. We have x 1 E[S 1 ] = x i r = 1 + x E[S 2 1] = x ( ) 1 i 2 x = r x i 2 225x Let ρ 1 = λ 1 E[S 1 ]. For ρ 1 < 1, we must have x 34. By the P-K formula, the mean waiting time at Counter 1 is W 1 = λ 1E[S 2 1] 2(1 ρ 1 ) 1
Similarly, the customer arrival rate to Counter 2 is λ 2 customer service time at Counter 2. Then, = x. Let S 2 denote the E[S 2 2] = E[S 2 ] = 1 x i r = x + 41 ( ) 1 i 2 x = r i 2 9000 225x Let ρ 2 = λ 2 E[S 2 ]. For ρ 2 < 1, we must have x 21. By the P-K formula, the mean waiting time at Counter 2 is W 2 = λ 2E[S 2 2] 2(1 ρ 2 ) The mean waiting time of the customers is given by W = x W 1 + x W 2 Note that W is a function of x for 21 x 34. We write a computer program (Matlab file week08 q1.m) to calculate how W varies with x. The figure below shows how W varies with x. It can be seen that the minimum value of W is achieved at x = 28. 80 70 60 Meaning waiting time 50 20 10 0 20 22 24 26 28 32 34 x 2
Problem 2: A computer system receives requests from a Poisson process at a rate of 10 requests per second. Assume that % of the requests are of type a and the remaining are of type b. For request type a, its average service time is 0.1 seconds and the coefficient of variation of its service time is 1.5. For request type b, its average service time is 0.08 seconds and the coefficient of variation of its service time is 1.2. Compute the average response time for each type of requests under the following scenarios: 1. Requests of types a and b have equal priorities 2. Requests of type b have non-preemptive priority over requests of type a 3. Requests of type b have preemptive priority over requests of type a Solution: Let C a, σ a, E[S a ] and E[S 2 a] denote, respectively, the coefficient of variation, standard deviation, mean and second moment of the service time of requests of type a. Recall that the coefficient of variation of a random variable is its standard deviation divided by mean, i.e C a = σ a /E[S a ]. Using the relation we have σ 2 a = E[S 2 a] (E[S a ]) 2 E[S 2 a] = (E[S a ]) 2 (1 + C 2 a) Since we know E[S a ] = 0.1 and C a = 1.5, we can compute E[S 2 a] using the above equation. Similarly, let C b, σ b, E[S b ] and E[S 2 b ] denote, respectively, the coefficient of variation, standard deviation, mean and second moment of the service time of requests of type b. We have E[S 2 b ] = (E[S b ]) 2 (1 + C 2 b ) Since we know E[S b ] = 0.08 and C b = 1.2, we can compute E[S 2 b ] using the above equation. 1. Requests of types a and b have equal priorities: This is an M/G/1 queue without priority. The arrival rate is 10 requests per second (= λ). Since % of the request are type a and the remaining are type b, we have the mean service time E[S] and second moment E[S 2 ] of the aggregate are, respectively, E[S] = 0.3E[S a ] + 0.7E[S b ] 3
The mean response time is therefore where ρ = λe[s]. E[S 2 ] = 0.3E[S 2 a] + 0.7E[S 2 b ] T = E[S] + λe[s2 ] 2(1 ρ) 2. Requests of type b have non-preemptive priority over requests of type a: Let R = 1 2 (0.3λE[S2 a] + 0.7λE[S 2 b ]) The response time of type b requests is The response time of type a requests is T a = E[S a ] + ρ a = 0.3λE[S a ] ρ b = 0.7λE[S b ] T b = E[S b ] + R 1 ρ b R (1 ρ a ρ b )(1 ρ b ) 3. Requests of type b have preemptive priority over requests of type a: Let R a = 1 2 (0.3λE[S2 a] + 0.7λE[S 2 b ]) The response time of type b requests is The response time of type a requests is R b = 1 2 (0.7λE[S2 b ]) ρ a = 0.3λE[S a ] ρ b = 0.7λE[S b ] R b T b = E[S b ] + 1 ρ b T a = E[S a] R a + 1 ρ b (1 ρ a ρ b )(1 ρ b ) The response time results are summarized in the following table: 4
Type Part 1 Part 2 Part 3 a 0.8246 1.7787 1.9059 b 0.8246 0.3150 0.2042 Observe that the response time for type b requests have become better because it has a higher priority, this is of course at the expense of type a requests which have a lower priority. Problem 3: A communication line capable of transmitting at a rate of 50 kbits per second will be used to accommodate 10 sessions each generating Poisson traffic at a rate of 150 packets per minute. Packet lengths are distributed as follows: 10% of the packets are 100 bits long and the rest are 1500 bits long. Find the mean queue length and how long a packet has to wait before it starts its transmission on the communication line. You can assume that there is sufficient buffer space to store the queueing packets. Solution: The system behaves as an M/G/1 queueing system. Since there are 10 sessions each generating Poisson traffic at a rate of 150 packets per minute, the packet arrival rate λ to the communication line is 1500 packets per minute or 25 packets per second. With a transmission rate of 50 kbits per second, a 100-bit packet requires a transmission time (service time in queueing theory terminology) of 0.002 seconds and a 1500-bit packet requires a transmission time of 0.029 seconds. Given that 10% of the packets are 100 bits long and the rest are 1500 bits long, the mean service time is E[S] = 0.1 0.002 + 0.9 0.029 = 0.026 sec and the second moment of the service time is E[S 2 ] = 0.1 0.002 2 + 0.9 0.029 2 = 7.573 10 4 sec 2 The mean waiting time W, according to the P-K formula, which applies to an M/G/1 queueing system, is λe[s 2 ] W = = 0.027 sec 2(1 λe[s]) By the Little s Law, the mean queue length in the buffer is given by N w = λ W = 0.6762 packets 5