The IBM
Technology Leadership Council from Brazil has translated to Portuguese and published
two brief articles I have written on virtual capacity. Here are the public
links:
As
some of you –like me- might not be able to fully understand Portuguese, I expose
below the English version for both mini papers.
Demystifying Virtual Capacity, Part I
In a virtualized system virtual machines share the
underlying physical machine (PM). This physical machine has a well-defined
processing capacity. Let us call virtual capacity to the actual capacity used
by a virtual machine.
How much of the real physical capacity goes to a
particular virtual machine (VM)? What are the parameters that determine the virtual
capacity? In this paper we will briefly review these factors. Different
hypervisors and virtualization technologies use different names for them, but
in all the cases the underlying concepts are largely the same.
·
Physical Machine capacity. The virtualization layer distributes the PM capacity
among its VMs. Of course, this PM capacity is the absolute limit of the virtual
capacity: a hosted VM cannot be larger than the hosting PM. Virtualization
overhead should also be taken into account. The capacity is typically measured
in processor cores or aggregated CPU cycles (MHz).
·
Guaranteed capacity. This is the capacity the VM will have for sure when/if
demanded. In example, consider a guaranteed capacity of 4 cores. If the VM
workload demand is 2 cores, the VM will use 2 cores. But if the demand is 5
cores, it will use 4 for sure and the remaining 1 core may be used or not
depending on additional factors. It is also called entitlement and reservation.
It’s measured in capacity units.
·
Exclusive use attribute. Flag or binary value indicating if the guaranteed
capacity is set aside for the exclusive use of the VM. If it is not, the unused
guaranteed capacity is available for use by the rest of VMs sharing the PM. Other
name for this parameter is dedicated use.
·
Limit / cap attribute. Flag or binary value that indicates if the
guaranteed capacity can be exceeded or not. May the VM virtual capacity go
beyond the guaranteed capacity in case of need? The response is yes if
unlimited / uncapped, and no if limited / capped. Some hypervisors specify a
limit capacity not tied to the guaranteed capacity.
·
Virtual cores. A fundamental, but sometimes tricky concept, and the
link between the physical and the virtual world. The operative system inside
the VM sees (virtual) cores and dispatches runnable processes to them. Then the
hypervisor dispatches virtual cores to physical cores. The number of virtual
cores may limit the virtual capacity: i.e. a VM with 2 virtual cores never can have
a virtual capacity greater than 2 physical cores.
·
Relative priority. This parameter sets relative priorities between VMs that
compete for capacity. This competence may happen when the sum of demands are
greater than the PM capacity. You can find this concept under several names
like uncapped weight and shares.
The actual virtual capacity depends on all the above
factors. Let's go from theory to practice, and play with a simple scenario: two
VMs, the red and the blue, sharing an 8 core PM.
Red and blue virtual machines are both defined in the
same way:
·
Guaranteed capacity:
4 cores.
·
Exclusive
use: NO.
·
Uncapped /
Unlimited.
·
Virtual
cores: 8.
·
Relative
priority: 128.
What do you think it would happen when red customers
place a demand on the red VM of 5 cores, and at the same time blue customers
place a demand on the blue VM of 5 cores?
According to the above parameterization, it's possible
for the red VM to use 5 physical cores because it's uncapped/unlimited and it has at least 5 virtual cores.
But to be able to go beyond its guarantee (4 cores), there must be available
free physical capacity. And this is not the case, because the other VM -the
blue VM- is using its 4 cores of guaranteed capacity.
So the final capacity distribution in the above
conditions is: the red VM is using 4 cores, and the blue VM is using 4 cores.
Consequently the physical machine is 100% busy (all 8 cores used). You may
conclude, from the sizer point of view, that the physical machine is
undersized, not being able to meet all demands placed on it.
What would happen if the blue demand decreases from 5
to 1 core? In the forthcoming second part we will solve this and will play with
more complex and subtle cases.
Demystifying Virtual Capacity, Part II
In the previous mini paper we defined the virtual
capacity concept and identified the generic factors it depends on: physical
machine (PM) capacity, guaranteed capacity, exclusive use attribute, limit /
cap attribute and relative priority.
A very simple thought scenario was proposed: an 8-core
PM with two virtual machines (VM), the red and the blue, parameterized with the
following configuration:
VM
|
Guarant. Capacity
|
vCores
|
Exclusive Use
|
Limit / Cap
|
Priority
|
Red
|
4
|
8
|
No
|
No
|
128
|
Blue
|
4
|
8
|
No
|
No
|
128
|
If the red demand is 5 cores and the blue demand is 1
core, what would be the resulting capacity distribution?
The blue will get 1 core, as this demand is well below
its guaranteed 4 cores. The remaining 3 cores are not used and, as it has not
the exclusive use attribute set, they are ceded back as free capacity.
The red usage increase to 5 cores, 4 of them coming
from its guaranteed capacity and the additional 1 core coming from the
available free capacity. Now the PM is 75% busy (6 of 8 cores) and there are no
unsatisfied demands.
A general rule is that when all the VMs are uncapped
and without exclusivity, and the sum of all demands are less than the PM capacity
all VM demands can be satisfied.
Let’s consider a case with competence, that is, the PM
capacity is not enough to satisfy the sum of VM demands (being all of them uncapped
and with no exclusive use). How the scarce PM capacity is distributed?
Suppose
the same 8-core PM with 3 VMs, the red, the blue and the green, with the
following configuration:
VM
|
Guarant. Capacity
|
vCores
|
Exclusive Use
|
Limit / Cap
|
Priority
|
Red
|
3
|
8
|
No
|
No
|
128
|
Blue
|
3
|
8
|
No
|
No
|
128
|
Green
|
2
|
8
|
No
|
No
|
128
|
The
demands are: red and blue 4 cores, and green 1 core. The sum of demands are 9
cores, more than the physical capacity (8 cores).
First group, VMs with demands less or equal than their
guarantees. They are serviced and the rest of the guarantee is ceded and
increase the free capacity. The green VM is in this group: it uses 1 core and
cedes 1 core.
Second group, VMs with demands higher than their guarantees.
They receive their guarantee plus the right proportion, according to their
priorities, of the free capacity. The red and the blue are in this group, they
both use 3 cores (the guaranteed) plus 0.5 cores, coming from the 1 core
divided into two equal parts, as both VMs have the same priority and thus
receive the same fraction. Is this situation, the PM is 100% busy and there are
unsatisfied demands.
What would happen if the green VM is shutdown or its
demand drops to zero? Or if the blue VM is limited/capped? Or if the red VM
number of virtual cores is set to 2? Or if the green demand goes up to 4 cores?
Calculations to solve the generic case, if
you know what to do and how to do them, are simple. I’ve created a spreadsheet
implementing them. Simple, functional (but not fool proof): the
virtual capacity demystifier. It comes with a companion presentation
illustrating its usage. You should experiment with the tool to fully comprehend
and understand virtual capacities.
A final word: perhaps I should have added ths
following subtitle: “...in a perfect world”. In the real world there are second
order effects -overheads, inefficiencies, cache misses,...- that diminish virtual
capacities we have obtained. These effects belong to the realm of advanced practitioners
and performance gurus, but you should be aware of them.