While the tranquil notion of virtualization features a virtual machine floating on an endless sea of compute cycles, the harsh reality is a VM requires a physical ESXi host for sustenance and it will fight with other VMs for its share of resources.
An administrator can leave VMware vSphere on autopilot to manage host resources, but there are times when a seasoned administrator must take the wheel in a complex environment and make decisions to keep performance at an even keel.
Jonathan Frappier's book VMware vSphere Resource Management Essentials can help administrators understand the complexities of a VMware infrastructure, including the interdependencies that exist between VMs, hosts, storage and the network that binds them.
Chapter 2, titled "Assigning Resources to VMs," is available to download and read here (PDF). In this chapter, Frappier explains how VMs use resources provided by ESXi hosts -- and how sharing affects both the host and the VMs that rely on it.
A technology such as Hyper-Threading (HT) by Intel or AMD-V/RVI will make a single core appear as two cores to the operating system and can help process multiple requests at once on a single CPU core.
If you have HT enabled, you will see that your OS, if supported with a hypervisor such as ESXi, perceives this to be an available physical processor core; however, for purposes of designing your infrastructure, I would recommend staying within the physical capabilities of your processor. With an Intel Xeon CPU running HT on four cores, the ESXi hypervisor will be presented with eight available cores. Although HT increases [the] number of the available virtual cores, you should design your clusters for the load based on the number of physical cores.
With this basic understanding of how CPUs function, you can see why it's important to understand the resource requirements for a specific server or application. Servers or applications with relatively low CPU resource requirements could potentially work fine with 10 or 12 vCPUs per physical core; however, if the application was processor intensive, you might find that you can only run two to three vCPUs per physical core. It's important to note here that generally, you are not assigning a VM or vCPU to a physical CPU; however, you could through the use of CPU affinity in ESXi. We are simply saying that depending on your workload and the number of physical cores in your CPU, you could expect to receive certain consolidation ratios. When possible, you should try to perform the following actions:
- Monitor resource utilization prior to any project -- physical to virtual or virtual to virtual
- Do not overcommit the CPU; only assign what the VM and workload require
- Avoid CPU affinity as you will not be able to vMotion VMs with CPU affinity enabled until it is disabled
VMware has developed an advanced CPU scheduler to ensure the efficient operation of VMs in your environment. In fact, they have published an excellent technical white paper that you should read, as we don't have the space in this book to cover the CPU scheduler in that level of detail. You can find the white paper at www.vmware.com/files/pdf/techpaper/VMware-vSphere-CPU-Sched-Perf.pdf. If your VM has one vCPU, and the host it is running on has four pCPU, then it's the job of the CPU scheduler to find an available pCPU for the VM to access when required. That is an easy translation to make to a physical server with an OS installed. However, what happens when your VM has multiple vCPUs?