[CentOS-virt] what scheduling algorithm does KVM use?
oinksocket at letterboxes.org
Thu Nov 18 18:10:00 EST 2010
This may not be the best place to ask, but I was prompted by a question about
guest cores on KVM.
We currently use VMWare Server (v1.0) on CentOS5.
It supports up to two virtual CPUs, but not very well, as I understand it.
VMWare Server 2.0 might do better at supporting the same maximum of 2 CPUs, but
if my research is correct, they both use what is called "strict co-scheduling".
Which means, if a two virtual-CPU VM is waiting for a time slice on the
physical host, there needs to be two physical CPUs available to be allocated.
This is because amount of time scheduled to each virtual CPU has to stay equal,
else assumptions in the virtualised software may become false and things start
The problem with this is that it is obviously more of a constraint to have two
physical CPUs available. Therefore adding virtual CPUs to a co-scheduled VM can
actually make performance worse if the physical CPUs are under any sort of
contention. Performance degrades rapidly under load - which is exactly what you
don't want for a webserver. Therefore advice seems to be to avoid using
multi-virtual CPU VMs. 
VMWare ESX uses something supposedly better, called relaxed co-scheduling. .
We're not likely to use that any time soon, since we are using 1&1 root servers
I did try and research the algorithm(s) used by KVM. Apparently it doesn't use
co-scheduling, but possibly something called the "completely fair scheduler",
but I'm no an expert in VM scheduling and I didn't manage to discover what this
means, nor specifically what the implications are for performance were in terms
of scaling up the number of virtual CPUs on KVM. (I understand that the number
of virtual CPUs supported by KVM is be quite high.)
Anyway, I've been asked how to scale a VM up utilise more - say four or more -
physical CPUs. Is KVM better at this than VMware Server, or does the same basic
> "The SMP
> scheduling algorithms used by ESX server and by Xen
> have a low overhead for single-threaded compute inten-
> sive workloads. However, they do not scale as well for
> multi-threaded workloads on a system with overcommit-
> ted CPU resources."
More information about the CentOS-virt