How to calculate vCPU to CPU | Explanations and Examples
You may be asked to specify the number of vCPU when creating a VM. Do you know what is it, and how to calculate CPU to vCPU? Here I will explain it in this article.
What is vCPU
vCPU refers to virtual central processing unit, or virtual processor, which is a portion or share of the underlying physical CPU that is assigned to a particular virtual machine (VM). In most cases, it is not a one-to-one allocation.
So, you may be wondering how to calculate vCPU to CPU or CPU to vCPU. I will explain it in this article. But before that, let’s review some related terms.
What is CPU
A (physical) CPU is the electronic circuitry that executes basic arithmetic, logic, controlling, and input/output (I/O) operations specified by the instructions in the computer program.
Most modern CPUs are implemented on integrated circuit (IC) microprocessors, with one or more CPUs on a single IC chip. Microprocessor chips with multiple CPUs are called multi-core processors. The individual physical CPUs, processor cores, can also be multithreaded to create vCPUs.
What is Core
A (physical) Core is the CPU’s processor. Unlike the past when there was only one core per processor, modern CPUs tend to have multiple cores, each of which can work on a different task. To put it simply, the more cores a CPU has, the more efficient it is.
Logical Core: As physical CPUs and physical cores are actual hardware components, logical core is a concept. To make more efficient use of the physical core, Hyper-Threading technology on Intel CPUs (or Simultaneous Multi-Threading on AMD CPUs) splits a physical core into virtual cores.
The Logical cores are calculated by the number of Physical cores times the number of threads that can run on each core. For example, if your CPU has 2 physical cores, and can run 2 threads per core, then you have 4 logical cores.
VMware vCPU vs Core: Many users have questions such as 1 vCPU how many cores. In face, it is generally assumed that 1 vCPU = 1 physical CPU core. But this is not entirely correct, as the vCPU is made up of the timeslots of all available physical cores, so in general 1 vCPU is actually more powerful than a single core.
What is Thread
A thread is a small sequence of programmed instructions that divide the physical core into multiple virtual cores to allow multitasking on computer. A physical core usually has 2 threads.
How does a vCPU work
The number of a VM’s vCPUs represents the maximum number of threads that the VM can run at any given moment.
When using a hypervisor to create VMs, you will be asked to specify the number of vCPUs for the VM. And the number of vCPUs assigned to a VM cannot exceed the number of logical cores in the host.
The Hypervisor allocates a portion of the physical CPU computing resources to the vCPU of a specific VM. Each vCPU is seen as s single physical CPU core by the VM’s operating system.
How to calculate vCPU to CPU
As I mentioned, the ratio of CPU to vCPU is generally not 1: 1. In fact, how many vCPU a host can assign is determined by the manufacturer. It’s calculated by taking the number of processing threads that a chipset offers per core and multiplying the number of occupied sockets:
(Threads x Cores) x Physical CPU = Number vCPU
For example, A 8 cores/ 16 threads CPU has (16 Threads x 8 Cores) x 1 CPU = 128 vCPUs
However, one of the major advantages of vSphere virtualization is the ability to oversubscribe. 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.
However, the actual achievable number of vCPUs per core depends on the workload and specifics of the hardware. Things like CPU exhaustion can degrade the VM performance, so there is a limit to the number of vCPU that can be allocated to a VM.
The recommended ratio of vCPU to CPU ranges from 1:1 to 3:1. With 3:1 to 5:1, you might begin to see a performance degradation, 6:1 or greater is often going to cause a significant problem for VM performance.
You may be confused when you are asked to specify the number of vCPUs of a VM. To calculate the ratio of vCPU to CPU, first you need to understand what are vCPU, CPU, physical cores, logical cores, and thread.
In this article, I introduced what are them and how to calculate the ratio of CPU to vCPU. However, to avoid VM performance degradation, there is a limit to the vCPU numbers that recommend to allocated to a VM.