Maximizing Your Virtual Machine Density in Hyper-V (Part 5)

If you would like to read the other parts in this article series please go to:

Introdution

In the previous article in this series, I talked about the acceptable ratios between virtual processors and logical processors. In this article, I want to continue the discussion by talking about memory allocations for virtual machines.

Dynamic Memory

Ever since Windows Server 2008 R2, Hyper-V has supported the use of dynamic memory. Dynamic memory allows you to configure a virtual machine to use a memory range rather than a fixed amount of memory. That way the virtual machine can claim or release memory on an as needed basis within the limits that are set by the administrator.

Using dynamic memory helps to improve virtual machine density by cutting down on memory waste. You do however, have to be careful about over subscribing your physical memory. Otherwise you could end up in a situation in which the host does not have enough physical memory to go around.

Dynamic memory is configured on a per virtual machine basis. You can access the memory settings by opening the Hyper-V Manager, right clicking on the virtual machine that you want to configure, and selecting the Settings command from the shortcut menu. You can see the memory settings in Figure A.

Image
Figure A: Hyper-V supports the use of virtual memory.

As you can see, there are several different virtual memory settings available. These settings include:

Startup RAM – The amount of physical memory required to boot the VM.

Minimum RAM – The least amount of memory the VM will ever require.

Maximum RAM – The most physical memory that should ever be allocated to the VM.

Memory Buffer – Extra memory provided to the VM as a buffer against memory shortages. The buffer is expressed as a percentage. For example, if a VM currently needs 1000 MB of memory and the buffer is set to 20%, then Hyper-V will attempt to allocate 1200 MB to the VM instead of the 1000 MB that it is asking for. This buffer helps with stability and performance.

Memory Weight – The memory weight setting can be thought of as a VM prioritization setting. When there is not enough physical memory to go around the Memory Weight value is used to determine which VMs have the highest priority and should therefore be the first to receive the requested memory.

Although dynamic memory is a standard Hyper-V feature, not every guest operating system is supported for use with dynamic memory. The guest operating systems that Microsoft currently supports for use with dynamic memory include:

  • Windows Server 2012
  • Windows Server 2012 R2
  • Windows 8 and 8.1
  • Windows 7
  • Windows Server 2008 R2 (SP1 and higher)
  • Windows Server 2008 (SP2 and higher)
  • Windows Vista (SP1 and higher)
  • Windows Server 2003 R2 (SP2 and higher)
  • Windows Server 2003 (SP2 and higher)
  • SUSE Linux Enterprise Server 11 (SP3 and higher)
  • Ubuntu 13.10

The Smart Paging file

As I explained earlier, Microsoft makes a distinction between minimum memory and startup memory. Sometimes virtual machines require more memory to boot than they require to actually run. Although it is sometimes possible to free up a significant amount of physical memory by differentiating between startup memory and minimum memory, this distinction can lead to problems on high density host servers.

To show you what I mean, imagine for a moment that a particular virtual machine requires 1 GB of memory to boot, but once the boot completes and the guest operating system stabilizes the virtual machine is able to run on 512 MB of memory. Since we are talking about ways of maximizing virtual machine density, let’s also pretend that the host server in question has the highest possible number of virtual machines running on it and that there isn’t any extra memory to spare.

This type of situation really isn’t all that uncommon, and it isn’t really problematic so long as the host operating system has sufficient memory and none of the guest machines are going to be needing any additional memory. What can be problematic however is a virtual machine reboot.

Suppose for a moment that you rebooted the virtual machine that I used in my earlier example. The virtual machine can run with 512 MB of memory, but it needs a full gigabyte of memory to be able to boot. The problem is that there isn’t a gigabyte of physical memory available because the other virtual machines are using all of the available memory. In essence, there isn’t enough memory to allow the virtual machine to boot.

The way to avoid this problem is to take advantage of a Hyper-V feature called the Smart Paging File. The smart paging file works similarly to the way that the Windows page file has worked for decades. The basic idea is that disk space can be used to temporarily make up for shortages in physical memory. That way, if a virtual machine is rebooted and there isn’t enough memory to complete the boot process, the smart paging file can be used as a temporary substitute for physical memory, thus allowing the virtual machine to boot.

The most important thing to understand about the smart paging file is that although it works similarly to the Windows page file, it is a completely separate mechanism. The Windows page file exists in the form of a file named Pagefile.sys. This file is a part of the Windows operating system. This means that a virtual machine’s Pagefile exists on the virtual hard disk. Similarly, there may also be a page file for the host operating system. That page file exists on the server’s physical boot drive.

The Windows page file can be used to make up for all manner of memory shortages. For example, if a virtual machine has been provisioned with a maximum of 4 GB of memory and an application needs 5 GB then the virtual machine’s page file is used to make up the difference.

The smart paging file is completely different. Whereas a virtual machine’s Windows page file exists on the virtual machine’s virtual hard disk and is used to overcome memory shortages, the smart paging file exists outside of the virtual machine, and is used only when there is not enough physical RAM available for the virtual machine to be rebooted. This is the only time that the smart paging file is used. The smart paging file is not used when a VM is being started from an Off state or in failover situations.

The smart paging file is configured on a per virtual machine basis. You don’t have to do anything to enable the smart paging file option, but you do need to make sure that the file exists on a volume with a sufficient amount of free space to accommodate the smart paging file.

You can control the smart paging file’s location by opening the Hyper-V Manager, right clicking on a virtual machine, and choosing the Settings command from the shortcut menu. Upon doing so, Windows will display the Settings dialog box for the selected virtual machine. You can see the Smart Paging File Location option shown in Figure B.

Image
Figure B: The smart paging file location is configurable on a per VM basis.

Conclusion

As you can see, the use of dynamic memory can go a long way toward improving virtual machine density. In Part 6, I plan to conclude the series by examining some Windows Server 2012 R2 features that can help to improve virtual machine density.

If you would like to read the other parts in this article series please go to:

Leave a Comment

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top