[CentOS] Sharing RAM between VM

Tue Apr 14 20:22:23 UTC 2009
nate <centos at linuxpowered.net>

John R Pierce wrote:
> Jim Wildman wrote:
>> 'over commit' of RAM is the phrase you are probably looking for.  And
>> this is one of the limitations of Xen (it doesn't).
>>
>
> perhaps I am being naive here, but I'd guess that a hypervisor which
> allowed such would have to have its own page swapping mechanism, as it
> needs to present each guest OS with the appearance of having whatever
> "physical" memory it thinks it has...   meanwhile, each guest OS has
> *its* own page swapping to implement whatever VM scheme it supports.
>
> since most modern virtual memory systems attempt to maximize their
> memory footprint by treating the bulk of otherwise unused ('free') pages
> as disk cache, I can't help but think this wouldn't work that well
> (having the hypervisor doing swapping on pages that are guest OS
> discardable cache pages just doesn't sound very effective)

VMware's technology is twofold:

- Transparent page sharing - every so often the hypervisor scans for
  identical memory pages and eliminates them, if your running a lot
  of similar VMs you can regain quite a bit of memory, there is
  a minimal amount of overhead and you can control how often the
  page scan occurs(or disable it entirely)

An extreme example:
http://blogs.vmware.com/virtualreality/2008/03/memory-overcomm.html

[..]a screenshot of their environment showing a total of 178
VMs running on the system. You can also see in the screenshot that
less than 20 GB of RAM out of the total 64 GB of RAM is being used
on the system. With a total of 178 VMs configured for 512 MB of RAM
each they are currently allocating 89 GB of memory to running VMs
which means they are oversubscribed on the host.

- Memory ballooning - when the VM host is starved for physical memory
  and the vmware balloon driver is loaded into the guest VMs, the
  hypervisor tells that driver to consume more memory, forcing the
  guest VMs to free up things like buffer cache and if it has to
  go to swap. This process does not occur if you have plenty of
  physical memory available on the host.

Combine both of these with Vmware DRS and a cluster and you can
potentially overcommit a ton of memory depending on your workload.

The hypervisor can swap as well, as there is memory overhead above
and beyond what the guest OS thinks it is using. But of course
any active swapping kills performance.

I think some bleeding edge KVM versions or patches offer these
features, I have never used KVM or Xen myself. Also haven't used
the enterprise versions of vmware, Foundation is good enough for
me for now.

nate