Thursday, 24 January 2013

ESXi Host Memory Swapping and Balloon not deflating - Solved

I came across an interesting problem where hypervisor's memory was ballooning although there wasn't a memory contention on the host. 


Problem:

Host has 32GB of RAM and provisioned RAM is 20GB, there was absolutely no reason for Memory swapping or Ballooning but when I did SSH and esxtop then 'm' for memory, you can see in the screenshot memory swapping is taking place:




This was confirmed from the VIClient Performance tab as well where 1.5GB  of hypervisor's memory was in used by Baloon drivers.
I've also added screenshot from VKernel vOPS







After going back to basis and checking esxtop again, I found that although MEMSZ  is 2048MB the GRANT memory is 449.11MB this tells me something is wrong with resource allocation.
On checking VM Properties, strangely there is a limit of 512MB on the memory  resources which is not visible in Summary and you can also see from the screenshot memory limit bar wasn't moved or adjusted to 512MB.







You can also run following command (change the VMNAME) to identify the memory size and maximum memory size

egrep "memsize|sched.mem.max" /vmfs/volumes/*/*/VMNAME.vmx | awk -F/ '{print $6}' | more




Solution:


If sched.mem.max is smaller than memsize, the balloon driver can start consuming memory (especially if the guest operating system application has periodic bursts of memory usage). However, this setting can cause the balloon driver to retain its hold on memory. If the guest operating system requires memory that is made unavailable by the balloon driver, the guest operating system starts using swap memory instead, which slows it down considerably.



To force the balloon driver to release its hold on memory and prevent the guest operating system from using swap space, use one of these options:

  • Set the value of sched.mem.max to the allocated memory or greater.
  • Select the virtual machine's Resources > Memory > Limit > Unlimited box.
  • Migrate the virtual machine to another host.







After completing the VMotion check the performace monitor and see memory release from the Balloon drivers and difference in VM performance and VM memory chart.










Possible Cause:


Migrating a virtual machine from ESX 2.x to 3.x or 4.x may cause a carry-over of memory reservation that is smaller than the virtual machine's allocated memory (likely a customer-specific setting).


No comments:

Post a Comment