Can a VM perform better when only two cores instead of four cores are presented to it?

Solution 1:

I'll chime in here and say that what your engineer was likely talking about is the fact that a VM with multiple vCPU's has a distinct disadvantage when scheduling CPU cycles. A 1 vCPU VM can execute instructions as soon as a single core is available. If a VM has 4 vCPU's, then it literally cannot execute any instructions until 4 cores are available.

If your box has a decent number of VM's on it, this definitely could slow you down b/c your VM will have to wait in line for 4 cores to free up. It could also slow the other VM's down because it will have all 4 cores tied up at once.

I don't want to get into Hyper-Threading and all that, but above is a simple explanation of what I think your guy might have been referring to. Although he may not have done the best job explaining it.

Solution 2:

Best practice for vSphere per VMWare is to use as few virtual CPU's as possible. If the applications aren't built for SMP applications, it can have a negative impact if you assign multiple vCPU's to the guest.

Even if some vCPUs are not used, configuring virtual machines with them still imposes some small resource requirements on ESX: * Unused vCPUs still consume timer interrupts. * Maintaining a consistent memory view among multiple vCPUs consumes resources. * Some older guest operating systems execute idle loops on unused vCPUs, thereby consuming resources that might otherwise be available for other uses (other virtual machines, the VMkernel, the console, etc.). * The guest scheduler might migrate a single-threaded workload amongst multiple vCPUs, thereby losing cache locality.

It's possible that if the host was maxing out all the physical CPU cycles, it could cause other performance issues since the host starts bogging down which, in turn, causes all the guests to start bogging down.

edit: Your engineer should have at least been willing to test.

on reading your post again, you said that it only had 1 quad core CPU.. if that's the case, I would probably go with your engineer and say that assigning all 4 physical CPU's to one guest is a bad idea. The overhead on the host to manage all 4 vCPU's when there are only 4 physical cores would bring down overall performance.

The problem is that adding 4 vCPU's on the gust when the host only has 4 cores total is you are assigning all your physical CPU resources to one machine. The overhead in having the hypervisor managing all 4 vCPU's will end up taking resources away and your realized gains would most likely be minimal