Using Hyper-V Virtual Machine Processor Resource Control
In this post I will show you why and how you can use the virtual processor resource control settings to configure Hyper-V virtual machine reservations, limits, and weights.
How a Virtual Machine Uses Host Logical Processors
A logical processor (LP) is a thread of execution on a host. Let’s look at three example hosts.
|Host Name||Physical Processors||Hyper-threading Enabled?||Logical Processors|
|Host1||Dual Intel 4-core (8 cores)||No||8|
|Host2||Dual Intel 8-core (16 cores)||Yes||32|
|Host3||Dual AMD 12-core (24 cores)||N/A||24|
Host1 has eight cores with Hyper-threading disabled. There are eight threads of execution or LPs on that host. Host2 has 16 cores; each core has two threads thanks to Hyper-threading, so there are a total of 32 LPs on that host. Host3 has AMD processors (Hyper-threading is an Intel CPU function) with a total of 24 cores; without Hyper-threading there are 24 LPs on this host.
Note: Hyper-threading does not double the power of a processor. It allows more multitasking and can add a small percentage to a host’s capacity with recent processors. Only on older processors does enabling Hyper-threading have a negative impact on performance for Hyper-V.
When a virtual machine runs on a host, it is sharing the resources of that host, including the processor capacity. A virtual machines virtual CPUs (vCPUs) do not permanently sit on the LPs that run them. Just like with applications on your PC, each virtual machine gets a slice of time to run. The VM is swapped on and off the physical processors of the host to allow other VMs to share those LPs. This might sound bad at first, but virtualization exists in the first place because the majority of servers were greatly underusing their CPU capacity. The virtual machines swap in/out so quickly that we humans do not normally notice. But sometimes those virtual machines need to be able to guarantee physical processor capacity to more horsepower-hungry services.
Virtual Processor Resource Control
Hyper-V gives us the ability to manipulate how any virtual machine’s vCPUs utilize the LPs of a host. This is known as resource control. You can configure a virtual machine by editing the settings and browsing to Processor. Note that the VM must be powered down to edit these settings.
This is the location where you can configure the number of vCPUs that a VM has. Doing this allows a VM’s guest OS to have the ability to schedule more or fewer parallel tasks. This is useful for multithreaded services such as SQL Server or SharePoint. Doing this needlessly blocks the LPs of a host from being used by other VMs while the over-resourced VM is executing.
Here is also where you will find the Resource Control settings where you can control how LP capacity is scheduled for your virtual machine.
Virtual Machine Reserve (Percentage) is probably the most interesting setting. This is a guarantee of LP capacity for the virtual machine. If your virtual machine has two vCPUs and you set this setting to 100 percent then that virtual machine will be guaranteed two logical processors. No other virtual machines will be scheduled for those logical processors. This is useful for processor-hungry services such as SharePoint. Note that:
- Some software support statements urge you to enable this setting to 50 or 100 percent.
- This is probably how Windows Azure is enabling non-sharing of processors to the small (1 vCPU) and larger virtual machine specifications.
The Percent Of Total Resource display is a calculation of how much of the host’s total LP capacity will be assigned to this virtual machine. This setting is important to note – if you reserve 100 percent for every virtual machine then you won’t put many virtual machines onto each host!
This setting is rarely looked at in the real world by most virtual administrators, and really should only be configured for those services that require it. In a cloud there should be a higher cost for any templates that are configured with this setting.
Virtual Machine Limit (Percentage) restricts how much of the assigned LPs that this virtual machine can consume. By default, a virtual machine can use up to 100 percent of the capacity; this is used in conjunction with virtual machine processor pressure (or demand) along with the Relative Weight setting to balance the scheduling of virtual machines on the LPs.
I have never seen Virtual Machine Limit (Percentage) being used outside of a “what does it do?” scenario. It might be useful if some troublesome virtual machine does run away from time to time. Remember that you can only edit these settings while a virtual machine is powered off.
Relative Weight is used to manipulate the scheduling of virtual machines that are competing for shared (by default) LP resources. This setting is 100 by default. You can skew the weight of a VM by changing the setting. Valid values range from 0 to 10000.
More in Hyper-V
How to Install Hyper-V on Windows Server Core
Mar 16, 2022 | Michael Reinders
Microsoft Says There Will Be No Hyper-V Server 2022 Free Edition
Dec 13, 2021 | Michael Reinders
How to Stop an Unresponsive Hyper-V Virtual Machine
Jun 29, 2021 | Russell Smith
How to Enable Nested Virtualization in Hyper-V
Jun 28, 2021 | Russell Smith
Disaster Recovery with Azure Backup for SQL Server VMs
May 28, 2019 | Michael Otey
Leveraging Virtualization for Improved Availability and Disaster Recovery
Apr 29, 2019 | Michael Otey
Most popular on petri