When it comes to allocating resources to virtual machines, most of the emphasis tends to center on memory allocation
and storage I/O bottlenecks, but VM processor assignments are just as important to ensuring stable performance. This article discusses four best practices for CPU assignments.
Adhere to application recommendations
The first best practice you should observe when assigning virtual CPUs is to adhere to the requirements of the operating system and applications that will be running on the VM. Default VM configurations often do not adhere to application requirements, even when the application and the hypervisor are produced by the same vendor.
Consider SharePoint 2013, for example. Many SharePoint 2013 configurations require four CPU cores. SharePoint is a multithreaded application specifically designed to take advantage of multiple CPU cores. In contrast, Hyper-V provisions newly created VMs with a single virtual processor unless the administrator specifies otherwise. SharePoint 2013 will run on single-processor or single-core systems, but doing so tends to result in painfully slow performance.
Pay attention to recommended virtual CPU ratios
Another best practice is to pay attention to the recommended CPU ratios. However, you must remember that CPU ratios should be treated as guidelines. They are never absolute requirements, because production VMs rarely generate workloads that are identical to those produced in lab testing.
The supported CPU ratio could be a best practice, or it might represent a configuration that only works under ideal conditions.
Another reason to treat CPU ratios as a guideline rather than an absolute requirement is that it is difficult to know what the hypervisor vendor's goals were when they defined the ratio. For example, the ratio could have been set by the vendor's engineering department and could be based on the configuration that the engineers who built the hypervisor think will deliver the best performance and the most efficient hardware usage. In contrast, the ratio might have been produced by the hypervisor vendor's marketing department as a way of showing that their hypervisor supports higher consolidation ratios than the competition. In other words, the supported CPU ratio could be a best practice, or it might represent a configuration that only works under ideal conditions.
It is also important to understand that virtual CPU ratios can differ based on the workload. For instance, some hypervisor vendors offer one virtual CPU ratio for VDI deployments and a different ratio for virtual servers.
In any case, just remember that a recommended virtual CPU ratio does not trump an application's stated CPU requirements. Remember, SharePoint's requirement for four cores does not change simply because SharePoint is hosted on a VM. SharePoint (as well as every other application) has the same hardware needs regardless of whether it is running in a physical or a virtual environment.
The same basic concept also applies to VMs that are running CPU-intensive applications. If you have such a VM, it is a good idea to dedicate CPU cores to that VM by maintaining a 1:1 ratio of physical CPU cores to virtual CPU cores.
Consider the vendor's definition of a virtual processor
The concept of a virtual processor seems simple. Even so, the underlying architecture can be somewhat confusing. For example, in Hyper-V, there is no direct relationship between virtual processors and physical processors. Virtual processors link to logical processors, and logical processors are based on the physical hardware.
Many websites indicate that there is a 1:1 ratio of physical processor cores to logical processors. In other words, every logical processor represents a physical core. This explanation holds up in many cases, but it does not work 100% of the time.
When hyperthreading is enabled, Hyper-V can treat a thread as a logical processor. In essence, a six-core processor could result in 12 logical processors. This is an important consideration because the number of logical processors has a direct impact on the CPU ratios.
Leave some CPU resources for the hypervisor
When you are allocating CPU resources to VMs, don't forget to factor in the needs of the hypervisor itself. Making VM processor assignments without regard for the host operating system can result in diminished performance.
Ultimately, there is no magic formula for determining the best VM processor allocation. Every hypervisor vendor offers its own recommendations for best practices, but those recommendations are rarely optimal in a production environment. As a best practice, you should start by adhering to the hypervisor vendor's recommendations, then create a baseline of the server's performance. As you fine-tune the CPU allocation, you can compare the performance metrics against your baseline tests in an effort to find the optimal allocation method for your organization.
Dig deeper on Virtual machine provisioning and configuration
Brien Posey asks:
What is the most difficult part of VM processor assignments for you?
0 ResponsesJoin the Discussion