Virtual memory in virtualized machines (Swap File in VM?)

memorypagefilevirtualization

What are the opinions on allowing virtual memory inside a virtual machine?

For example, a host machine w/8 Gig of memory, I could run 4 VMs each w/2 Gig (roughly) and there would be no host swapping. However, in each VM I could have a 2Gig page file so the virtual server had 4Gig of usable memory, 2 physical 2 virtual.

OR… I could give each VM 4 Gig of "memory" and have the host use 8Gig of real memory and 8G of virtual memory and have no page file in each VM. Each VM would still have "4Gig" but the paging would occur on the host.

The warm-fuzzy part of me says setup paging in each guest like you would a real server and you're good. But the analytical side of me sees two major advantages to overcommitting the host memory and having no paging in the VM. First, the IO for the virtual memory is then handled by the host OS, which is closer to the bare metal, so it should be quicker. And second, paging would only be required if the host didn't have the memory available. If the guest wanted 4Gig, but other guests weren't using their memory then no paging would be required.

Thoughts?

Best Answer

I'm not a virtualization expert (in fact I think it's the wrong tool for the job most times), but from what I have read your guest OS's should not be allowed to swap. The primary reason for preventing swapping is it represents a way for one guess OS to hog a large portion of th e host's IO bandwidth.

Also, you don't want to pretend to your guess OS's that the host has more physical memory than it has as it will cause the host to swap heavily, but debugging performance issues inside the guess OS's will be very hard, because from their point of view they are not swapping, and none of the os level tools in the guest will show it.

It may even be with tools like Xen and VmWare you cannot overcommit memory on the host OS because of the use of baloon memory drivers.