How does the vCPU align with the CPU? (VM with more cores than the CPU has)

central-processing-unitvcpuvmware-vsphere

I have a VM running on vSphere 6.5.which has 24 vCPU's.
The server has two physical cpu's (xeon e5-2699 v4) which have 22 cores and hyperthreading is enabled.

How exactly are the vcpu's running on the physical cpu's? Would it be better to reduce the vcpu's to 22 that it could run on one phyical cpu or would vSphere even use in this case multiple pysical cpu's?

Best Answer

A single VM must never have more virtual CPUs than logical physical cores that are available.

With Hyperthreading enabled you are at 44 logical physical cores, so this should be fine. However, this heavily depends on how many more VMs are running on that host. One thing you have to keep in mind is how the CPU scheduler of the ESXi server works. For every CPU cycle it always waits until there is a physical core available for each virtual CPU on a VM. So, in your case, it will always wait until 22 physical cores are available before a CPU cycle can be processed. If you have many more VMs on that host that can lead to a high CPU ready time and a very slow VM.

Personally, I always try to keep the number of vCPUs at 8 or less. If you can, rather scale your VMs out than up.

Another consideration: With the current state of mitigations against Spectre and Meltdown attacks it is generally recommended to disable Hyperthreading, because this reduces the possible attack vectors. If you decide to disable Hyperthreading your configuration will most probably not be usable anymore.