VMware Cloud Community
jacobshorr
Contributor
Contributor

VM's with lots of unused guest memory - options/best practices for saving RAM

Hello,

I have the basics of vSphere down but will be the first to admit I don't understand much about the resource management.  Haven't had to deal with resource constaints too much up until now.  I will be doing some reading over the weekend, but in the meantime if anyone can point me in the right direction that would be great.

I have a DEV/QA esxi cluster with the standard licensing (no resource pools.)  There are a number of VM's allocated with 8GB of memory.  When you look at the host VM list you see that most of them have very low guest mem %.  There are enough of these 8GB VM's that I am running out of memory on the hosts.

I know that based on the low guest mem % I could probably go back to the VM's and lower the memory allocation to 4GB or less.  But let's say that I don't want to do that, and that I still want the VM to have the ability to use up to 8GB if it should need to at some point.  But at the same time, I want to keep adding more VM's and not run out of memory.  I've experimented with changing the resource settings on a few VM's and putting a 4GB limit....the host memory drops to 4GB, and the Baloon goes up to 4GB.  What did this actually accomplish?

I know I need to read through the resource planning guide but if someone understands what I'm trying to accomplish please let me know how I should be approaching this.  Thanks.

0 Kudos
7 Replies
mcowger
Immortal
Immortal

By setting a 4GB limit on an 8GB VMs, you force it to never use more than 4 GB of real, physical memory, and the rest gets swapped out.

What have you accomplished?  Reduced performance.

--Matt VCDX #52 blog.cowger.us
jacobshorr
Contributor
Contributor

Thanks for replying. If 4gb is still allocated and the active guest memory remains low, does that mean it wont wind up having to swap unless active memory goes over 4gb? I thought ballooning allowed esxi to borrow memory from vms that aren't using it.

What would you recommend in this situation, other than adding RAM or lowering the OS allocated memory?

0 Kudos
a_p_
Leadership
Leadership

I thought ballooning allowed esxi to borrow memory from vms that aren't using it.

This is correct. With ballooning enabled in the guest, ESXi can borrow already allocated but currently unused memory from a VM.

What would you recommend in this situation, other than adding RAM or lowering the OS allocated memory?

Don't change anything. Why would you want to deal with limits or any other settings if the VM's don't usually need that memory anyway. Let ESXi take care of the memory allocation. If the VM's need more memory than the physical RAM, ESXi will start its memory saving features like TPS, memory compression, ... and as a last resort start swapping.

With setting limits or lowering the RAM allocation for individual VM's, you would actually force swapping for these VMs even if there was enough host memory available.

André

0 Kudos
saurabhbhattach
Enthusiast
Enthusiast

Hi,

I personally am not a big fan of putting Limits, I would rather go ahead with Reservations and Shares. For your most critical VMs use High Share values and for non critical VMs you may go ahead with Low share values.

0 Kudos
jacobshorr
Contributor
Contributor

Thanks for your reply.  So, what should I do about the Host Memory warning messages?  Why is ESXi warning me about running out of memory if it has so much unused Guest memory out there it can tap into?  Sort of along these same lines, when ESXi calculates HA requirements does it look only at the physical memory being used or also at the unused guest memory that's out there?

0 Kudos
RanjnaAggarwal
VMware Employee
VMware Employee

First of all few things you should know:-

1. VM only use the RAM of the host when it is powered on and release it when it is off.

2. Ballooning is use to take the RAM from one VM and Provide it to another VM. Like if u have 2 vm's vm1 with 2GB Reservation and vm2 is with suppose 512MB reservation. Currently VM1 is only using 1gb from its reservation in that case vmkernel can provide that remaining 1gb of vm1 reservation to vm2 but not to satisfy the vm2 reservation if vm2 needs more than its reservation then only they will provide that 1gb to this vm to satisfy that area that is above the reservation and this is only used when host memory is overallocated.

3. Limit = Limit means vm can use up to that physical ram after that they can use only .vswp means if vm is configured with 8gb ram and 6gb is the limit so that 6gb can come from .vswp as well as from physical ram or via balloning but remaining 2gb is only from .vswp.

4. if your vm application needs 8 gb ram and you allocated only 4gb of ram then vm is forced to use guest level swapping (Pagefile.sys in windows).

So in your case you can allocate 8GB to vm's and use limit on your vm so that it can use only up to that much physical ram after that it will use .vswp

Hope this answered your query

Regards, Ranjna Aggarwal
0 Kudos
rickardnobel
Champion
Champion

Limit = Limit means vm can use up to that physical ram after that they can use only .vswp

means if vm is configured with 8gb ram and 6gb is the limit so that 6gb can come from .vswp as well as from physical ram or via balloning but remaining 2gb is only from .vswp.

The "limit" does not really force to vmkernel vswap, it could be both compression and ballooning that will take the remaining memory away. The limit could be seen as a forbid to use a certain amount of real physical memory, but does not matter how this is done by the vmkernel.

jacobshorr wrote:

I know that based on the low guest mem % I could probably go back to the VM's and lower the memory allocation to 4GB or less.

The Memory % is just the "active" memory, which is a sample of recently touched RAM from the VM, but the VM could actually both use and need lots of more then the active. You would really have to look inside the VM to see how much memory it is using.

My VMware blog: www.rickardnobel.se
0 Kudos