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.