Q
Manage Learn to apply best practices and optimize your operations.

Allocate the right amount of virtual processor resources to a VM

Think about what types of workloads are running on a VM before assigning compute resources, and consider using vCPUs from different cores for demanding workloads.

Although it's a simple matter to provision virtual processor resources to a VM, there's sometimes a question of...

just how many vCPUs are appropriate. The answer is that it depends primarily on the application itself and its computing requirements.

A VM running most everyday workloads will function just fine with a single vCPU. In fact, most common workloads, such as a domain name system server, don't need the full compute capacity of a typical enterprise-class CPU core -- it's this reality of unused or idle time that makes it possible for a CPU to share its functionality with a second instruction pipeline, which is known as hyper-threading.

However, it's certainly possible to provision more than one vCPU to a VM. This might be entirely appropriate when the workload is more demanding, such as a database or email server. In most cases, two or four vCPUs should handle the most daunting workloads, but hypervisors, like VMware ESXi 6.0 and later, can provision up to 128 vCPUs to a VM.

The trick is to assign enough virtual processor resources to meet the workload's computing requirements but not so many vCPUs that valuable computing resources are wasted. As a rule, assign vCPUs as physical CPUs based on the system requirements of the workload. For example, if an application recommends a four-CPU server, allocate four vCPUs for the VM. That's often a good place to start.

Be careful assigning vCPUs from the same physical CPU core. Remember that hyper-threading provides a second instruction pipeline, but it shares the CPU's internal subsystems. It doesn't double performance, so even though the hyper-threaded CPU might look like two separate CPUs from a logical perspective, it doesn't mean you have two full-speed CPUs available. A workload demanding enough to require multiple CPUs might benefit from multiple CPUs on different cores.

Administrators often use CPU affinity and anti-affinity rules to stipulate what CPUs a VM should and shouldn't use.

For example, consider a server with a two-core hyper-threaded CPU. This yields four vCPUs, which would be noted as CPU 0 and CPU 1 on the first core and CPU 2 and CPU 3 on the second core. Now, consider a VM and workload that requires two processors. If CPU 0 and CPU 1 are provisioned for that VM, those two vCPUs actually share the same physical core, and the resulting performance might be inadequate to operate the workload properly. Rather than provisioning CPU 0 and CPU 1 on the same core, try provisioning CPU 0 and CPU 2, which would invoke vCPUs from two different physical cores. The remaining vCPUs -- CPU 1 and CPU 3 in this example -- could be allocated to light workloads or even left unused. Administrators often use CPU affinity and anti-affinity rules to stipulate what CPUs a VM should and shouldn't use.

Fortunately, the number of virtual processor resources allocated to a VM can be changed without destroying and recreating the VM. Administrators can change the number of vCPUs assigned to a VM while the VM is powered off. However, more recent hot plug capabilities in a hypervisor, if enabled, can allow administrators to increase the number of vCPUs while the VM and workload are actually running.

Next Steps

Learn about application resource management

Ensure workload resiliency with these strategies

Deploy applications to VMs or containers

This was last published in August 2017

Dig Deeper on Virtual machine performance management

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

2 comments

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

How do you decide how many virtual processors to assign a VM?
Cancel
Its depend on Application requirement. In most cases, two or four vCPUs should handle the most daunting workloads, For example, if an application recommends a four-CPU server, allocate four vCPUs for the VM
Cancel

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close