Hyper-V Dynamic Memory

Dynamic Memory was one of the most important features that came with Windows Server 2008 R2 Service Pack 1; This VM memory allocation feature allows us to get more virtual machines on to a Hyper-V host without sacrificing performance.

Dynamic Memory allocation feature widely used in virtual desktop infrastructure (VDI) implementation where PCs are replaced by virtual machines running in the data centre.

My aim is to introduce Dynamic Memory, how it works, Microsoft Approach with this new memory optimization and how it is different from over commitment


Before Dynamic Memory:

Before Windows Server 2008 R2 Service Pack 1, Hyper-V had no memory optimization techniques.

Memory was consumed as follows on a Hyper-V host server.

Let’s assume we have a host with 16 GB of RAM.

When the host powers up, the parent partition will start up and consume whatever memory it requires. It’s usually 2 GB RAM or less. So from our 16 GB, 2 GB is consumed by the host, leaving us with 14 GB of available memory.

Each virtual machine is allocated a certain amount of memory. For example, VM1 might be assigned 4 GB RAM and VM2 might be assigned 8 GB RAM.

Each virtual machine will instantly consume all of their allocated memory, even if their workloads don’t require it. That means that 12 GB RAM is consumed from the available physical pool of RAM on the host, even if the current workloads in the virtual machines might only require 4 GB. Does that sound a little wasteful?

We did have 14 GB free on the host. Now we have consumed 12 GB of that and are left with 2 GB of RAM, even though we only require 4 GB for our application workloads right now.

Dynamic Memory

The Basics of Dynamic Memory

High end server hardware have had hardware features such as fault tolerant memory; If a memory DIMM degraded, it could be removed and replaced while the server was running.

Striping of memory contents was done by the server to ensure that nothing bad, like a blue screen of death, would occur once the engineer popped open the case and started removing and adding memory DIMMs.

These servers tended to have heavy workloads. If demand grew, then it was possible to open the machine while it was running, and add additional memory DIMMs.

This hot-add memory ability was a feature of Windows Server Enterprise and Datacenter editions.

Dynamic Memory is really just an extension of this idea. Memory is added to virtual machines while they run. But instead of plugging in large amounts, such as 8 GB DIMMs, tiny amounts of memory are added to the virtual machine. This is done on an on-demand basis from the pool of available memory on the host.

Let’s back once again to the 16 GB RAM host example.

Think of this 16 GB of RAM as a shared pool of available memory.

When the host powers up, the parent partition will start up and consume whatever memory it requires from the host pool of memory. Let’s assume 2 GB of RAM for now.

This leaves the pool with 14 GB of available memory.

VM1 and VM2 are the two virtual machines on this host. They will both start up, each initially consuming 1 GB of RAM. It’s immediately clear that Dynamic Memory is going to allow more virtual machines on the host.

Dynamic Memory

The application workloads on VM1 and VM2 will start up and require memory once their guest operating systems have started. This may drive up memory demand.

This demand will be met by dynamically allocating additional memory to the virtual machines from the shared pool on the host. Note that this is the very same pool that the parent partition (host OS) will go to if it requires more memory.


Dynamic Memory

Compare this with our original scenario where there was no Dynamic Memory. It’s clear that we have additional capacity for more virtual machines. Let’s add a third virtual machine VM3 to the host.

Dynamic Memory

Let’s assume that user activity is increased and this increases memory demand by the workloads that are running in VM1 and VM2. Additional memory must be added to both VM1 and VM2

They cannot increase it beyond what is left in the shared pool of physical memory on the host.

Dynamic Memory

The host has 16 GB of RAM. That means that Hyper-V can never allocate more than 16 GB RAM to the parent partition and virtual machines.

Eventually demand will subside in virtual machines and they will return the unneeded memory back to the available pool so that it can be reallocated to other virtual machines should they have demand.

This gives you a high level view of what is happening in Dynamic Memory.

Dynamic Memory

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s