Configuring memory for virtual machines

To optimize memory usage by virtual machines, Virtuozzo Hybrid Infrastructure uses a Linux feature called kernel same-page merging (KSM). The KSM daemon periodically scans memory for pages with identical content and merges those into a single page. That page is marked as copy-on-write (COW), so when a virtual machine needs to change its contents, the kernel creates a copy of the page for that VM and changes it. KSM allows using RAM overcommitment and avoiding swapping when many similar workloads run on the same server. However, we strongly recommend to configure swap space if you enable memory overcommitment.

Additionally, virtual machines running on a server are bound to its NUMA nodes, to keep VM processes as close to the memory they access as possible. When the load difference between NUMA nodes exceeds 50%, hosted VMs are rebalanced based on their memory and CPU usage.

You can configure the amount of memory that can be provisioned for virtual machines by setting the RAM overcommitment ratio. This is the ratio of the amount of maximum reserved RAM to physical. The default ratio is 1, which means that you cannot provision more than the amount of physical RAM available on all of the compute nodes. By increasing the ratio, you can increase the number of virtual machines running in the compute cluster but potentially reduce their performance. By default, memory guarantees for virtual machines are set to 50%, which allows increasing the RAM overcommitment ratio up to 2. However, the maximum recommended RAM overcommitment ratio is 1.5.

Memory overcommitment for virtual machines is only available if all of the compute nodes have enough swap space. Before enabling RAM overcommitment, you need to calculate the required swap space, and then configure it on each compute node.