For more information about the VMware Management Interface, go to www.vmware.com/support/esx2/doc/.


 

CPU Resource Management
CPU Resource Management

VMware ESX Server provides dynamic control over both the execution rate and the processor assignment of each scheduled virtual machine. The scheduler performs automatic load balancing on multiprocessor systems.

You can manage the CPU resources on a server from the VMware Management Interface, from the procfs interface on the service console and the VMware Scripting API.

For additional information on CPU management, see the cpu(8) man page.

Allocating CPU Resources
Allocating CPU Resources

Three basic parameters control the allocation of CPU resources to each virtual machine:

You have the option of specifying a minimum percentage, a maximum percentage, CPU shares, or a combination of these. The system automatically allocates CPU time to each virtual machine somewhere between its minimum and maximum percentages, refined by the number of shares.

Admission Control
Admission Control

ESX Server uses an admission control policy. If ESX Server is unable to guarantee a virtual machine's specified minimum percentage, it will not allow you to power on that virtual machine.

While CPU reservations are used for admission control, actual CPU time allocations vary dynamically, and unused reservations are not wasted.

This section discusses managing CPU resources using CPU percentages, CPU shares, or both.

Specifying Minimum and Maximum CPU Percentages
Specifying Minimum and Maximum CPU Percentages

This ESX Server release includes the option to specify a minimum and maximum percentage of CPUs for each virtual machine. The minimum percentage represents an absolute, fixed lower limit while the maximum percentage represents an absolute, fixed upper limit. A virtual machine will always be able to use at least as much CPU time as specified by the minimum percentage, and never use more CPU time than the specified maximum percentage.

For a single virtual CPU virtual machine, the percentage ranges from 0% to 100%. For a dual-virtual CPU machine, the percentage ranges from 0% to 200%.

For example, if one of your virtual machines is running an important application, you can specify a higher minimum percentage for this virtual machine, compared to the other virtual machines on your ESX Server.

You can set CPU percentages for some, or all of your virtual machines. Alternately, you may choose to set only maximum CPU percentages.

For example, suppose you eventually plan to run 20 virtual machines on your ESX Server machine, but have currently deployed only five virtual machines. Normally, these five virtual machines would utilize any extra CPU time that is available on the ESX Server machine. However, after you deploy an additional 15 virtual machines, these five initial virtual machines will receive a smaller share of CPU time, than what they were used to previously.

If you prefer not to have the users of these virtual machines become accustomed to this higher level of performance, you could set a maximum CPU percentage for these five virtual machines and limit the amount of CPU time they receive.

Note: The CPU percentage(s) you choose represent an absolute fixed limit for that virtual machine.

Multiprocessor Systems
Multiprocessor Systems

In multiprocessor systems, you can also restrict the assignment of virtual machines to a subset of the available processors by specifying an affinity set for each virtual machine. The system automatically assigns each virtual machine to processors in the specified affinity set in order to achieve the CPU allocations specified by the minimum, maximum and shares settings associated with each virtual machine. If the affinity set for a uniprocessor virtual machine contains only a single processor, then the virtual machine is placed there.

For symmetric multiprocessing (SMP) virtual machines, you can optionally specify an affinity set for each virtual CPU.

You can modify CPU shares and affinity sets dynamically at any time by using the procfs interface on the service console or using the VMware Management Interface. Initial values for a virtual machine may also be specified in its configuration file.

Using Proportional-share Scheduling
Using Proportional-share Scheduling

With proportional-share processor scheduling, you can allocate a number of shares to each scheduled virtual machine. CPU shares are relative.

For example, a virtual machine that is allocated 2000 shares is entitled to consume twice as many CPU cycles as a virtual machine with 1000 shares. Similarly, a virtual machine that is allocated 200 shares is entitled to consume twice as many CPU cycles as a virtual machine with 100 shares. The number of shares may vary, but the first virtual machine has twice as many shares as the second virtual machine.

You can use proportionalshare scheduling by itself, or in combination with CPU percentages. See Managing CPU Time with Percentages and Shares.

For example, if you are running three virtual machines, each starts with a default allocation of 1,000 shares. If you want to give one virtual machine half the CPU time and give each of the other two virtual machines one-quarter of the CPU time, you can assign 2,000 shares to the first virtual machine and leave the other two at their default allocations. Since these share allocations are relative, the same effect may be achieved by giving 500 shares to the first virtual machine and 250 to each of the other two virtual machines.

Controlling Relative CPU Rates
Controlling Relative CPU Rates

You can control relative CPU rates by specifying the number of shares allocated to each virtual machine. Increasing the number of shares allocated to a virtual machine dilutes the effective value of all shares by increasing the total number of shares.

The service console receives 1,000 shares and has a minimum CPU percentage of 8 percent, by default. In most cases, this should be an appropriate allocation, since the service console should not be used for CPU-intensive tasks.

If you do find it necessary to adjust the service console's allocation of CPU shares, you can use the VMware Management Interface or the procfs interface on the service console, as described in this section. Through the management interface, you can increase the minimum CPU percentage or the number of CPU shares to allocated more CPU to the service console.

Note: CPU share allocations, by themselves, do not necessarily guarantee the rate of progress within a virtual machine.

For example, suppose virtual machine 103 is allocated 2,000 shares, while virtual machine 104 is allocated 1,000 shares. If both virtual machines are CPU-bound - for example, both are running the same compute-intensive benchmark - then virtual machine 103 should indeed run twice as fast as virtual machine 104. However, if virtual machine 103 instead runs an I/O-bound workload that causes it to stop as it waits for other resources, it does not run twice as fast as virtual machine 103, even though it is allowed to use twice as much CPU time.

Managing CPU Time with Percentages and Shares
Managing CPU Time with Percentages and Shares

You can also use both CPU percentages and shares to manage CPU resources for your virtual machines.

For example, virtual machine A has a minimum CPU percentage of 20%, and a maximum CPU percentage of 50%, while virtual machine B has a minimum percentage of 30% and no specified maximum percentage. You then decide to give virtual machine A 3000 CPU shares and virtual machine B 1000 CPU shares.

ESX Server interprets this allocation so that virtual machine A will never have less than 20% of the total physical CPU resources, while virtual machine B will never have less than 30% of the total physical CPU resources, in any situation.

However, if one or more virtual machines are idling, then ESX Server redistributes this extra CPU time proportionally, based on the virtual machines' CPU shares. Active virtual machines benefit when extra resources are available. In this example, virtual machine A gets three times as much CPU time as virtual machine B, subject to the specified CPU percentages.

That is, virtual machine A has three times as much CPU time as machine B, as long as the virtual machine A's CPU percentage is between 20% and 50%. In actuality, virtual machine A may only get twice the CPU time of virtual machine B, because three times the CPU time exceeds 50%, or the maximum CPU percentage of virtual machine A.