7

I have a new 8 core machine with 16GB of RAM. I want to run VMs on it using Ubuntu and KVM. Nothing else but SSH will be running on the host.

My question is what is the maximum amount of cores and of RAM which I can use for the VMs. Can I create 4 VMs and assign 2 cores and 4GB RAM each? Will the host OS have problems with such setup?

Stated in other way, what is the minimum amount of cores and RAM which is needed for the host to run the VMs? Will 1 core and 1GB of RAM be enough to run the VMs.

3 Answers 3

5

there is no maximum as such, same as there is no real maximum for memory. You need to keep in mind the following:

  • A KVM v-CPU to a host is just a thread in the KVM process. If you run more threads than you have physical cores, they will be competing for those cores, and the host scheduler will have to take care of giving them CPU time
  • Avoid allocating more v-CPUs to a single VM that you have physical cores in a host.
  • Do not count HT cores as real cores.
  • If possible, do not allocate more v-CPUs to all of the VMs you are running than you have physical cores, if CPU time on the VMs is critical. However, on less busy systems, you can easily overallocate up to some really insane ratios (I've seen a system with 8 cores running 150 mostly idle VMs with 2 cores each with no problems)

As for the RAM allocation, this is basically the same line of thought:

  • a VM is just another process to the host, and the process will have a memory limit it can use
  • If you try to use more RAM that you actually have, you will end up in swap, which is dead slow compared to RAM
  • KVM provides ways to overallocate memory - there's balooning and KSM for that.

So, having said that, you need to consider what your VMs will absolutely require (don't just give a VM 4 cores because you can, give it the minimum it needs to run, and add more later if you see performance issues).
Be careful with memory allocation - you never want to end up in swap.

2
  • 1
    Should hyperthreading be disabled?
    – ewwhite
    Dec 23, 2011 at 14:29
  • I don't think so, but this topic is not always agreed upon. Just test your specific VM loads with and without HT and see what works best for you
    – dyasny
    Dec 23, 2011 at 14:31
0

The overhead of host system is something near few hundreds MB, you can check it immediately at boot with the free command.

In any case, it's a good thing to leave some free memory to be used for I/O buffers. If you run similar VM, take a look to KSM to optimize memory usage.

0

In addition to the considerations that @dyasny has addressed, you need to also consider how many sockets are there in your host.

If you have a 2-socket 4-core setup then you don't want to allocate too many cores per VM as your performance may suffer if the VM needs to communicate across main memory.

I have previously experienced this issue before but YMMV. Test your setup.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .