This post will detail and explains some basic concept about ESXi memory reclamation technique called ballooning. What is VMware Memory Ballooning is the name of today's post. We'll put it again in our Tips Category. You might already pass your VCP exam and (or) you might know this topic well. We can understand that. This topic is mostly for folks just starting with virtualization and learning about it.
Note that your ESXi host will never use any of the memory reclamation technique if you don't allocate more memory to your VMs, then your ESXi host actually has physically installed. You “will not overcommit memory”, we say.
VMware ballooning is a memory reclamation technique used when ESXi host runs out of memory. Your VMs configured with some RAM within their virtual hardware will consume the memory via their applications running in memory.
Before we dive in, I think it would be a good idea to talk about the different types of memory we have on ESXi. We have the host physical memory, guest physical memory, but also virtual memory which is within each VM and where the applications run.
- Host physical memory – physical RAM of each ESXi host (server). This is a physical resource.
- Guest physical memory – The Guest OS memory. A memory that is visible to the guest operating system running in the virtual machine.
- Virtual Memory – memory where an application runs within a VM. It is a continuous virtual address space presented by the guest operating system to applications. It is the memory that is visible to the applications running in the VM.
Screenshot from VMware PDF – Understanding Memory Resource Management in VMware.
What is VMware Memory Ballooning?
Ballooning is a process where the ESXi host reclaims memory back from the virtual machine. Ballooning is an activity that happens when the ESXi host is running out of physical memory. The demand of the virtual machine is too high for the host to handle.
Each VM has a driver installed via VMware tools. This driver is called a Balloon Driver. The guest operating system is able to decide which memory pages should be swapped to disk. When the host needs to free up some memory it will notify a special driver (vmmemctl) that is installed as part of the VMTools. This driver then consumes some of the memory that the guest OS believes is physically present in the virtual machine. The guest OS will then swap memory to disk reducing the load on the
This driver then consumes some of the memory that the guest OS believes is physically present in the virtual machine. The guest OS will then swap memory to disk reducing the load on the host's physical memory. The host will then reallocate that memory to other virtual machines.
Quote from (a very old) VMware PDF:
By inflating the balloon, a virtual machine consumes less physical memory on the host, but more physical memory inside the guest. As a result, the hypervisor offloads some of its memory overload to the guest operating system while slightly loading the virtual machine. That is, the hypervisor transfers the memory pressure from the host to the virtual machine. Ballooning induces guest memory pressure. In response, the balloon driver allocates and pins guest physical memory. The guest operating system determines if it needs to page out guest physical memory to satisfy the balloon driver’s allocation requests. If the virtual machine has plenty of free guest physical memory, inflating the balloon will induce no paging and will not impact guest performance.
As you can see, it is well organized and orchestrated.
Disable VMware Balloon Driver?
You might ask what if (and how) to disable the VMware balloon driver within the guest OS. Is it a good idea? Well, there is a VMware KB article which talks about the Disabling the balloon driver (rather outdated). IMHO I don't see much interest in doing that.
This KB article provides the step-by-step to disable the balloon driver in a VM. But they emit a warning which says:
Disabling the balloon driver in a virtual machine results in performance issues with the ESXi/ESX host.
Where to check if the Balloon driver is installed or not?
Here is an overview from the lab. Connect via Putty and SSH, then run ESXTOP and chose “m” for memory. Use “f” key to change fields.
Where else to check?
You can also use vSphere Client to check if memory gets ballooned or not. If you Select your host > Monitor > Advanced > Memory. In my case I turned off my DRS and did a vMotion on a bunch of my VMs from host01 to host 02 in order to “generate” some memory pressure on my host.
Wrap Up:
VMware Ballooning isn't the only technique of memory reclamation. There is also other techniques such as VMware Transparent Page Sharing (TPS) which is a proprietary solution to transparently share memory pages between virtual machines and eliminating redundant copies of memory pages.
Then there is memory compression where ESXi will compress the memory before the need for swapping (bad, worst to happen). But we might talk about those in one of our future posts. If you are over-committing your hosts then this is an important topic to review.
With our short blog post, we give you the idea how it works and where to look at the metrics, but one must study further to get the whole picture how all memory management techniques work within VMware infrastructure. VMware TPS kicks in first, then there is Ballooning and finally a Swap.
VMware Oversubscription/Overcommit allows administrators basically, to assign more aggregate RAM to virtual machines than is actually physically available inside the server, and still won't penalize the environment and the end users, by low performance.
More from ESX Virtualization:
- What is VMware Hot-Add RAM and How to use it?
- What Is VMware Virtual NVMe Device?
- What is VMware CPU Ready?
- What is VMware Instant Clone Technology?
- VMware Virtual Hardware Performance Optimization Tips
Stay tuned through RSS, and social media channels (Twitter, FB, YouTube)
Maciej says
Hi Vladan, good article as usual. But i think you could write few words about memory state calculations, minfree etc. because it is not always clear for all.
Regards
Vladan SEGET says
Good Idea Maciej, keep them comming -:).
Will do.
++
Anthony Maw says
Thanks for the explanation. But it would be useful to clarify if the VMTools Balloon driver requests pageable or non-pageable memory from the Guest VM. If it’s just pageable memory then the Guest is liable to page the Balloon driver’s memory to disk which defeats the purpose. If it’s non-pageable memory then the Balloon driver forces the Guest OS to dump other running application’s pageable memory to disk. Of course ESX has to know that the fake requested non-pageable memory is from the Balloon driver in order to release physical RAM.