# CS457 - System Performance Evaluation - Winter 2010

## Public Service Announcements

• class on assignment 3
• possible tutorial

# Birth & Death Processes

#### Derivation

• See previous lecture.
• See pdf

#### Basic Result

dp_j(t) / dt = \lambda_j-1 p_j-1(t) + \mu_j+1 p_j+1(t) - (\lambda_j + \mu_j) p_j(t)

Reminder. Transient and steady states are different. We are interest in the steady state. The steady state is defined as having stationary (not time-dependent) probabilities.

That is: dp_j(t) / dt = 0.

Then

• \lambda_j-1 p_j-1(t) + \mu_j+1 p_j+1(t) - (\lambda_j + \mu_j) p_j(t) = 0

Solve this iteratively

1. l0 p0 = m1 p1 => p1 = (l0/m1) p0
2. (l1 + m1) p1 = l0 p0 + m2 p2 => (l1 + m1) (l0/m1) p0 = l0 p0 + m2 p2 => p2 = p0 (l1*l0 / m1*m0)
3. ...
4. pn = p0 (l_n-1*...*l1*l0 / m_n-1 *...*m1*m0)
5. Set p0 by the condition sum_n pn = 1.

This looks like you could solve it further, but you can't. How could you possibly solve the differential equation above, in that case?

What do we do? Try simplified examples.

## The Simplest Example M/M/1

First M: Markovian (Exponential) birth (interarrival) times

Second M: Markovian (Exponential) life/death (service) times

1: one server

Assumptions:

1. \lambda_j = \lambda
2. \mu_j = \mu
3. Define r = \lambda / \mu

Then

1. pn = r^n p0
2. p0 = 1 / (1 + r + r^2 + ...) = 1 - r.
3. pn = (1 - r) * r^n.

#### Useful tricks.

1. S = 1 + r + r^2 + r^3 + ... = 1 + r * ( 1 + r + r^2 + r^3 + ... ) = 1 + r * S
Therefore, S * (1-r) = 1and S = 1 / (1 - r)
2. dS/dr = 1 + 2r + 3r^2 + 4r^3 + ... = (1 + r + r^2 + ...) + ( r + 2r^2 + 3r^3 +... ) = S + r ( 1 + 2r + 3r^2 + ... ) = S + r dS/dr

Therefore, dS/dr = S + r dS/dr and dS/dr = S / (1 - r) = 1 / (1 - r)^2

But E(N) = sum_n n*p_n = (1 - r) (r + 2 r^2 + 3 r^3 + ... ) = (1 - r ) (dS/dr - S) = (1 - r ) (1 / (1 - r)^2 - 1 / (1 - r) ) = 1 / (1 - r) - 1 = r / (1 - r)

#### Results

The mean number of requests in the system is E[N] = sum_n n * (1 - r ) * r^n = r / (1 - r)

• Goes to infinity as r -> 1. Why?

Little's law

• Mean response time: E(R) = (1/\lambda) * E(N) = 1 / (\mu - \lambda)
• Goes to infinity as \lambda -> \mu from below. Why?
• What happens when \lambda > \mu?

Mean waiting time E[W]

1. Mean service time is 1/\mu
2. Mean waiting time is E[W] = E[R] - 1/\mu = r / ( \mu (1-r) ) = r / (\mu - \lambda)
3. Mean waiting time goes to infinity as \lambda -> \mu from below. Why?

Mean number of jobs in the queue E[Nq]

1. Little's law applied to the queue: \lambda*E[w] = E[Eq]
2. E[nq] = r^2 / (1-r)

Utilization

U = 1 - p0 = 1 - (1-r) = r = \lambda / \mu

Note that you can only get utilization at 1 by having the response time go to infinity. Why?

## Example 2: Finite Queue

Let the maximum size of the queue be m.

• What happens to requests that arrive when the queue is full?
 Number of requests in the system, j 0 1 2 ... m-1 m Probability of a birth, \lambda_j \lambda \lambda \lambda ... \lambda 0 Probability of a death, \mu_j 0 \mu \mu ... \mu \mu

#### Results

Result of incremental solution

• p_n = p_0 r^n
• 1 = \sum_n p_n = p_0 \sum_n r^n = p_0 ( 1 - r^(m+1) ) / ( 1 - r )
• p_n = { (1-r) r^n } / (1 - r^(m+1))

What's the story

• The system is guaranteed to be stables because no more than m requests can be in the system at once.
• Thus, the solution is valid for all values of r
• As r -> 1 use l'Hopital's rule 1 = p_0 (m+1) and p_n = 1 / (m+1)
• For r < 1 the probability is skewed toward low numbers of requests.
• For r >= 1 the probability is uniform. As soon as a request is processed, all other requests move up, and a new request is accepted.

## Another Example: Two Servers

 Number of requests in the system, j 0 1 2 3 ... Probability of a birth, \lambda_j \lambda \lambda \lambda \lambda ... Probability of a death, \mu_j 0 \mu 2 \mu 2 \mu ...

#### Incremental Solution

• j = 0: \mu p_1 = \lambda p_0 ==> p_1 = p_0 * 2r, where r = \lambda / (2 \mu)
• j = 1: 2 \mu p_2 = ((\lambda + \mu) p_1 - \lambda p_0 ) / (2 \mu) ==> p_2 = p_0 * 2 r^2
• j = 2: 2 \mu p_3 = ((\lambda + \mu) p_2 - \lambda p_1 ) / (2 \mu) ==> p_3 = p_0 * 2 r^3
• ...
• j = n-1: 2 \mu p_n = ((\lambda + \mu) p_n-1 - \lambda p_n-2 ) / (2 \mu) ==> p_n = p_0 * 2 r^n

Now normalize,

• 1 = \sum_n p_n = p_0( 1 + 2 \sum_(n=1) r^n ) = p_0 ( 2 \sum_(n=0) r^n - 1 ) = p_0 ( 2 / (1-r) - 1 ) = p_0 ( 1 + r ) / ( 1 - r )
• p_0 = (1-r) / (1+r) = (2 \mu + \lambda) / (2 \mu - \lambda)

Thus, p_n = 2 (1-r) r^n / (1+r)

#### Results

The mean number of jobs in the system is

• E[N] = sum_n n * 2 * (1 - r ) * r^n / (1+r) = {2 * (1-r) / (1+r) } \sum_n n*r^n = 2*r / (1-r^2)
• Why is this different from the result above with \mu doubled?
• Goes to infinity as r -> 1. Why?

Little's law

• Mean response time: E(R) = (1/\lambda) * E(N) = 2* / { \mu * (1-r^2) }
• Goes to infinity as \lambda -> \mu from below. Why?
• What happens when \lambda > \mu?