Is the # of CPUs on a virtual machine always meaningful?

Solution 1:

It very much depends on the virtualisation solution being used. If you have multiple CPUs showing in VMWare then you have multiple vCPUs assigned to your VM in which case it is probably best to arrange your server processes in a similar way that you would a pair of real cores (with the caveat that due to the way vCPUs and real cores are scheduled sometimes you are better off not giving VMs more than one vCPU via VMWare if you have a relatively heavily loaded host. Other similar solutions probably work the same way, but some (especially those that are really partitioning one kernel rather than providing VMs often report the host's full capabilities even though your partition is, for example, effectively locked to one core.

Solution 2:

It depends on the Hypervisor. If the Hypervisor is simluating 4 processors in 1 thread on the physical processor then your VM is better off treating it like 1 CPU. If the Hypervisor is passing through 4 physical cores to your VM, then you're best off using them.