After standing up a new Microsoft Hyper-V environment, creating and configuring virtual machines is one of the first tasks that by default, an administrator will be tasked with. Hyper-V contains a wealth of possible virtual machine configuration parameters to suit the needs of most environments. One of the aspects of configuring Hyper-V virtual machines involves configuring Hyper-V virtual machine resources and settings. There is a wide range of settings that administrators can configure to tweak various aspects of performance and consumption for the specific virtual machine.
This post on basic Hyper-V virtual machine resources and settings configuration will be a three-part series.
- In this first post, we’ll discuss on configuring Hyper-V virtual machine CPU resources and settings.
In the second post, we’ll look at Hyper-V virtual machine memory resources and settings.
In the last post, we’ll look at Hyper-V virtual machine storage settings.
One of the extremely configurable aspects of Hyper-V virtual machine configuration is the CPU.
Now, Let’s take a look at configuring Hyper-V virtual machine CPU resources and settings to see the various configuration changes and optimizations that can be made for the virtual CPU assigned to the virtual machine.
Why Configure Virtual Machine Resources?
When thinking about configuring virtual machine resources, administrators don’t simply change a configuration because it is available to be changed. Configuration changes generally have a need that drives the change being made. The default settings for a virtual machine that is created in a Windows Server 2019 Hyper-V cluster has the following settings configured by default if you simply Next through the New Virtual Machine Wizard:
- 1024 MB memory
- 127 GB hard disk
- 1 Virtual Process
- No networks connected
- No dynamic memory settings enabled
As you can see from the above, there are certainly configuration changes that will need to be made for production workloads. The default settings are fairly anemic in many areas and with no networks connected, the VM will not be able to communicate with other virtual resources or the outside world.
All workloads are not going to be the same running inside the Hyper-V virtual infrastructure. There may be servers that only require a very limited number of resources such as a Windows services box or a file server serving out very small file resources. However, other production workloads will need to be provisioning “heavier”, needing much more compute, memory, and storage resources to be allocated.
The great thing about virtualization in general from an efficiency perspective is, it allows tweaking these various server workloads running on the same physical host hardware differently. This allows CPU, memory, and storage resources to be provisioned based on the needs of the virtual server rather than have all servers allocated with the exact same resources as this would be grossly inefficient.
Hyper-V has some really great features for tweaking virtual machine resources so the VM can perform optimally, despite the workload that is running inside the guest operating system.
Configure Hyper-V Virtual Machine CPU Resources
Hyper-V has several tools and utilities that are available for configuring and otherwise interactive with Hyper-V for management. This includes the Hyper-V Manager which is the default tool for configuring Hyper-V hosts and virtual machines.
Let’s take a look at the options available in the Hyper-V Manager for assigning CPU resources to a Hyper-V Virtual Machine.
Open up the Hyper-V Manager by typing the shortcut, virtmgmt.msc.
Hyper-V Manager should open. Right-click on a virtual machine and select Settings.
Under Hardware, Choose the Processor node.
This will display the configurables for the processor section in the Hyper-V Manager for the particular virtual machine being edited.
***Note*** These changes will need to be made with the virtual machine powered off.
The resource control setting determines how the CPU scheduler allocates CPU resources for the virtual machine and how it consumes resources. For most, this setting will be best left to the defaults here as in general, the Hyper-V. Scheduler does a much better job at scheduling CPU resources than can be manually configured for a VM. However, if you had a particular VM that you want to ensure always has more CPU resources than another, these settings can be used to reserve resources for a particular workload.
The following settings are contained within the resource control section:
- Virtual Machine Reserve (Percentage) – This setting allows reserving a percentage of the assigned vCPUs to a VM
- Percent of total system resources – This is tied to the reserve and limit configuration. These are updated automatically to reflect changes made in total host CPU resources for the virtual machine in reserve or limited
- Virtual machine limit (percentage) – This limits percentage of processing power the virtual machine can use based on the allocated CPUs.
- Relative Weight – This assigns priority in times of processor contention. A VM with a higher weight gets more processing time than a VM with a lower weight during times of contention.
The Compatibility subtree under the Processor node allows checking a box – Migrate to a physical computer with a different processor version. This allows limiting features that a VM can use and by extension, enables compatibility.
If you are in need of Live Migrating a VM from an older host to a newer host with CPUs with more instruction sets, this box can be checked so the features of the current CPU exposed to the VM are kept as the VM moves to a newer CPU architecture. The same “older” architecture will be presented to the VM in that case, eliminating the need for a reboot. However, a shutdown and move in this case would be recommended.
Configuring NUMA or Non-Uniform Memory Access settings for a VM is also possible in the Hyper-V VM configuration settings. The nuances of the NUMA architecture for virtual machines can be extremely detailed to explain and understand. However, NUMA in general provides efficiencies in the way that memory is accessed.
Hyper-V presents a virtual NUMA topology to virtual machines. By default, Hyper-V attempts to optimize the virtual NUMA topology to match the NUMA topology of the physical Hyper-V host processor/memory architecture. By allowing the virtual machine to have the virtual NUMA topology exposed, NUMA-aware applications are able to take advantage of the NUMA performance optimizations as it would running on a physical server.
A classic example of a business-critical application that is NUMA aware is Microsoft SQL Server.
An important point to note about virtual NUMA is that it cannot be used at the same time as dynamic memory. When dynamic memory is enabled, it effectively has only one virtual NUMA node and no NUMA topology is presented to the VM.
The CPU configuration of virtual machines running inside Hyper-V infrastructure is highly configurable. Aside from configuring the number of virtual CPUs assigned to the VM, Hyper-V administrators can change the compatibility of the CPU as well as the NUMA architecture and how these are seen by the virtual machine.
There are various levels of CPU configuration that allows controlling how the CPU resources can be consumed by the VM, especially during times of CPU contention on the Hyper-V host. This can be helpful for business-critical workloads that need to be given priority during times of CPU contention. Compatibility settings determine how the CPU instruction set is presented to a VM when Live Migrating workloads to a newer Hyper-V host with newer CPU architecture. The same CPU instruction set is locked to the VM when it moves to the newer Hyper-V host. NUMA architecture and configuration allows virtual machines to take advantage of today’s modern NUMA architecture for NUMA-aware applications such as Microsoft SQL Server.
In my next post, we will take a look at configuring basic Hyper-V virtual machine memory resources and settings.Like what you read? Rate us