# CS457 - System Performance Evaluation - Winter 2010

## Public Service Announcement

1. pdf available
2. Markovian service times

# 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)

## Steady State Solutions...

1. pn = p0 (l_(n-1)*...*l1*l0 / m_n *...*m1)
2. Set p0 by the condition sum_n p_n = 1.

## Example 1: Infinite Queue

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.

### Results

The mean number of jobs in the system is E[N] = r / (1 - r)

Little's law

• Mean response time: E(R) = (1/\lambda) * E(N) = 1 / (\mu - \lambda)

Mean waiting time E[W]

1. Mean waiting time is E[W] = r / (\mu - \lambda)

Mean number of jobs in the queue E[Nq]

1. E[nq] = r^2 / (1-r)

Utilization

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

## Example 2: Finite Queue

 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

### Incremental solution

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

### Results

#### Number of Requests

• E[N] = {r + 2r^2 + 3r^3 + ... + mr^m}) / {1 + r + r^2 + ... + r^m}

#### Response Time

• E[R] = E[N] / \lambda = {1/\mu} {1 + 2r + 3r^2 + ... + mr^(m-1)} / {1 + r + r^2 + ... + r^m}

#### Utilization

• U = r ( 1 + r + ... + r^(m-1) ) / ( 1 + r + ... + r^m )
• r -> 0: U = r
• r = 1: U = 1 - (1/(m+1)) = m / (m+1)
• r -> infinity: U -> 1

## Example 3: Two Servers versus One Server Twice as Powerful

### One Server Twice as Powerful

#### Service rate and time:

• service rate: \nu = 2 \mu
• service time 1 / \nu = 1 / (2\nu)
• s = r / 2

#### Number of requests

• E[N] = s / (1-s) = r / (2-r)
• This is not quite as good as half as many. Why?

#### Response Time

• R[N] = 1 / (\nu - \lambda) = 1 / {\nu (1 - s)} = 1 / {2 \mu (1-r/2)} = 1 / {\mu (2-r)}
• This is not quite as good as twice as fast.

#### Utilization

• U = s = r/2
• Utilization is exactly one half, as we expect.

### Two Servers with One Queue

 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 * r, where r = \lambda / (\mu)
• j = 1: 2 \mu p_2 = ((\lambda + \mu) p_1 - \lambda p_0 ) / (2 \mu) ==> p_2 = p_0 * (1/2 r^2
• j = 2: 2 \mu p_3 = ((\lambda + \mu) p_2 - \lambda p_1 ) / (2 \mu) ==> p_3 = p_0 * (1/4) r^3
• ...
• j = n-1: 2 \mu p_n = ((\lambda + \mu) p_n-1 - \lambda p_n-2 ) / (2 \mu) ==> p_n = p_0 * (1/2)^(n-1) r^n

Now normalize,

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

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

#### Results

The mean number of jobs in the system is

• E[N] = sum_n n * (2 - r ) * r^n / (2+r) = {(2-r) / (2+r) } \sum_n n*(r/2)^n = 2*r / {(2-r)(2+r)} = r / {(2-r)(1+(r/2))}
• Compare this to E[N] = r / (2-r), the result for the twice as powerful server.
• We see the queue shrink by a factor of 1/(1 + (r/2))

Little's law

• Mean response time: E(R) = (1/\lambda) * E(N) = 1/ { \mu*(2-r)*(1+r/2) }
• Compare this to E[R] = 1 / {\mu (2-r) }
• We see the same response speed up by the same factor: 1/(1 + (r/2))

Utilization

• U = 1 - p_0 - 1/2 p_1= 1 - (2-r) / 2+r - (r/2) (2-r) / (2+r) = r / 2.
• Utilization does not change, as we expect.

## Example 4: Finite Population of Users (Think time Model)

Think time is exponentially distributed with rate parameter \lambda.

Service time is exponentially distributed with rate parameter \mu

 State of system (j) 0 1 2 n N-1 N Probability of birth (\lambda) N N-1 N-2 ... N-n ... 1 0 in terms of \lambda Probability of death (\mu) 0 1 1 1 1 1 in terms of \mu
• r = \lambda / \mu
• N \lambda p_0 = \mu p_1 => p_1 = N r p_0
• p_2 = N(N-1) r^2 p_0
• p_n = N(N-1)...(N - n + 1) r^n p_0
• p_0 = 1 / \sum_0^N {N! / (N-n)! } r^n

We have to understand this somehow.

1. N = 1
• think -> server -> think -> serve
• average number in server = { 1/\mu } / {1/\mu + 1/\lambda } = \lambda / ( \lambda + \mu )
• average response time = 1/\mu
• utilization = 1 - p_0 = p_1
2. N = 2
• p_0; p_1 = 2 p_0 r; p_3 = 2 p_0 r^2
• p_0 = 1 / (1 + 2r + 2r^2) = 1 - (2r + 2r^2)/ (1 + 2r + 2r^2)
• E[N] = (2r + 4r^2) / (1 + 2r + 2r^2) = ( 2r^2 - 1) / (1 + 2r + 2r^2)
• E[R] = E[N] / X - Z
• X = \mu * U = \mu * (1 - p0) = \mu (2r + 2r^2) / (1 + 2r + 2r^2)
• E[N] / X = (2r + 4r^2) / {\mu (2r + 2r^2)}
• Z = 1 / \lambda
• E[R] = (2r + 4r^2) / {\mu (2r + 2r^2)} - 1 / \lambda
E[R] = { \lambda (2r + 4r^2) + \mu (2r + 2r^2) } / { \lambda \mu (2r + 2r^2) }

Now, we would like to find the response time

Little's Law: E[R] = N/X - Z

• Z = 1/\lambda
• X = \mu ( 1 - p_0 )
• E[R] = E[N] / { \mu (1 - p_0) }

## Example 4: Deterministic Service Times

Assume that the system is stable.

Consider the system at time t

• k requests have arrived since the system started.
• Number of requests in the system is max( 0, k-t/s )
• p_n = P( n + t/s arrived between 0 and t )

p_0 = P( n < t/s ) = sum_k^n {1/k!} t^k exp(-t )

• Service time of task arriving is s(1 + max( 0, k - t/s ) )

If N > 0 then there is a request being served

• The server last started providing service at time 0
• The amount of time until a new task's service starts is

Return to: