By Rob Rech

A common problem that I run into with virtual environments is when a VM is created; the administrator starts the VM off with more than 1 vCPU. The justification behind this is that they often say that a physical machine would have more than one CPU so shouldn’t VM as well? A common misconception is that applying more than 1 vCPU to a VM results in greater performance for the VM.

The truth is, starting VM’s with more than 1 vCPU can lead to performance problems for the environment as a whole as the number of VM’s increases.

To illustrate the point, two VM’s were assigned 8 vCPU’s each. The first VM started a stress test against all 8 vCPU’s. 1 minute later, the second VM started the stress test against all 8 vCPU’s while the first was still running. The results indicated that when the second VM started the test the Co-stop time in ms went from ~30 to ~1000. The Ready time went from ~25 to ~10,000.

VM Stress Test Graph

VM Stress Test Table

The black bar in the graph indicates when the second VM started the stress test. As you can see, when the second VM started the stress test, the performance of the first VM dropped significantly. The reason why the performance dropped was because the host was unable to schedule the vCPU’s to the VM’s due to the number of vCPU’s in each VM.

The CO-STOP (%CSTP in esxtop) value indicates the amount of time that the VM was ready but was forced to wait due to vCPU scheduling contention. The Ready (%RDY in esxtop) value indicates the amount of time in ms that the VM must wait in a ready to run state before it can be scheduled to a physical (or hyper threaded) CPU core. For both metrics, the vSphere client shows it as milliseconds and esxtop shows the value as a percentage.

As a general rule, when creating a VM I size it according to what the capabilities of the application are (is it multithreaded) and what the expected load is going to be. If the application is unithreaded then I only assign one vCPU. If the application is multithreaded and the load is expected to be low then I still start it with one vCPU and monitor the performance. The only time I start a VM with 2 or more vCPU’s is when the application is multithreaded and the expected load is high. I then monitor the performance of the VM and application and adjust the number of vCPU’s accordingly.

For more information on co-vCPU scheduling: