/cmaneu
[ | ][EN | FR]

Hyper-V: a quick tour of Dynamic Memory

Archive media: Some illustrations are no longer available at their original addresses. Their original links are preserved below.

The beta of Service Pack 1 for Windows Server 2008 R2 introduces a new feature: Dynamic Memory. What is it? A feature that dynamically adjusts the amount of RAM assigned to a virtual machine, making even better use of hardware resources.

This article is based on the beta, so some details may not be entirely accurate for the final release.

What is Dynamic Memory?

Until now, administrators of Hyper-V virtual machines running on Windows Server 2008 and 2008 R2 could assign a fixed amount of RAM to a virtual machine. When the VM starts, that amount is allocated from the host’s memory and remains unchanged until the machine shuts down. A host with 8 GB of RAM could therefore have ten virtual machines configured with 2 GB each, but could start only three of them. The host operating system does not need 2 GB, but in this example, three is the limit.

To understand why this is a limitation, we need to return to the most common reason for virtualization: server consolidation. One goal of consolidation is to share hardware resources more efficiently. By virtualizing servers, we reduce the number and power of processors needed to run the same services, and we also save disk resources, whether using internal disks, DAS, or SAN storage. But what about RAM? Until now, this was the remaining area where virtualization made no efficiency difference: 2 GB of RAM on a physical server still required 2 GB when virtualized. That was true… until now.

Dynamic Memory lets you specify two memory values:

  • Startup memory: the amount assigned when the machine starts, seen by the BIOS, and the minimum the machine will receive, whatever the circumstances.
  • Maximum memory: the most the virtual machine can occupy if the conditions are met, meaning that it needs the memory and the memory is available.

How does it work?

“Changing RAM on the fly is impossible! What operating system will support that?” A very good question! A magic wand? A druid’s potion? Does it only work on a special, entirely managed operating system? A little of all three…

The technical difficulty is that our operating systems were not designed for RAM to change while they are running. Providing this capability first requires handling that situation. On the host side, Hyper-V’s architecture makes it possible: that is the magic wand. On the guest OS side, things become more complicated for several reasons:

  • The guest OS must accept that part of its memory can be taken away, meaning that some memory pages will no longer be accessible.
  • Dynamic Memory is automatic: you do not need to intervene to increase memory when necessary, within the limits you have set. The guest system therefore needs to communicate with Hyper-V to indicate whether it is short of memory.

The magic potion, alongside Hyper-V’s architecture (VSP/VCP/VMBus), is the VM Additions Tools. The version included with this beta adds kernel functionality that enables these changes.

Hmm, “additional kernel functionality” — does that work with my SUSE Enterprise installation? No! At least, not in this version. The feature is only available on certain operating systems. Here is the list for this beta; other systems are planned for the final release, and both x86 and x64 versions of these systems are supported:

  • Windows Server 2008 R2 Enterprise SP1
  • Windows Server 2008 R2 Datacenter SP1
  • Windows Server 2008 Enterprise SP2
  • Windows Server 2008 Datacenter SP2
  • Windows Server 2003 R2 Enterprise SP2 or later
  • Windows Server 2003 R2 Datacenter SP2 or later
  • Windows Server 2003 Enterprise SP2 or later
  • Windows Server 2003 Datacenter SP2 or later
  • Windows 7 Enterprise
  • Windows 7 Ultimate
  • Windows Vista Enterprise SP2
  • Windows Vista Ultimate SP2

Dynamic Memory configuration

Once the feature is enabled and the integration components have been updated, the guest and host operating systems communicate, assess memory requirements, and allocate more memory to a virtual machine when necessary. A priority system handles shortages: you can prioritize which machines receive memory when several need it and there is not enough available to satisfy every request.

At any time, you can see how much memory has been allocated to a virtual machine directly in Hyper-V Manager, as shown below, or through Performance Monitor, with 16 new counters divided into two groups.

Allocated memory in Hyper-V Manager

There are many other concepts to understand for a detailed picture of Dynamic Memory — ballooning, memory pressure, and so on — which may become the subject of a future article ;).

Any final advice before I get started?

Several points, actually! Here are some things to watch if you want to try this new feature:

  • Installing the new integration components makes your virtual machines incompatible with hosts that have not also been upgraded to the SP1 beta!
  • Enabling Dynamic Memory on a virtual machine requires shutting it down.
  • I have not yet tested this solution in a high-availability environment. Although failover clustering is supported, with considerations around total and available memory per cluster, I have found nothing about Dynamic Memory and Live Migration. Something to test.
  • Finally, remember: this is a beta :).

Another new feature in SP1 is Remote FX, a set of technologies that enables a rich multimedia experience over RDP, including 3D applications. Perhaps a subject for another article ;).