Using memory management techniques to optimize available resources helps ensure the success of your VMware vSphere environment. VMware vSphere offers several ways to enable memory over-allocation and, in turn, sets up efficient resource use.
Advanced techniques for vSphere memory management
These memory management techniques allow VMs to continue to work and prevent the VMs from ever knowing you have allocated more than the available memory.
Transparent page sharing and memory ballooning
More resources on vSphere 5 features
New storage management functionality, vSphere Storage Appliance
Top 5 security features in VMware vSphere 5
Five exciting VMware networking features in vSphere 5
In transparent page sharing (TPS), the hypervisor analyzes a VM's activity and identifies similar memory pages among other VMs on the host. If the hypervisor discovers identical or redundant memory pages on different VMs, it will share these pages with those VMs and set pointers to the memory blocks. TPS is extremely useful if you run the same operating system (OS) on multiple VMs because that OS will load the same files multiple times.
In addition to TPS, vSphere uses memory ballooning to optimize memory usage. To use this memory management technique, you need to install a special balloon driver in the VM. This driver is part of the VMware Tools that admins install on a specific VM. The hypervisor uses the driver to reclaim unused memory from a VM but avoids reclaiming memory from a VM already short on memory.
Because the balloon driver is installed in the guest OS, it knows the specific memory needs of that operating system. If the host OS is short on memory, it can poll all balloon drivers on other VMs within the host to request available memory and, in turn, grant that memory to VMs. With the balloon driver in the guest, or virtualized OS, it will not rob any VMs of the memory they need.
Alternative memory management techniques
If memory ballooning and transparent page sharing don’t optimize resource usage for a particular vSphere environment, the hypervisor will enable swapping. With this memory management technique, the hypervisor reclaims used memory pages and stores them on a swap file. Disk-based storage is much slower than physical RAM storage, so swapping severely limits VM performance and is not a desirable way to optimize resource usage.
Alternatively, the hypervisor can enable memory compression, where it attempts to compress memory pages. If a page can be compressed to at least 50% of its original size, it is stored in a memory cache for compressed pages. The host only considers memory compression if it is out of memory and would otherwise need to start swapping memory. Memory compression does not impede the performance of an ESXi host the way swapping does.
Even if the hypervisor uses the vSphere memory management techniques, it will not know which VMs are the most important to your environment. As such, vSphere admins must also use memory optimization techniques such as reservations, limits and shares, which I will explain in a follow up to this article.
This was first published in September 2012