Mac – What are the limits of allocating the CPU cores to VMs

cpuvirtual machinevirtualizationvmware

At least in VMware when creating or tweaking the settings of a VM I choose how many CPU cores I let the VM use. This question came to mind when thinking about at some point potentially running multiple VMs at once. Is there a limit to how many VMs I can run based off of how many CPU cores are allocated to other VMs or my main system? For example I have 6 cores, would I only be able to run 5 VMs; each one using 5 cores leaving one for my system? Or can I run more than 5 VMs and they'll just share cores at an obvious cost to performance?

Best Answer

If you're using vSphere (which I assume you are as you tagged vmware, when you allocate 1 CPU core you're allocating 1 vCPU core. The CPU does not bind to a physical CPU core (pCPU).

For vSphere 6.0, there is a maximum of 32 vCPUs per physical core, and vSphere administrators can allocate up to 4,096 vCPUs to virtual machines on a single host, although the actual achievable number of vCPUs per core depends on the workload and specifics of the hardware.

For every workload beyond a 1:1 vCPU to pCPU ratio to get processor time, the vSphere hypervisor must invoke processor scheduling to distribute processor time to virtual machines that need it. Therefore, if the vSphere administrator has created a 5:1 vCPU to pCPU ratio, each processor is supporting five vCPUs. The higher the ratio becomes, the higher the performance impact will be, because you have to account for the length of time that a virtual machine has to wait for physical processors to become available. The metric that is by far the most useful when looking at CPU oversubscription, and when determining how long virtual machines have to wait for processor time, is CPU Ready.

The vCPU-to-pCPU ratio to aim to achieve in your design depends upon the application you are virtualizing. In the absence of any empirical data, which is generally the case on a heterogeneous cloud platform, it is a good practice, through the use of templates and blueprints, to encourage your service consumers to start with a single vCPU and scale out when it is necessary. While multiple vCPUs are great for workloads that support parallelization, this is counterproductive in the case for applications that do not have built in multi-threaded structures. Therefore, while a virtual machine with 4 vCPUs will require the hypervisor to wait for 4 pCPUs to become available, on a particularly busy ESXi host with other virtual machines, this could take significantly longer than if the VM in question only had a single vCPU. This performance impact is further extended as the vSphere ESXi scheduling mechanism prefers to use the same vCPU-to-pCPU mapping to boost performance through CPU caching on the socket.

https://www.vmware.com/pdf/Perf_Best_Practices_vSphere5.5.pdf

You can also search for 'virtual machine cpu overcommit' for more results.

Related Question