Skip to main content

VMware Memory Management Part 3 – Memory Ballooning

This post we are going to understand in detail about Memory Ballooning. Memory Ballooning is one of the common question which are asked during VMware Administrator interviews to test the knowledge of the candidate because there are lot of misunderstanding out there about this feature. So, decided to explain about VMware Memory Ballooning in simple and understandable manner.
VMware Memory Ballooning is one of memory reclamation technique used by hypervisor, when ESXi host is running low on memory. We have discussed in detail about ESXi host Memory states in my previous post “Understanding ESXi Host Memory States”. When the ESXi host memory state is High, None of the action will be taken by hypervisor expect Transparent page sharing. In understand about Transparent Page sharing, take a look at my post “Understanding TPS”. Memory Ballooning will be active, if your ESXi host Memory state is soft.
Memory Ballooning is the memeory reclamation technique used by hypervisor to reclaim the memory back from the virtual machine. Ballooning will happen on the ESXi host which is running out of physical memory or  its memory state is soft. In Virtualization, ESXi host doesn’t know what guest operating is performing and also Guest does not aware that it is running on virtual machine. Then how does ESXi host will request the memory back form the guest operating system? . Thats where balloon driver come into picture. There is balloon driver called vmmemctl.sys which is running on the virtual machine which is available as part of VMware Tools. When ESXi host running low on physical memory, It uses ballooning driver (vmmemctl.sys) to determine the how much memory from virtual machines can be get back to prevent the hypervisor swapping.
Before I explain about Memory ballooning in detail, I would like explain 3 Memory terminologies which you should understand to better understand the Memory ballooning.
1. Host Physical Memory : Memory which is visible to your ESXi host or in other terms available on the your physical server or system
VMware Memory Terminology
2. Guest Physical Memory : Memory which is visible to your Guest operating system running in the VM. Let’s say , you have created a VM called VM1 with 4 GB of memory. Guest OS will see 4 GB of memory, which is referred to as Guest Physical memory.
3. Guest Virtual Memory : Guest Virtual memory mostly visible to your applications running inside the Virtual machine. Guest Virtual Memory refers to a continuous virtual address space presented by the guest operating system to applications.

Memory Ballooning with Real- Time Example:


Memory Ballooning

1. You are running a virtual Machine called ” VM1″ and You are starting a application called Microsoft Excel on that VM. Microsoft Excel as an application will ask the windows guest operating system for memory. Windows will provide the memory to the application and map it from the  Guest virtual memory -> guest physical memory
2. When the  Guest Virtual Memory is mapped Guest Physical memory, Hypervisor sees the request for memory from guest and hypervisor maps guest physical memory -> Host physical memory. You are generating report on Microsoft Excel application for around 2 hours and  closed the application ,once you have done with it.
3. When you close the Microsoft Excel, Guest operating system will mark the memory allocated to Microsoft excel as “free” and make it available for other applications running on the guest OS but your hypervsior will not aware aware about the “free memory list” of your guest OS, so it keeps the memory mapped in the host physical memory and which puts the memory load on the ESXi host.
4. So When ESXi host is running low on memory or ESXi host memory state is Soft, VMware Memory Ballooning comes into picture. Hypervisor will ask the balloon driver installed inside the virtual machine to “inflate” . Since, memory ballooning driver is running on the guest operating system, It will get the memory from the “free list”. Hypervisor will detect the memory reclaimed by the balloon driver and will free it up on the host physical memory layer and provides that physical memory to other virtual machines which is in need of memory instead of swapping it into disk. By default, Balloon driver (vmmemctl.sys) can reclaim upto a maximum of 65 % of guest physical memory. For example, You VM is allocated with 1000 MB of memory, It can be reclaimed upto 650 MB using this technique.

Analyzing Memory Ballooning Statistics:

