VMware Cloud Community
rezajoon2500
Contributor
Contributor

How to force VMware ESXi to reclaim memory (manually with script)

Scenario

We have a VMware ESXi Server with 512GB RAM and we have 25 VMs with 64GB RAM with "0GB" reservation memory for VMs. They don't use all of their resources but we need to do this because they use all of their memory(64GB) once a day. When they do this ESXi gives VM 64GB and tries to reserve it for VM. I know ESXi is managing memory by ballooning and other ways but it shows used memory in the "Host Mem" section of VM 64GB.

  • Total Server Mem: 512GB
  • Total Guest Mem: 5%
  • Total Host Mem: 470GB

ProblemWe want to say ESXi if a VM didn't use memory for 10Min reclaim all reserved memory(Host Mem parameter). with powercli, VMtools, Linux script, a config and etc.

  • VM Memory Size: 64GB
  • VM Guest MEm: 1%
  • VM Host Mem: 52GB (we want to reclaim this memory)

I know

I know about ballooning but we need to reclaim memory manually if possible. Or force ESXi to reclaim unused memory very fast.

8 Replies
vMarkusK1985
Expert
Expert

What's the reason for reclaim memory manually?

If the ESXi hosts get into memory contention (more precisely, much earlier) the hosts start reclaiming (page sharing, ballooning, compression, etc.) memory automatically.

https://mycloudrevolution.com | https://twitter.com/vMarkus_K | https://github.com/vMarkusK
rezajoon2500
Contributor
Contributor

Thank you ,

Our development team states that VMs are very slow some times and it is because of "Host mem" usage parameter and we need to find the problem to fix it.

  • What do you think where is the problem and how we can find it?
  • And is there a way to reclaim memory with command if not is there a way to optimize memory sharing .e.g a config for reclaiming faster or do " (page sharing, ballooning, compression, etc.)" with faster triggers?  what is your suggestion?
Reply
0 Kudos
vMarkusK1985
Expert
Expert

Do you already have active ballooning, compression and swapping on your VMs?

I would not be surprised. The numbers you mentioned show a hight memory overcomitment.

Are you able to add more hosts to the cluster?

https://mycloudrevolution.com | https://twitter.com/vMarkus_K | https://github.com/vMarkusK
larstr
Champion
Champion

This?

pastedImage_0.png

berndweyand
Expert
Expert

there ist no substitute for memory except to add more memory.

if the vm´s don´t fit into the host memory you have the risk of performance issues. don´t allow the host to do other memory optimizations than tpm or compression. ballooning or swapping is always an indicator of insufficient memory

berndweyand
Expert
Expert

a typo - i mean tps

rezajoon2500
Contributor
Contributor

Yes I checked hosts and ballooning, compression are enabled and also I checked some of VMs had done ballooning and compression. Swapping is enabled and it makes .vswp files beside VM files.

Yes we have so many VMs. Is there formula or best practice to calculate memory overcomitment or it's experimental?

We have already some other hosts and I will try to convence CTO to do this Smiley Happy If i can find the exact problem point!

Reply
0 Kudos
vMarkusK1985
Expert
Expert

Does Ballooning, Compression, and Swapping happen for your VMs (the .vswp file exists per default when no memory reservation is done)? You can check the Memory Performance Metrics of the Host or the VMs get a good insight.

If one of these Memory saving methods (especial Compression and Swapping) hits your VMs you can be sure there is too much memory overcommitment. With the current server sizings and memory prices, in most ent. environment memory overcommitment is not usual (or only on a small scale).

You already have the exact problem point, your developers are not happy. For exact numbers check the Memory Performance for Ballooning, Compression, and Swapping of the VMs.

https://mycloudrevolution.com | https://twitter.com/vMarkus_K | https://github.com/vMarkusK