5. Dynamic Memory improvements
Dynamic
Memory was introduced for Hyper-V in Windows Server 2008 R2 as a way of
enabling virtualization hosts to make more effective use of physical
memory allocated to VMs running on the host. Dynamic Memory works by
adjusting the amount of memory available to the VM in real time. These
adjustments in memory allocation are based on how much memory the VM
needs and on how Dynamic Memory has been configured on the VM.
Dynamic Memory provides important scalability and performance
benefits, especially for virtual desktop infrastructure (VDI)
environments, where at any given time, a subset of the VMs running on
the host tend either to be idle or to have a relatively low load. By
using Dynamic Memory in such scenarios, you can consolidate greater
numbers of VM on your Hyper-V hosts. The result is that you’ll need
fewer hosts for provisioning virtual desktops to your user population,
which means you won’t need to procure as much high-end server hardware.
In other words, Dynamic Memory can help you save money.
5.1 Configuring Dynamic Memory
Dynamic Memory is enabled on a per-VM basis. You can enable and
configure Dynamic Memory in the Memory section of the VM’s settings in
Hyper-V Manager, as shown in Figure 5 below. You also can enable and configure Dynamic Memory using PowerShell by using the Set-VM
cmdlet, which can be used to configure the various properties of a VM.
Note that you can enable or disable Dynamic Memory only when the VM is
in a stopped state.
Configuration options for Dynamic Memory for VMs on Hyper-V hosts running Windows Server 2008 R2 were as follows:
-
Startup RAM
The amount of memory needed for starting the VM
-
Maximum RAM The maximum amount of memory that the VM can use
-
Memory buffer
An amount of memory
(as a percentage of the amount that the VM actually needs to perform
its workload) that can be allocated to the VM when there is sufficient
memory available on the host
-
Memory weight
A parameter that determines how available memory on the host is allocated among the different VMs running on the host
Configuration options for Dynamic Memory for VMs on Hyper-V hosts running Windows Server 2012 have been enhanced in several ways:
A new configuration setting called Minimum Memory
allows you to specify the minimum amount of memory that the VM can use
when it is running. The reason for introducing this new setting is
because Windows generally needs more memory when starting than it does
when idle and running. As a result of this change, you now can specify
sufficient startup memory to enable the VM to start quickly and then a
lesser amount of memory (the minimum memory) for when the VM is
running. That way, a VM can get some extra memory so it can start
properly, and then once it’s started, Windows reclaims the unneeded
memory so other VMs on the host can use the reclaimed memory if needed.
Another change in the way that Dynamic Memory can be configured in
Windows Server 2012 is that now you can modify the maximum and minimum
memory settings while the VM is running. In Windows Server 2008 R2, the
maximum memory
setting could be modified only when the VM was in a stopped state. This
change gives you a new way of quickly provisioning more memory to a
critical VM when needed.
Specifying a minimum memory for a VM can enable Windows to reclaim
some unneeded memory once the VM has started. Then this reclaimed
memory can be reallocated towards other VMs on the host. But this
raises a question: What if you start as many VMs as you can on a host,
allow Windows to reclaim unneeded memory once the VMs are running, then
start more VMs using the reclaimed memory, then again allow Windows to
reclaim any additional unneeded memory, then try to start more VMs on
the host … and so on? Eventually, you reach the point where almost all
the host’s memory is in use and you’re unable to start any more VMs.
But then you find that one of your running VMs needs to be restarted
immediately (for example, to apply a software update). So you try and
restart the VM, and it shuts down successfully but it won’t start
again. Why not? Because there’s not enough free memory on the host to
meet the Startup RAM criterion for that VM.
To prevent this kind of scenario from happening while enabling Dynamic Memory to work its scalability magic, Hyper-V in Windows Server 2012 introduces a new feature called Smart Paging (see Figure 6). Smart Paging allows a VM that’s being restarted to use disk resources temporarily on the host as a source for any additional memory needed to restart the VM successfully. Then, once the VM has started successfully and its memory requirements lessen, Smart Paging releases the previously used disk resources because of the performance hit that such use can create.
Smart Paging is used only when a VM is restarted and there
is no free physical memory on the host and no memory can be reclaimed
from other running VMs. Smart Paging is not used if you simply try and
start a VM that’s in a stopped state, or if a VM is failing over in a
cluster.