Dynamic Memory feature was introduced in Windows Server 2008 R2 Service Pack 1 but in Windows Server 2012 one new configuration setting (Minimum RAM) was added. Dynamic Memory pools the available RAM on a Hyper-V host for all running VMs for which Dynamic Memory is enabled. Using this pool, Dynamic Memory automatically modifies on the fly the amount of RAM assigned to each running VM as the need increases or decreases. The biggest benefit of Dynamic Memory is that it allows you to use yours RAM resources more efficiently, dramatically improving consolidation ratio on your virtualisation servers. Starting a VM often requires more memory than does running the VM after it starts and Dynamie Memory feature in Windows 2012 naturally mirrors these changing needs.
Now let’s take a look at Dynamic Memory settings available in Windows Server 2012. As you can expect all settings related to memory can be modified in the Memory section of a VM’s settings in Hyper-V Manager. You can also enable and configure Dynamic Memory with Windows PowerShell by using Set-VM cmdlet, which can be used to configure the various properties of a VM. Please note that enable or disable Dynmic Memory only when VM is in stopped state – Dynamic Memory does not mean you can manually adjust RAM settings while a VM is running.
Dynamic Memory settings available to configure:
- Startup RAM – this is only the amount of RAM assigned at startup and is no longer the minimum RAM. If a running VM uses less RAM after startup, some of the RAM can be reclaimed by other running VMs.
- Minimum RAM – this is the only new setting that has been added since Windows Server 2008 R2 SP1. If Dynamic Memory is enabled on a VM running on the Windows 2012 host, by default this value is the same as the Startup RAM value. You can lover Minimum RAM to allow the amount of RAM allocated tothe VM to decrease after startup.
- Maximum RAM – this is the maximum amount of RAM that can ever be dynamically assigned to the VM.
- Memory Buffer – this is the preffered amount of extra RAM that is assigned to the system what is necessary to run the active workload at any given point. The default value is 20 %. If memory usage spikes intermittely on a VM, you might want to increase this value to help ensure that enough RAM is available when needed.
As in the previous version of Dynamic Memory, you can configure a minimum memory amount for virtual machines in Windows Server 2012, and Hyper-V continues to ensure that this amount is always assigned to running virtual machines.
To provide a reliable restart experience for the virtual machines configured with less minimum memory than startup memory, Hyper-V in Windows Server 2012 uses Smart Paging. This memory management method uses disk resources as additional, temporary memory when more memory is required to restart a virtual machine. This approach has advantages and drawbacks. It provides a reliable way to keep the virtual machines running when there is no available physical memory. However, it can degrade virtual machine performance because disk access speeds are much slower than memory access speeds.
To minimize the performance impact of Smart Paging, Hyper-V uses it only when all of the following occurs:
- The virtual machine is being restarted.
- There is no available physical memory.
- No memory can be reclaimed from other virtual machines running on the host.
Smart Paging is not used when:
- A virtual machine is being started from an “off state” (instead of a restart).
- Oversubscribing memory for a running virtual machine is required.
- A virtual machine is failing over in Hyper-V clusters.
When host memory is oversubscribed, Hyper-V continues to rely on the paging operation in the guest operating system because it is more effective than Smart Paging. The paging operation in the guest operating system is performed by Windows Memory Manager. Windows Memory Manager has more information than the Hyper-V host about memory usage within the virtual machine, which means it can provide Hyper-V with better information to use when choosing the memory to be paged. Because of this, less overhead to the system is incurred compared to Smart Paging.
To further reduce the impact of Smart Paging, Hyper-V removes memory from the virtual machine after it completes the start process. It accomplishes this by coordinating with Dynamic Memory components inside the guest operating system (a process sometimes referred to as “ballooning”), so the virtual machine stops using Smart Paging. With this technique, the use of Smart Paging is temporary and is not expected to be longer than 10 minutes.