[CentOS-virt] what scheduling algorithm does KVM use?

Thu Nov 18 23:45:00 UTC 2010
Kenni Lund <kenni at kelu.dk>

2010/11/19 Nick <oinksocket at letterboxes.org>:
> 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.  [1]

As long as you keep the number of CPUs for *each* VM - equal to or
lower than - the number of physical cores, your performance should not
suffer with KVM. If you assign more CPUs to one VM than you have
available cores (a core can also be a hyperthreaded core), you will
for sure run into performance problems.

> 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",

The good thing about KVM compared to other virtualization solutions,
is that KVM doesn't try to reinvent the wheel. It leaves scheduling to
the Linux kernel, so whatever your Linux system is setup to use, KVM
will use that. You can choose to run CFS (Completely Fair Scheduler),
deadline, BFS, or whatever scheduler you prefer. As long as Linux uses
it, KVM will use it.

> 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.)

If you want a really competent answer to your question, send it to the
kvm-devel list...they don't mind user questions like this, and as long
as you're asking a relevant question, there's a good chance of getting
a highly competent answer :)

Best regards