Friday, December 13, 2013

Configure Hyper-V dynamic memory in Windows Server 2012, Windows Server 2012 R2

Hyper-V Dynamic Memory is not new in Hyper-V environment. This feature started at Windows Server 2008 R2 SP1. In Windows Server 2012 and Windows Server 2012 R2, this feature is enhanced. Microsoft added "Minimum RAM" and worked with "Smart Paging".

Before configuring Hyper-V dynamic memory, make sure operating systems are installed latest integration services and support this feature.

Now, I will configure the VM, DC01.contoso.com, with dynamic memory for testing.

Lab environment
  • 1 standalone Hyper-V server installed Windows Server 2012
  • 1 VM installed Windows Server 2012 R2 named DC01.contoso.com

Assuming that DC01.contoso.com was installed successfully. If you would like the installation steps, please read "Install Windows Server 2012 with GUI".

1. On the Hyper-V server, log in as "Administrator".
2. Launch "Hyper-V Manager".
3. Right-click "DC01.contoso.com", select "Settings".


4. On left pane, select "Memory".


Startup RAM: Basically, this value of "Startup RAM" should be set to right amount. The right amount should be enough to boot up the Windows and related services in it.

Minimum RAM: The minimum value of the RAM should be assigned for the VM. You can measure the ram when the VM is idle and then insert the suitable value in it.

Maximum RAMThe maximum value of the RAM should be assigned for the VM. According to Microsoft, you should not insert the value greater than the guest operating system support value.

Memory bufferSpecifies how much memory Hyper-V will attempt to assign to the virtual machine compared to the amount of memory actually needed by the applications and services running inside the virtual machine. Memory buffer is specified as a percentage because the actual amount of memory that represents the buffer changes in response to changes in memory usage while the virtual machine is running. Hyper-V uses performance counters in the virtual machine that identify committed memory to determine the current memory requirements of the virtual machine and then calculates the amount of memory to add as a buffer. The buffer is determined using the following formula:

Amount of memory buffer = how much memory the virtual machine actually needs / (memory buffer value / 100).

For example, if the memory committed to the guest operating system is 1000 MB and the memory buffer is 20%, Hyper-V will attempt to allocate an additional 20% (200 MB) for a total of 1200 MB of physical memory allocated to the virtual machine. 

The minimum value is 5%.

Memory weight: Provides Hyper-V with a way to determine how to distribute memory among virtual machines if there is not enough physical memory available in the computer to give virtual machine its requested amount of memory.

5. Now, I set the following settings for the memory of "DC01.contoso.com".

  • Startup RAM: 1024
  • Minimum RAM: 512
  • Maximum RAM: 2048
  • Memory buffer: 10%
  • Memory weight: Lowest

6. Click "OK".
7. Power on "DC01.contoso.com".
8. Back to Hyper-V Manager, next to the bottom, click "Memory".


Now, DC01.contoso.com was assigned 1024 MB RAM.

After a few minutes, Hyper-V server automatically adjusted the memory value to minimum value for DC01.contoso.com because the memory demand of DC01.contoso.com is 296MB.


9. Right-click "DC01.contoso.com", select "Settings".
10. Next to "Memory".


When the VM is running, the value of "Startup RAM" cannot be adjusted. Plus, the value of "Minimum RAM" cannot be configure to be higher than original value when the VM is running and the value of "Maximum RAMcannot be configure to be lower than original value when the VM is running .



11. Click "Cancel".
12. Shut down "DC01.contoso.com".
13. Launch "PowerShell" as administrator.
14. Perform "Set-VMMemory -VMName DC01.contoso.com -DynamicMemoryEnabled $True -MinimumBytes 128MB - StartupBytes 128MB -MaximumBytes 1GB -Priority 0 -Buffer 10 -Passthru".


15. Perform "Start-VM DC01.contoso.com" to start the VM.
16. Back to Hyper-V Manager, next to the bottom, click "Memory".


The memory of DC01.contoso.com has been automatically adjusted because the startup RAM is not enough.

17. Log in DC01.contoso.com as administrator and then launch "System".


The "Installed memory (RAM)has been automatically adjusted in the VM.

Remark: The "Installed memory (RAM)" only updated the value which is higher than current.

Remark: If a VM is assigned static RAM setting, you cannot modify it to dynamic memory when the VM is running.


Should I configure the MemoryReserve registry setting?
Hyper-V running on Windows Server 2012 and Windows Server 2012 R2 automatically calculates an amount of memory to reserve for exclusive use by the management host operating system. This memory is used to run virtualization services. If the computer is part of a failover cluster, Hyper-V also reserves enough memory to run failover cluster services. In previous versions of Hyper-V, you might have needed to modify the MemoryReserve registry setting to ensure adequate memory for these functions. This is no longer necessary for Hyper-V running on Windows Server 2012 and Windows Server 2012 R2.

Quote from Hyper-V Dynamic Memory Ovreview

Reference:

This posting is provided “AS IS” with no warranties, and confers no rights!

No comments:

Post a Comment