Configuring Hyper-V Dynamic Memory

Last year I attended a Dynamic Memory session at TechEd New Orleans, not long after I saw the files and scripts for the demo were posted by the presenter (Ben Armstrong aka Virtual PC guy) on his blog. 

Since then I have been meaning to put that demo together and at long last I have got round to doing it!  In the likely event of forgetting how, I’m posting it here.

Some quick information about the new hyper-v memory settings we need to know for the demo

Configuring Hyper-V Dynamic memory

We need the host server running Hyper-V, with Windows Server 2008 R2 Service Pack 1 installed, then our guest operating system to meet the requirements and have the latest integration services updated to the SP 1 version.

In the Hyper-V Management Console after selecting a guest we right click and select Settings then Memory, the memory management page should look like our picture below.

image

To enable dynamic memory we need click on Dynamic and enter some values, our options are

Startup RAM:

The amount of ram we want our virtual machine to start with (between 8 and 65536)

Note, the requirements guide above has an appendix with recommended Start-up memory settings, it suggests 512 MB minimum for all except supported versions of Windows 2003 Server which are 128 MB minimum.

Maximum RAM:

The maximum amount of ram we want our virtual machine to have access to (between 8 and 65536).

Memory Buffer:

The amount of memory we will reserve as a percentage of the memory in use, for a good explanation of how this works read Virtual PC Guys article posted here – What is the memory buffer when dynamic memory is enabled?

Memory Weight:

This where we can assign memory allocation prioritization for a given virtual machine, my machines.

So that’s a quick look at the GUI settings, moving to the host server there’s another setting consider:

Host reserve

With the introduction of dynamic memory comes a new ability to assign the amount of ram we can reserve for our Hyper-V hosts usage.  We need to set this to a figure that will allow the host to reliable run and cater for any management security agents.  My demo shuttle has 16GB and I have opted to reserve 2048MB.

To configure the amount of ram we need to set a registry key as follows:

1) Navigate to HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization

2) Create a new DWORD entry with a name of MemoryReserve

3) Enter the value of memory to reserve for the parent partition in MB

We need to reboot for this to take effect

Scripting Dynamic memory changes

One of the first things I noted in Ben Armstrong’s demo was the scripting of dynamic memory settings. 

Ben has posted a series of articles which you can read on his blog, they are

Scripting dynamic memory, part 1- reading the configuration

Scripting dynamic memory, part 2- displaying current usage

Scripting dynamic memory, part 3- looking at performance counters

scripting-dynamic-memory-part-4-configuring-memory

Scripting dynamic memory, part 5- changing minimum memory

In post 5, changing the minimum memory there’s important information to note on editing settings. 

If you do edit minimum setting to differ from the start-up RAM then n the Hyper-V Management console for the specified virtual machine, when selecting hardware settings and memory you will see a warning has appeared.

image

For general use I guess we best leave that setting alone until we know exactly how we can leverage something by changing it.

Changing multiple guests

I have download and edited this script written by Vlad Borodin, I have adjusted it only to enable dynamic memory, set a memory buffer and the memory weight.

image

Giving that a whirl it’s fired through my VM’s

image

Now we can start experimenting with our test host and it’s virtual guest

In the Hyper-V Console we see the following three columns

Assigned Memory

Real-time view of how much physical memory is allocated to the virtual machine

Memory Demand

How much memory the virtual machine needs at this time to meet the requirements of the active processes running in the virtual machine. The total committed memory based on data obtained from performance counters

Memory Status

How much of the buffer amount specified for the virtual machine is available

Status is displayed as one of the following:

  • OK – there is enough physical memory available to give the virtual machine the full amount of memory buffer.
  • Low – the current amount of memory assigned to the virtual machine as a buffer is lower than amount that Hyper-V determines should be available as a buffer.
  • Warning – there is not enough physical memory available to assign any memory buffer to the virtual machine.

image

To start my testing I have downloaded and edited another of Ben’s scripts which is running in these guests simulating workload.

image

So that’s enough to get a demo running and later in the week when I have experimented with endpoints and various different applications and memory allocations I can share some monitoring and best practices.

Linkedin Facebook Twitter Email
Posted on March 7, 2011 at 2:40 am by Ronnie · Permalink
In: Virtualization