4.4. CPU Management, Affinity
VMware ESX Server allows you to control access to the CPUs on which the Service Console and your virtual machines run. This management is in the form of minimum and maximum percentage values, as well as shares.
A minimum percentage value is the minimum amount of time that either the Service Console or the virtual machine is guaranteed on a particular processor. The maximum percentage value is the maximum amount of time that the Service Console of a virtual machine is guaranteed on a particular processor or processors if you are running virtual smp.
As shown in Figure 4.3, a default build of one of our ESX Servers gave the Service Console the following access to Processor0.
Figure 4-3. Default CPU Access for the Service Console
The values located under the Resources heading show that the Service Console will receive a minimum of 8 percent availability of the processor capacity while the most, or the maximum, it can utilize is 100 percent.
The Service Console is also configured with 2,000 shares. Shares represent a relative priority. This priority denotes which virtual machines will have priority or preferential access to the CPU.
VMware describes shares in the following manner: "the shares value represents a relative metric for allocating processor capacity, where this value is compared to the sum of all shares of all virtual machines on the server and the Service Console."
In our example of the Service Console, it has been allotted 2,000 shares on processor0. Since the Service Console has been allocated 2,000 shares, it has priority access on processor0 over a virtual machine, which by default is configured to Normal.
Note that these default settings can be edited if needed. By selecting Edit… link, the window shown in Figure 4.4 will be displayed.
Figure 4-4. Editing CPU Resources with VMware ESX Server 2.5
The Service Console is given a higher default priority on processor0 for pretty obvious reasonsif the Service Console doesn't have access to its processor, management of your ESX Server will take a performance hit. To ensure the Service Console always has access to processor0, you could bump up the minimum to 100 percent. This is rarely, if ever, needed and is not recommended. You could create the same effect through the use of CPU Affinity, which we'll discuss later in this chapter.
Let's compare the default CPU configuration of a virtual machine to that of the default Service Console configuration and then discuss what possible tweaks you may want to make in order for your virtual machine to perform more optimally.
Figure 4.5 shows the default configuration of a Windows 2003 Server, Standard Edition.
Figure 4-5. The Default Configuration of Windows 2003 Server, Standard Edition
This virtual machine has one virtual CPU with a minimum setting of 0 percent, a maximum of 100 percent, and its shares set to Normal. Also note that the Scheduling Affinity option is available. It's here where you can choose on which CPU(s) you want your virtual machines to run. This option is not available for the Service Console since it always runs on processor0. By clicking the Edit link, you may adjust your CPU resources to better meet the needs of your virtual machines.
Let's say you want this particular virtual machine to run on processors 2 and 3. The change might look like the settings shown in Figure 4.6
Figure 4-6. Setting CPU Affinity
By default, every virtual machine is given access to all processors running. But we have chosen this virtual machine to run only processors 2 and 3 by clicking the Do Not Run On Processor(s) radio buttons 0 and 1.
For CPU-intensive virtual machines, you might also want to increment the Minimum value to a level where the virtual machine is guaranteed a performance high enough for its service level. Changing the affinity of your CPUs, as well as the minimum and maximum values and the CPU shares, allows for virtual machines of high CPU requirements and low CPU requirements to exist harmoniously. Affinity comes into play more in larger NUMA ESX hosts.