TL;DR;

What is the best practice for overcommiting memory with libvirt and kvm ?

Long story -

I have a small and underutilized server running multiple VMs (both host and guest running centos 7.4) most of the VMs are not critical and are mostly used for testing. a couple VMs are more important than the other ones and should have the option to utilze almost the whole memory of the server if they are being heavily used.

I started with just giving every VM the maximum memory it might ever need, but that just used all the server RAM and most of it's SWAP and on top of it had ksmd running like crazy even though all VMs together aren't using even 30% of the server RAM.

I than tried naively setting up currentMemory to be about 1/4 of the maximum memory for all VMs. But it doesn't seem like the available memory to the guest increase as more memory is being used and once the guest uses all of the available currentMemory it will start to fail.

I than tried to use MOM from the oVirt project which can work with libvirt but information online is quite old (~2011) and though the project seem to be maintained I found the documentation to be incomplete and initial setup difficult and buggy.

After getting everything to run and looking at the balloon.rules policy code it seem like though it can work for my use case the default policy is probably too basic and I will need to write a policy that will better support my use case which seem cumbersome especially when documentation is lacking.

So I'm hopping there is a better solution or approach I might be missing

  • 1
    Are you making sure to install the guest agent in your VMs, a baloon driver, and a virtio serial channel for guest to host communication? Without those things, ballooning won't work. – Spooler Mar 6 at 3:49
  • I'm pretty sure everything is installed correctly. Drivers should be included with Centos 7 and I do get balloning to work as it initially reduces the VM memory but memory never increases after that. MOM seem to work automatically changing guest memory but I'm not sure if that is actually the best option – Yoni Jah Mar 6 at 4:46
  • You should first determine how much memory each VM actually needs, without regard to other VMs. If you have less memory than this total, buy more. Best practice is to not overcommit. Virtualization can help you use your resources more efficiently, but it can't give you something for nothing. – Michael Hampton Mar 6 at 21:55
  • @MichaelHampton not sure I understand what you mean overcommitting is an important feature of virtualization. if you have 5 VMs using 5% of resources on normal load but an hour a month it might need 70% of the resources it make sense to allocate the resources dynamically as needed. if I understand your answer correctly you saying since the max use of each VM is 70% and that's 350% of your resources you'll buy 3.5 times the RAM ? for something your server is 99.9% of the time will handle with no issue even on max use ? I can't see the point in that. – Yoni Jah Mar 16 at 1:12
  • Any way if it is not clear from the question server is underutilized. So currently on max use it never goes more than 30% of resources but I want a very specific VM to be able to use all available RAM even if there will be twice as much RAM I still want it to be able to use most of it. – Yoni Jah Mar 16 at 1:16

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.