[CentOS] Linux ate my RAM...

Wed Nov 18 21:41:54 UTC 2015
Warren Young <wyml at etr-usa.com>

On Nov 18, 2015, at 1:20 PM, Kwan Lowe <kwan.lowe at gmail.com> wrote:
> 
> Because of caching, from VMWare's perspective, all Linux memory is
> being "used”.

Nope.  VMware’s memory ballooning feature purposely keeps some of the guest’s RAM locked away from the kernel.  This is where RAM comes from when another guest needs more physical RAM than it currently has access to:

  https://blogs.vmware.com/virtualreality/2008/10/memory-overcomm.html

There are downsides.

One is that pages locked up by the balloon driver aren’t being used by Linux’s buffer cache.  But on the other hand, the hypervisor itself fulfills some of that role, which is why rebooting a VM guest is typically much faster than rebooting the same OS on the same bare hardware.

Another, of course, is that oversubscription risks running out of RAM, if all of the guests decide to try and use all the RAM the host told them it gave.  All of the guests end up being forced to deflate their balloons until there is no more balloon memory left.

> The increase in vm density is an acceptable tradeoff.

Instead of oversubscribing the real RAM of the system, consider starting and stopping VMs at need, so that only a subset of them are running at a given time.  That lets you host more VMs underneath a given hypervisor than would run simultaneously, as long as you don’t need too many of the VMs at once.

This patterns works well for a suite of test VMs, since you probably don’t need to test all configurations in parallel.  You might need only one or two of the guests at any given time.

> 1) What options are available in CentOS to limit the page cache?

Again, you should not be tuning the Linux’s virtual memory manager to make the VM host happy.  That’s one of the jobs VMware Tools performs.