CPU virtualization adds varying amounts of overhead. Because of this, you may need to fine-tune the CPU performance and need to know what the standard best practices are.
The following are the standard CPU performance best practices:
- You need to avoid using SMP VMs unless it is required by the application running inside the guest OS. This means if the application is not multithreaded, then there is no benefit of using the SMP VM.
- You should prioritize VM CPU usage with a proportional share algorithm.
- Use Distributed Resource Scheduler (DRS) and vMotion to redistribute VMs and reduce contention.
- Use the latest available virtual hardware for the VMs.
- Reduce the number of VMs running on a single host. This way, you can not only reduce contention, but also reduce the fault domain configuration.
- You should leverage the application-tuning guide from the vendor to tune your VMs for best performance.
To step through this recipe, you need a running ESXi Server (licensed with Enterprise Plus for DRS), a couple of running VMs, and vSphere Web Client. No other prerequisites are required.
Let's get started:
- For the first best practice, you need to check whether the application is single threaded or multithreaded. If it is single threaded, then avoid running an SMP VM:
- You need to log in to vCenter using vSphere Web Client, then go to the
Home
tab. - Once there, go to the VM and look at the
VM Hardware
tile. - Now you can see whether the VM has one vCPU or multiple vCPUs. You see whether it's using them by looking at
%Utilization
or a similar metric for each vCPU:
- You need to log in to vCenter using vSphere Web Client, then go to the
- For the second best practice, you need to prioritize the VM CPU using shares and reservation. Depending on the customer SLA, this has to be defined:
- You need to log in to vCenter using vSphere Web Client, then go to the
Home
tab. - Once there, go to the VM, right-click on it, and then select
Edit Resource Settings
. - In the
CPU
section, you need to define theShares
andReservation
values depending on your SLA and the performance factors.
- You need to log in to vCenter using vSphere Web Client, then go to the
By default, ESXi is efficient and fair. It does not waste physical resources. If all the demands could be met, all is well. If all the demands are not satisfied, the deprivation is shared equitably among VMs by default.
VMs can use and then adjust the shares, reservation, or limit settings. But be sure that you know how they work first:
- For the third best practice, you need to have a vSphere Cluster and have DRS enabled for this. DRS will load balance the VMs across the ESXi hosts using vMotion.
The first screenshot shows that the DRS is enabled on this vSphere Cluster:
The second screenshot shows the automation level and migration threshold:
- For the fourth best practice, you first need to see what virtual hardware the VM is running on; if it is not current, then you need to upgrade it. A virtual hardware version can limit the number of vCPUs:
- You need to log in to vCenter using vSphere Web Client, then go to the
Home
tab. - Once there, go to
Hosts and Clusters
, then click onVM
and look at theVM Hardware
tile.
- You need to log in to vCenter using vSphere Web Client, then go to the
In the following example, it is version 10, which is old, and we can upgrade it to version 13.
Note
Take a VM snapshot prior to upgrading in order to mitigate the rare occurrence of a failure to boot the guest operating system after upgrading. For further information, refer to https://kb.vmware.com/kb/1010675.
- Now, to upgrade the virtual hardware of a VM, it has to be powered off. Then, start it again, right-click on
VM
, go toCompatibility
, and thenUpgrade VM Compatibility
. It should give you a warning:
- Once you click on Yes, the virtual hardware version will be upgraded.
- For the fifth recommendation, you need to limit the number of vCPUs required by the VMs that would run on the host and the number of sockets/cores available in each physical host:
- Try to balance the CPU load of your VMs across all of your hosts
- Monitor the VMs for performance and adjust as necessary.
- For the last recommendation, you need to get the vendor-application-tuning guide and follow that to tune your virtual environment. A typical example is Microsoft Exchange Server 2016 Best Practices Guide.
Note
For further information, refer to https://blogs.vmware.com/apps/2016/01/now-updated-microsoft-exchange-server-vmware-vsphere-best-practices-guide.html.