This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-users] how many VCPUs per physical CPU?

Peter Peltonen <peter.peltonen@xxxxxxxxx> writes:
> In what kind of cirumstances does a domU perform better with a 4 VCPUs
> than with 1 VCPU?

It is a best case/worst case tradeoff.   say I have 30 guests on one of my
32GiB ram/8 core boxes;   Obviously, I dedicate one core to the Dom0, and
set cpus=1-7  for the rest so nobody else can touch the dom0 core. 
But for the guests, should I give them each 1 vcpu?  4vcpus?  6 vcpus?

first, if only one guest is running, if it only has one vcpu, it can only
use one physical cpu, so I'm wasting 6 cores (I'm using one in the dom0, 
remember?)   -  if I gave everyone 4 vcpus, that one domain could use
4 CPUs, getting more power.   so if I only give 1 vcpu to each guest, best
case performance is limited.  

However,  if I have vcpus=4 in all guests, one guest is using all 4 vcpus
and all the sudden another guest wants to use all 4 vcpus, they have to share.
(well, at this point they only have to share 1 vcpu.   Now, I've read that
this can cause scheduling problems, e.g., if one vcpu is more available than
another, thus the vmware guys going on about 'gang scheduling'.)   even 
leaving the 'gang scheduling' to the smart people, if you have more vcpus 
that want to run at a given moment than physical cpus, it seems pretty 
obvious to even the most simple-minded janitor that you are going to be
doing more context switching, and context switching is expensive.  

if you accept that the more vcpus each DomU has, the more context switching 
is going to happen, it follows that worst-case performance gets worse as 
the number of vcpus in each domain goes up.

now, optimizing for best case vs worst case is a business decision.  
Me, I give each customer 1 vcpu, because I think it's easier to adjust to 
being not so awesome in the best case than it is to adjust to total suckage
in the worst case.  (that, and I know I have some customers who load their VPS 
to the max.)

On the other hand, I have lost one customer I know about (meaning I have lost
several orders of magnitude more that I don't know about) because I get 
absolutely slaughtered in unixbench type synthetic cpu benchmarks because 
of this (though I tend to do okay in real-world application benchmarks)
and to be clear, looking at xentop, I usually don't have more than 3 or 4 
domains running, so it would probably be ok for me to set vcpus to 2  (maybe 
I will do so for the larger domains)  

Xen-users mailing list

<Prev in Thread] Current Thread [Next in Thread>