Today we have a guest post to the blog from Venkatramani Krishnamurthy, a Tech Support Engineer in our India offices. Venkat (for short) gives us an introduction to some of the different ways ESX and ESXi manipulate memory.
There are four different methods by which ESX reclaims virtual machine memory. They are:
- Transparent Page sharing
- Hypervisor swapping
- Memory compression
Transparent Page Sharing
In situations where many virtual machines with identical memory content are running on an ESX host, the hypervisor will maintain just a single copy while reclaiming the redundant ones. This results in a reduction of the host memory consumption by the virtual machines.
The redundant pages are identified by their content. ESX employs a special hashing algorithm to identify these pages.
This is an innovative memory reclamation technique where the guest operating system is made aware of the host's low memory status. The guest operating system by default is not aware that it is running in a virtual machine and the amount of free host memory. The balloon driver is part of the VMware Tools installation. It communicates with the hypervisor directly which will set the balloon size based on the amount of host physical pages it needs to reclaim. The balloon driver then pins the pages in the guest free list and the hypervisor then reclaims the host physical pages which are backing them. If the guest operating system is under memory pressure, it will decide which guest pages to page out without any intervention from the hypervisor.
This is generally used as a last resort to reclaim memory. In this technique, the hypervisor creates a separate swap file for each virtual machine when it is powered on and swaps out guest physical memory thus freeing up host memory.
Here instead of the pages being swapped out, they are compressed and stored in a cache on the main memory itself. These pages can be accessed again just by a decompression rather than through disk I/O in the case of page swapping which can significantly improve application performance when the host is under memory pressure. If a page cannot be compressed, it will be swapped out.
A word about Host free memory states.
There are four different states namely, high, soft, hard and low. Page sharing is enabled by default. The memory state in which the host state is in determines if swapping or ballooning is to be employed.
In the high state no reclamation techniques are employed unless there is a virtual machine memory limit configured. In the soft state, ballooning is employed. In the hard state, both ballooning and swapping is used. During swapping, memory compression is also activated. In the low state, in addition to employing all memory reclamation techniques, execution of all virtual machines that consume more memory than their target memory allocations is blocked.
For further reading on this topic, refer to our guide that explains more fully how this works – http://www.vmware.com/files/pdf/techpaper/vsp_41_perf_memory_mgmt.pdf