Dynamic Memory Management

From Proxmox VE
Revision as of 09:26, 18 March 2013 by Martin (talk | contribs) (added win2012/win8)
Jump to navigation Jump to search

Introduction

Optimized and effective memory management is a key factor in virtualization environments. KSM and Auto-Ballooning enables sophisticated and economic configurations for physical RAM utilization.

KSM

KSM (Kernel Samepage Merging) is running in the Linux kernel and scans the memory of all the virtual machines running on a single host, looking for duplication and consolidating. With KSM we're able to improve virtual machine density by as much as 300% without impacting performance. One of the great benefits of using Linux as the hypervisor means KSM is not limited to KVM and virtual machines, but can also reduce memory pressure with normal Linux applications.

KSM in action

Just install several KVM virtual machines with the same OS (using at least 50 % of your physical memory on the host) and wait a few minutes. You will notice higher CPU activities on the host (ksm daemon) and the used memory on the host will be lowered significantly (see start page showing the overall memory usage).

Howto verify that KSM is working (how many pages are being shared between your KVM guests):

watch cat /sys/kernel/mm/ksm/pages_sharing

Note: a page is 4096 bytes

Ballooning

Memory ballooning (KVM only) allows you to have your guest dynamically change it’s memory usage by evicting unused memory during run time. It reduces the impact your guest can have on memory usage of your host by giving up unused memory back to the host.

The Proxmox VE host can loan ballooned memory to a busy VM. The VM decides which processes or cache pages to swap out to free up memory for the balloon. The VM (Windows or Linux) knows best which memory regions it can give up without impacting performance of the VM.

Requirements for Windows VM

You need to install the VirtIO Balloon Driver and the management service (blnsvr.exe -i).

Enable Auto-Ballooning on Windows 2012/Win8

More or less the same instructions as Windows 2008r2.

Enable Auto-Ballooning on Windows 2008r2

  1. Set the VM memory to "Automatically allocate memory within this range" - I choose 4096/2048 as example (see screenshot)
  2. Start the VM and install all virtio drivers, including the balloon driver (see screenshot)
  3. Copy and rename as Administrator the WIN7\AMD64 directory from the virtio.iso to "c:/Program files/Balloon"
  4. Open a CMD as Administrator and cd into "c:/Program Files/Balloon"
  5. Install the BLNSRV with "BLNSRV.exe -i"

As soon as the service is started, also the memory information displayed on the Proxmox VE GUI is identical to the value shown in the windows task manager (see screenshot).

If you need details about ballooning stats for this VM, go to the KVM monitor and enter 'info balloon'

VirtIO drivers: KVM project wiki downloads

Enable Auto-Ballooning on Windows 2003 / Windows Xp

You need to install the balloon service with BLNSRV, like for win2008.

You also need to install the driver manually

Download the "devcon" software on microsoft website

http://support.microsoft.com/kb/311272

Then install the balloon driver with

devcon install BALLOON.inf "PCI\VEN_1AF4&DEV_1002&SUBSYS_00051AF4&REV_00"

Requirements for Linux VM

Modern Linux Kernels does include the Balloon drivers by default. It works out of the box, and you only need to set the VM to "Automatically allocate memory within this range"

External Links

tbd.

Video Tutorials

tbd: Proxmox VE Youtube channel