Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

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.

share|improve this answer
    
Should hyperthreading be disabled? –  ewwhite Dec 23 '11 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 '11 at 14:31
    
Thanks! This is helpful. –  ddofborg Dec 24 '11 at 10:59
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.