Most admins are well-aware that mismanaging virtual processor resources often leads to serious performance problems,...
but knowing the best way to assign and allocate those resources can be a challenge.
Follow these tips to better understand the technology and navigate the available management techniques. You'll also be better prepared to reallocate virtual processor resources when your workload demands change and more equipped to troubleshoot vCPU issues with ease.
Understand processor technology
A CPU, which is responsible for fulfilling the instructions that are part of an application or workload, as well as handling any data associated with that application or workload, traditionally used one instruction thread and consisted of a single core. But modern CPUs are much more complex.
More threads and cores have been added to CPUs by designers in an attempt to increase speed and make processors more powerful and efficient. A hyper-threaded CPU, for example, consists of two instruction streams that share the same pipeline. In this case, each thread is considered a logical CPU.
Enterprise-level CPUs can have up to 24 cores, which, if hyper-threaded, can equate to 48 logical CPUs. When virtualization is added to the equation, the hypervisor abstracts these resources, meaning that each logical CPU is abstracted into a virtual processor that can then be assigned to a VM.
Use affinity and anti-affinity rules
While hyper-threading can improve performance, it can also have the opposite effect if your workloads aren't balanced. Fortunately, there are some features that can help you ensure balanced workloads across your environment. Affinity and anti-affinity rules can be used to manage vCPU distribution.
Affinity rules establish which vCPUs can be used by specific VMs, and anti-affinity rules discourage the use of certain vCPUs by the VMs you choose.
When you have predictable workloads, you can probably get away with assigning those workloads to vCPUs on the same hyper-threaded core without experiencing much performance degradation. For demanding workloads, however, you should seriously consider using vCPUs on different hyper-threaded cores to avoid potential issues.
Allocate virtual processor resources
Now that you know which vCPUs would be best to assign to a specific VM, it's time to think about how many virtual processor resources the workload will need. You obviously need enough vCPUs to meet the workload's computing requirements, but what about going beyond that?
If you assign too many vCPUs to a VM, those resources are essentially wasted because other VMs can't make use of them once they've been assigned. Start with the basic system requirements of the workload and go from there. You can always change the number of vCPUs allocated to the VM, so long as the VM is powered off first.
There are hypervisors that have hot plug capabilities that enable you to increase the number of vCPUs allocated to the VM while it's running, but be sure to check what features are available to you before making any changes so you don't disrupt any mission-critical workloads.
Calculate CPU overcommitment
As IT shops attempt to consolidate their servers in order to reduce their footprint and cut costs, they might overcommit to make up the difference in resources. There are calculators that can help you determine the ideal VM count per core, which typically ranges anywhere from three to seven VMs per core, but you shouldn't simply take these numbers at face value. If so, you might end up overestimating how much you can realistically consolidate.
CPU Ready Time metrics will show you the amount of time your VMs are ready to use processor resources but can't because they're being used by other VMs. An acceptable CPU busy time is 2-3%, with 5% or higher being a cause for concern and 10% or higher resulting in performance issues. So long as you monitor your workloads and use tools like calculators and CPU Ready Time metrics, you shouldn't have a problem.
Troubleshoot common vCPU issues
If you've addressed any performance degradation that might be due to overcommitting virtual processor resources and you're still experiencing issues, take a look at how vCPUs were selected and assigned to VMs in the environment. If hyper-threading is enabled, check those VMs that are using vCPUs on the same core and consider reassigning one and replacing it with that of a less demanding workload.
Once you've done some research and made the appropriate changes to address performance problems, set affinity and anti-affinity rules so those changes remain in place, at least for the foreseeable future.
The key thing to remember with CPU and vCPU management is that workloads aren't static; balancing them based on your available resources is an ongoing process.