My Query >>Currently, both of my VMs are configured to use 2 VCPU. It seems, their applications are CPU-intensive hence, for CPU intensive application if we increase VCPs from 2 to 4 since host is already using 8 physical processors then it would be good option to increase the throughput.
Ans. from one of my team mate>>> Increasing the number of vCPUs can create performance problems if the applications running on the VM do not explicitly use multiple processors. We need to be absolutely certain what ever is seen to be causing the performance issues on this VM are designed to explicitly use multiple processors. This is the reason we need to build all VMs initially with a single vCPU and increase beyond that only when the application supports it.
Could you guys please give your openion on this please I need this badly to fix on performance issue.
Hope this information help you.
If you use more VCPUs than physical CPUs ,VM cut the CPU worktime in timeslots. I think a timeslot is 20ms.
When a VM Guest is configured with 4VCPUs and the Software uses only 1CPU at the same time VM blocks 4 physical CPUs for 20ms.
So other guest can´t use this blocked CPUs and have to wait for the next time cycle.
8 physical CPUs 1 Guest with 4VCPUs 3 Guest with 2 VCPUs
Time 0 to 20ms > guest 1 works with 4 VCPUs, guest 2 and 3 works with 2 VCPUs and guest 4 must wait!
time 21 to 40ms > guest4 works with 2VCPUs ,Guest 1 with 4VCPUs , guest 2 with 2VCPus and guest 3 must wait!
time 41 to 60ms Y guest (3 and 4) with 2 VCPUs and Guest 1 with 4 VCPUs. Guest 2 must wait!
!!!! time 61 to 80ms Guest (2 and 3 and 4) work with 2VCPUs and Guest 1 must wait because there are not enough physical CPUs free!!!!
So you lose 25% of physical power.
Hope this will help
Your team mate is correct. When you assign 4 vCPUs to a vm it will only be able to access CPU cycles when 4 cores are available - this is called CPU scheduling. The problem comes when ESX has requests for CPU cycles from multiple vm's at the same time - say 1 vm with 4vCPUs, 4 vm's with 1 vCPU and something neded to be done by the service console (needs a core). This means that 9 cores need to be available at the same time for the execution or instructions to be done, now if your box has 2 x quad core CPUs = 8 cores, your 1 core out and ESX will have to schedule time/cycles on the available cores for the vm's - this is called CPU contention = not good
Thank you very much for your wonderful explanation!
You are right, VMkernal moves vCPUs from one core to other for the purpose of load balancing and the time you mentioned is 20 ms.
I would like to ask you do you have any doc. from VMware to support this saying the reason being I have to show this to our client and soem doc. is required to convience them.