# Resource Calculation on XenDesktop and XenApp part 01

Resource Calculation on XenDesktop and XenApp part 01

Almost every day I am asked the question that every virtualization technologist hates…

“How long is a piece of string?”

Really, every day. O.K. some days I am kidnapped by an alien race with advanced technology that gives me unlimited access to expensive lab equipment like large storage arrays and switches. But every other day “How long is a piece of string?”

Or:

How tall is a person?

Really you meet a lot of people, tell me how tall is a person?

I mean, say they are using Microsoft Office, how tall is a person?

O.K. You are a Citrix guy, you meet a lot of people. More people than me. So I’m asking for a normal person using Microsoft Office… how tall is that person?

I’m really frustrated; you have to know this answer. You have been doing this for years. Just tell me how tall is a person?

A normal person. How tall is a normal person?

Now in between each of those lines picture me in my robe, headband, and Katana. I say “It depends… my difficulty answering this question causes me dishonor.” Then I perform ritual suicide. They revive me, give me a blood transfusion then ask the next question.

Over and over. Over and over. Did I say “It depends?” Over and over and over.

Maybe they don’t ask how tall, how fat, how skinny, or how good looking is the normal user. But they might as well. So here is the first in a series of blogs about how to put a number on how many users will fit on a given set of hardware.

From the most basic levels we need a way to represent the model of resource utilization. We can use a way to represent the physical resource utilization of a desktop.

Let’s start with the simplest example of constant CPU utilization.

We can represent CPU utilization on a graph using a variable t for time and a variable c for CPU. Lets look at the simple example of c=0.1 That is that CPU utilization is constant regardless of time at 0.1 or 10% of Total CPU.

So:

c= 0.1

c = f(t)= 0.1

f’(t) = 0

That is that the first derivative of f(t) or c is zero. The rate of change of CPU utilization is zero.

The acceleration of the CPU utilization is also zero.

The integral of this function is the area or the total cycles used over the period of time. This can be represented in the following equation:

Let’s looks at a slightly more complex example.

If the CPU utilization is periodic with repetitive peaks followed by a trough of idle time then it could look like this. We could represent this by the equation:

f(t)=sint

But a more likely form if we were to use a tool to plot a series of measurements and then choose a graph that most closely resembles the data points would be:

This is a modification of the sine wave. Start to work from inside out of the equation. The sine wave starts at zero and at pi/2 radians the sine wave reaches its maximum, then it reaches zero at pi, minimum at 1.5 pi or 3pi/2 and back to zero. We shift this to start at its minimum from 3pi/2 radians to 0 and then adjust for its amplitude.

The sine wave is based on the relationship of the angle and the distance from the origin and the unit circle so this minimum and maximum is at 1. We create an amplitude “a” so that the range from center of the sine wave is plus or minus “a”. By adding a value of the amount “a” the end of the equation we keep the equation positive at all points. So…

This function varies from 0 to maximum 2a or 0.2 then to a minimum at 0 again at the period 2pi seconds. It is unlikely that your logs would record data this way so even if you saw a periodic pattern such as this it would be in a period not in terms of pi radians of seconds but of seconds.

We can change the period to not reflect pi by dividing the term inside the sine (that is (t- 3pi/2) as a quantity multiplied by the quantity (s/2pi) where s is the value of the number of seconds it takes to machine to cycle through its periodic rise and fall from minimum to max back to minimum before it starts to rise again for the next period of oscillation.

f(t)=0.1[sin〖s/2π〗 (t-3π/2)]+0.1

Let’s describe this in terms of CPU utilization.

This is a periodic function of CPU utilization from a minimum f(t) = 0 at t=0, to a maximum of 0.2 and back to 0 in s seconds. Let’s say this happens in a 5 second interval.

f(t)=0.1[sin〖5/2π〗 (t-3π/2)]+0.1

Great. Now we can find the rate of change of the CPU utilization by taking the first derivative.

f^' (t)=1/4π [cos(5/2π (t-3π/2)) ]

The acceleration of CPU utilization is:

f^'' (t)=(-5)/(8π^2 ) [sin〖5/2π (t-3π/2)〗 ]

We can integrate f(t) to find the CPU utilization times time. In analogy we could look at speed as a relationship of miles/hours or miles divided by hours. As in “I drove 60 miles in 1 hour so my speed was 60 miles per hour.” In a different situation I could say that “I rented 3 hotel rooms for 2 nights, so I used 6 room*nights.” The product represents an area or the product of the 2 variables. 6 room*nights could be 1 room for 6 nights, 6 rooms for 1 night, 2 rooms for 3 nights, or 3 rooms for 2 nights. In any of these ways I used 6 room*nights and will be charged for 6. We will account for the same kind of tenancy for resource utilization in a latter section of this blog.

Going with this example, the concept of speed while obvious in the “60 miles per hour” reference is not as obvious in this example but we could look it like this.

Begin at:

No rooms, t=0 (0,0)

1 room, t=1 (1,1)

2 rooms, t=2 (2,2)

This could be defined as rooms r=F(t)=t

F(t)=t

F’(t)=1

F’(t) or rate of change of 1 room per night. The story might be every night he came back to the hotel so drunk that he forgot that he checked in and rented a new room. (0,0), (1,1), (2,2), (3,3). His rate of change of rooms is 1 per day. It is like a memory leak, each time cycle causes more memory to be used.

Lets look at disk IO. Lets say a machine starts with a large spike in IO at boot and slowly lessens as time goes on until it approaches zero.

Let say that I is disk IO and the function is represented by:

i=i(t)=1/t for a range that is a small number but not so small so that it approaches zero. (if we did it would be infinite IO and that would be bad for our disk)

i(t)=1/t

i^' (t)=(-1)/t^2

i^'' (t)=2/t^3

∫_u^v▒〖i(t)=ln〖t di/dt〗 〗

Now we know all kinds of things about disk IO like its rate of change and IO*second etc.

We can create equations that represent these physical resources over time where they approach zero or another constant, are ever increasing or cyclic or whatever by combining these relative terms to create a function that describes their usage.

We can create the equations that define their tenancy by these kinds of manipulations. Once that is defined then we can resolve multi-dimensional equations like:

R=12m/i sin〖2t+ci ln〖t+mi(2t/(4t^2 ))〗 〗

Where

R= resources

c= CPU

m=memory

t= time

Thanks for hanging out and we will eventually move out of the theoretical and into the real world of calculations. But hey you are the one who asked for it…