Many schools and districts are employing virtualization to help them save money by making more efficient use of hardware. One way they can do this is by consolidating underutilized servers onto Hyper-V hosts. Then, instead of having a dozen servers with average processor utilization of about 20 to 30 percent, they can have one or two high-end Hyper-V machines hosting the server workloads as virtual machines.

Total physical memory is generally the limiting factor in determining the number of virtual machines that can run on a Hyper-V host. For example, if each virtual machine requires at least 8 megabytes of RAM and the host has 64MB, the maximum number of virtual machines on the host would be seven because some memory must be reserved for overhead (such as the host operating system itself).

Server workloads are rarely constant in the real world, and reserving 8MB of RAM for each virtual machine often is overkill. But because Hyper-V requires a fixed amount of RAM to be assigned to each virtual machine, most administrators play it safe by allocating each virtual machine more RAM than it may actually need. Such static assignment of RAM leads to the same type of inefficiency that server consolidation is meant to address – the underutilization of physical hardware resources.

Enter Dynamic Memory

To address this problem, Microsoft is introducing a new feature called Dynamic Memory in Service Pack 1 for Windows Server 2008 R2. Dynamic Memory allows the amount of memory assigned to each virtual machine on a Hyper-V host to be dynamically allocated in real time in response to the changing workload requirements of the virtual machine. The result is more efficient use of the physical memory resource on the host, thereby making possible greater consolidation ratios (more virtual machines per host).

To use Dynamic Memory, your virtualization host must be running either Windows Server 2008 R2 with the Hyper-V role or the free standalone product, Microsoft Hyper-V Server 2008 R2. In addition, the guest operating systems running in the virtual machines must be either Windows Server 2008 R2, Windows Server 2008, Windows Server 2003 or Windows 7.

The figure below shows four virtual machines, each of which has been assigned 4 gigabytes of physical memory. These virtual machines represent the workloads of four physical servers that have been consolidated onto a single Hyper-V R2 host. But because the host has just 12GB of total RAM, only two of these virtual machines can run at any given time, as seen in Figure 1:

Figure 1: Static memory allocation allows only two virtual machines to run on the host

Let's see how Dynamic Memory allows us to overcome this limitation once the host has been upgraded to Hyper-V R2 SP1.

Preparing to Use Dynamic Memory

Before a virtual machine running on a Hyper-V R2 SP1 host can use Dynamic Memory, you need to upgrade the integration components for the virtual machine. To do this, begin by starting the virtual machine and logging on to the guest operating system. Then open the virtual machine using the Virtual Machine Connection tool and select Insert Integration Services Setup Disk from the Action menu, as shown in Figure 2:

Figure 2: Upgrading the integration services for a virtual machine

After you select Install Hyper-V Integration Services, you'll be notified that a previous version of Hyper-V integration services has been detected, and you will be prompted to upgrade to the newer version. Once the integration services have been upgraded, you'll need to restart the virtual machine for the changes to take effect.

Turning On Dynamic Memory

Once integration services have been upgraded, you must shut down the virtual machines before you can turn on Dynamic Memory for them. You can then open the Settings dialog for the virtual machine and select the Memory option. As Figure 3 shows, the virtual machine is currently assigned 4GB of RAM in a fixed (static) configuration.

Figure 3: A virtual machine with 4GB of RAM assigned in a static configuration

To enable Dynamic Memory for the virtual machine, select the Dynamic option, as shown in Figure 4. Then specify values for the following four parameters:

Watching Dynamic Memory at Work

To get a feel for how all this works, you can assign 1GB and 64GB, respectively, as the Startup RAM and Maximum RAM for each virtual machine on the host. Then configure the Memory Buffer and Memory Priority settings for each virtual machine as shown in Figure 5:

Server

Memory Buffer

Memory Priority

NYC-SRV-01

80%

High

NYC-SRV-02

80%

Low

NYC-SRV-03

50%

Medium

NYC-SRV-04

20%

Low

Figure 5: Configuring Memory Buffer and Memory Priority settings

When the virtual machines are under load, the updated Hyper-V R2 SP1 Management Console shows the total amount of RAM currently allocated to each virtual machine and the amount of RAM allocated to the buffer for each virtual machine as a percentage of committed memory, as shown in Figure 6:

Figure 6: Dynamic Memory allows a greater number of server workloads to be consolidated on a host

Note that Virtual Machine 1 is using more RAM than the other virtual machines because it has the highest memory buffer allocation and highest memory priority. In fact, under load its memory usage has dynamically grown from 1GB at boot time to almost 6GB. Meanwhile, the total RAM utilized by all virtual machines on the host is almost 11GB, leaving just enough for the requirements of the host itself.

This demonstrates how the new Dynamic Memory feature of Windows Server 2008 R2 SP1 is able to grow and shrink the RAM allocated to each virtual machine in response to changes in workload while efficiently using as much RAM as possible on the host.

Dynamic Memory is going to help schools save money by achieving even higher server consolidation ratios on Hyper-V hosts. To try out Dynamic Memory today, download the free beta of Service Pack 1 for Windows Server 2008 R2 from Microsoft's TechNet Evaluation Center. For additional technical details concerning how Dynamic Memory works and how to configure it, check out the white paper Implementing and Configuring Dynamic Memory, available from the Microsoft Download Center.

Mitch Tulloch is a Microsoft Most Valuable Professional and lead author of the Windows 7 Resource Kit from Microsoft Press.