ESDS Knowledge Base

23
Jun

Hyper-V Dynamic Memory Best Practices

hyper-v_dynamic_memory

 

Introduction:

Hyper-V version 3 with Windows Server 2012 has a new feature which dynamically allocates memory (RAM) on a Windows virtual machine. What is that? And is it a complicated process?

It is simple; it adds memory to a VM as needed up to a limit defined in the configuration. The dynamic addition is actually a hot-add memory to the VM.

With this feature we can more efficiently manage the memory allocation to the virtual machine since without this feature we must first turn off the VM to change the allocated memory. With this feature, everything is handled dynamically. That’s to say hot-add by the Hyper-V manager, which interact with the virtual hosts.

Hyper-V also incorporated this feature in Windows Server 2008 R2 with Service Pack1. The following guest operating systems are supported:

  • Windows Server 2008 SP2
  • Windows Server 2008 R2 SP1
  • Windows 8
  • Windows Server 2012

How it works?

We will see a brief example here about adding and deleting memory dynamically on a VM to understand how it works…

Our Hyper-V server contains a VM that uses dynamic memory feature. It has 2 GB of memory assigned minimum and begins to saturate.

Hyper-V_Dynamic_RAM_1After enabling the dynamic memory feature, Windows will show warning message that the hypervisor needs additional memory through dynamic memory driver: DMVSC, Dynamic Memory VSC.

You will clearly understand in order to use this feature requires the system that taking advantage of the compatible virtual host which supports dynamic memory driver.

Hyper-V_Dynamic_RAM_2

OK, now our VM has a 3 GB of RAM, thanks to hot-added memory. The hours pass…the peak load of activity decrease and then our VM does not need as much memory.

A signal is sent to the Hyper-V host to withdraw the memory from our virtual machine, but we cannot remove memory directly from a Windows machine enthusiastically, otherwise a crash will obtain with a famous blue screen.

To counter this problem there is a solution. In fact, Hyper-V does believe in the system of exploitation when the VM memory is unavailable. Alright, as our VM no longer need to use that part of memory, it is then possible to reassign it to another needy VM. This is called as the “Memory Ballooning”.

The added extra memory to a virtual machine, 1GB, will be rendered in the virtual machine. We will allow it to use only minimum 2 GB.

Hyper-V_Dynamic_RAM_3

Configuring a virtual memory

To enable dynamic memory feature on virtual memory in Hyper-V manager, right click on the VM on which you need additional RAM, then click on “Settings”. Then on the left side, click “Memory” and in the right pane, select the check box next to “Enable Dynamic Memory”.

However, there are various fields:

-Minimum RAM: it must always be made available to the VM, and then the VM memory will not drop below this value. This is the minimum memory that the VM needs to function.

-Buffer: This buffer will be allocated to the VM memory very quickly with an area pre-allocated memory on each VM that can react quickly during a peak load.

It may be interesting to define a high value for this field when the VM is running an application that require a large amount RAM chunk for a moment and then release afterwards. This will meet the needs of the application. Conversely, set a low value on a VM if it turns an application that always seeks to use the maximum possible memory.

To determine this value, Hyper-V uses the percentage you point it and the amount of memory used at a time T by the virtual machine. After a calculation, it shows a value that will correspond to the available buffer.

-Memory Weight: It manages the memory availability on the priority of a machine relative to another. The higher the priority, the more Hyper-V will work to prioritize allocating memory for that VM rather than another whose priority is lower. It is important to prioritize critical virtual machines first and have significant advantage in term of memory.

Leave a Reply