In the last post, we took a look at how to configure basic Hyper-V virtual machine CPU resources and settings.
Hyper-V contains a wide range of settings that affect and control how the hypervisor allocates CPU resources from the physical host over to the virtual machine. This includes
- The amount of reserved processing power for the virtual machine in times of contention,
- The weight of the CPU resources for a particular VM,
- The compatibility mode of the CPU for Live Migration purposes, and
- NUMA settings to tweak how Hyper-V presents virtual NUMA to the guest operating system
This provides tremendous flexibility in how Hyper-V administrators are able to configure and tune Hyper-V VMs for their various CPU needs and use cases.
Next on the list of settings to configure for a virtual machine workload, Hyper-V provides a lot of different settings related to memory.
Let’s take a look at how to configure basic Hyper-V virtual machine memory resources and settings.
Hyper-V Virtual Machine Advanced Memory Configuration
Like advanced CPU configuration for Hyper-V CPU features and settings, Hyper-V provides great features for tweaking and configuring virtual machine memory that allows squeezing optimum performance and scale out of the physical hardware being used for the Hyper-V host. Hyper-V memory settings are fairly straightforward with the most basic configuration being of course how much memory to assign to the guest virtual machine.
What is Dynamic Memory in Hyper-V
To change the amount of memory assigned to a virtual machine, the machine must be powered off. However, there is a slick mechanism to allow the Hyper-V host to automatically adjust the amount of memory assigned to a virtual machine on the fly. This is known as Dynamic Memory.
Dynamic memory contains some very powerful logic and settings that allows the Hyper-V host to automatically adjust memory based on the demands of the workload running in the guest operating system.
There are several important aspects of the Dynamic Memory configuration that need to be taken note of to properly configure dynamic memory. These are minimum RAM, maximum RAM, and Memory Buffer.
Let’s take a closer look at dynamic memory and see how these values and settings come into play when configuring basic Hyper-V virtual machine memory resources and settings.
Configuring Hyper-V Dynamic Memory Settings
As mentioned above, the Hyper-V dynamic memory provides tremendous benefits when thinking about server consolidation ratio, efficiency, and squeezing the most performance and capacity out of a Hyper-V host from a memory perspective.
With dynamic memory, the Hyper-V host monitors the memory usage of the guest operating system and then can dynamically adjust the memory assigned to the virtual machine based on the values that are populated in the dynamic memory allocation settings. This allows the Hyper-V to operate more efficiently across the landscape of the host and helps to alleviate memory contention simply due to over provisioned VMs.
Let’s look at the values that makes up the configuration of dynamic memory.
The Startup RAM is the amount of memory that is configured in the top configuration box for RAM. This is the amount of memory the virtual machine has configured when it is powered on. This amount doesn’t change even with dynamic memory enabled. It is the amount of memory the VM starts with. From the power on state however, after the VM settles down from booting, the Hyper-V host dynamic memory setting will kick in and either adjust the memory setting up or down.
The Minimum RAM is a fairly intuitive value as it is the smallest amount of memory that you would like to have configured on the virtual machine as a bare minimum. If the Hyper-V host decides to take memory away from the virtual machine if it is not being used, it will reach the limit of memory that it can take away from the virtual machine when it reaches the Minimum RAM value.
Maximum RAM is the limit of RAM that you would like to configure in the opposite direction. If the VM workload continues to demand memory for the virtual machine, the Hyper-V host will continue to grant more and more memory up to the amount set in this field. However, once this limit is reached, the host will not grant more memory to the virtual machine.
The Memory Buffer is an interesting configuration setting in terms of how the Hyper-V host will grow the memory when the guest operating system workload requests more. This is basically the setting of how large the chunks of memory are when memory is incremented up based on demand.
The default for this setting is 20% but can be adjusted. This means the Hyper-V host will grow memory based on the specified percentage in this setting of the Startup RAM value. If the RAM configured is 1024 MB, Hyper-V will increase memory first by 20% of that amount which is 204 MB.
As you can see in the screenshot of the Hyper-V virtual machine settings looking at the Memory configuration, once the Enable Dynamic Memory checkbox is checked, you have three values that are now configurable.
Hyper-V Dynamic Memory Best Practices and Considerations
When using dynamic memory, there are a few considerations that need to be made and best practices to think about. As mentioned in configure basic Hyper-V virtual machine CPU resources and settings post, dynamic memory cannot be used with virtual NUMA. In other words, a virtual machine with dynamic memory enabled will essentially be locked into one virtual NUMA node and no NUMA topology is presented to the virtual machine regardless of the virtual NUMA settings. See Hyper-V Processor Performance.
Keep Integration services up to date in your guest virtual machines. Hyper-V relies heavily on the Integration Services residing in the virtual machine to properly control dynamic memory. Ensuring you have the latest version of Integration Services installed will help to ensure that dynamic memory performs and behaves as you would expect.
A good rule of thumb with dynamic memory is not to use it everywhere and also do not go crazy with the maximum values assigned as this can lead to memory contention or on the other end of the spectrum a memory-starved virtual machine.
As we have seen, Hyper-V has some really great memory configuration that can be used to control memory provisioning and usage from a Hyper-V host perspective in such a way that both capacity and performance can be maximized. Understanding the dynamic memory settings is important to properly configuring the functionality on a virtual machine.
By using the Hyper-V memory configuration along with the CPU configuration settings available, Hyper-V provides an extremely flexible, configurable, and capable hypervisor to run today’s business-critical production workloads.
In the last part of the basic Hyper-V virtual machine resources and settings configuration, we will take a look at how to configure basic Hyper-V virtual machine storage settings.