You can verify the memory ballooning  stats from Esxtop ,Virtual Machine Resource Allocation tab and also using vCenter Performance Graphs.
esxtop -> Press m
You will see the “MEMCTL/MB” counter which shows us the overall ballooning activity (22110 MB). The “curr” and “target” values are the accumulated values of the “MCTLSZ” and “MCTLTGT” as described below.
Memory Balloning_1We have to look for the “MCTL” columns to view ballooning activity on a per VM basis:
“MCTL?”: indicates if the balloon driver is active “Y” or not “N”. If VMware tools is not installed or not running this value will show as “N”
“MCTLSZ”: the amount (in MB) of guest physical memory that is actually reclaimed by the balloon driver
“MCTLTGT”: the amount (in MB) of guest physical memory that is going to be reclaimed (targeted memory). If this counter is greater than “MCTLSZ”, the balloon driver inflates causing more memory to be reclaimed. If “MCTLTGT” is less than “MCTLSZ”, then the balloon will deflate. This deflating process runs slowly unless the guest requests memory.
“MCTLMAX”: the maximum amount of guest physical memory that the balloon driver can reclaim. Default is 65% of assigned memory.
Resource Allocation Tab:
You can verify the Memory Ballooning stats of each individual VM from VM Resource Allocation Tab. This particular VM  Ballooned value is 5.08 GB
Memory Balloning_2vCenter Performance Charts:
You can generate a custom vCenter performance charts to understand the Memory ballooning stats of all virtual virtual in the ESXi host or individual Virtual machines.
Memory Balloning_3
Memory Balloning_4I hope this post will help you to better understand the concept of Memory Ballooning. Thanks for Reading !!!. Be Social and share it in social media, If you feel worth sharing it.

Comments

Popular posts from this blog

  Issue with Aria Automation Custom form Multi Value Picker and Data Grid https://knowledge.broadcom.com/external/article?articleNumber=345960 Products VMware Aria Suite Issue/Introduction Symptoms: Getting  error " Expected Type String but was Object ", w hen trying to use Complex Types in MultiValue Picker on the Aria for Automation Custom Form. Environment VMware vRealize Automation 8.x Cause This issue has been identified where the problem appears when a single column Multi Value Picker or Data Grid is used. Resolution This is a known issue. There is a workaround.  Workaround: As a workaround, try adding one empty column in the Multivalue picker without filling the options. So we can add one more column without filling the value which will be hidden(there is a button in the designer page that will hide the column). This way the end user will receive the same view.  

57 Tips Every Admin Should Know

Active Directory 1. To quickly list all the groups in your domain, with members, run this command: dsquery group -limit 0 | dsget group -members –expand 2. To find all users whose accounts are set to have a non-expiring password, run this command: dsquery * domainroot -filter “(&(objectcategory=person)(objectclass=user)(lockoutTime=*))” -limit 0 3. To list all the FSMO role holders in your forest, run this command: netdom query fsmo 4. To refresh group policy settings, run this command: gpupdate 5. To check Active Directory replication on a domain controller, run this command: repadmin /replsummary 6. To force replication from a domain controller without having to go through to Active Directory Sites and Services, run this command: repadmin /syncall 7. To see what server authenticated you (or if you logged on with cached credentials) you can run either of these commands: set l echo %logonserver% 8. To see what account you are logged on as, run this command: ...
  The Guardrails of Automation VMware Cloud Foundation (VCF) 9.0 has redefined private cloud automation. With full-stack automation powered by Ansible and orchestrated through vRealize Orchestrator (vRO), and version-controlled deployments driven by GitOps and CI/CD pipelines, teams can build infrastructure faster than ever. But automation without guardrails is a recipe for risk Enter RBAC and policy enforcement. This third and final installment in our automation series focuses on how to secure and govern multi-tenant environments in VCF 9.0 with role-based access control (RBAC) and layered identity management. VCF’s IAM Foundation VCF 9.x integrates tightly with enterprise identity providers, enabling organizations to define and assign roles using existing Active Directory (AD) groups. With its persona-based access model, administrators can enforce strict boundaries across compute, storage, and networking resources: Personas : Global Admin, Tenant Admin, Contributor, Viewer Projec...