Author: Fan Jun (Frank Fan) Sina Weibo: @frankfan7
How many vcpu does a virtual machine need? is the number more performance the better? There are many misunderstandings in this area. When allocating CPU resources to a VM, it is prudent to make the most possible use of existing resources to meet the needs of commercial applications. In some cases, setting an excessive number of vcpu for a VM can lead to a decrease in performance. It also causes the whole system to waste resources.
This article from concept to actual combat to explain how to do a good job on the virtual Machine CPU resource planning.
One concept:
First, we define some concepts.
Socket
A CPU socket or a cpupackage refers to a physical the unit of CPU which be plugged into a system board. For example, a 4-way system or a 4-socket system can contain up to four cpupackages
Core
A CPU socket or a cpupackage refers to a physical the unit of CPU which be plugged into a system board. For example, a 4-way system or a 4-socket system can contain up to four cpupackages
Logical Processor:
Hyperthreadingtechnology allows a single physical processor core to behave like two logical. The processor can run two independent applications at the same time. Aprocessor core may have multiple logical processors that share computeresources of the core
Pcpu
A pcpu denotes aphysical CPU, referring to a logical processor in a system with hyper-threading (HT) enabled; Otherwise, it refers to a processor core.
Virtual Sockets and Virtualcore
Set when configuring the VM. The operating system running on the VM reads this setting.
Vcpu
The virtual machine vcpuconfiguration is the sum of number of cores x number of sockets.
For example, a VM has 2 virtual sockets for example, each virtual socket has 2 virtual Core. So the total number of vcpu that this VM is available = num of cores x of sockets = 2 *2 =4
The number of VCPU the VM can set cannot exceed the actual number of logical CPUs on the ESXI host
The following figure shows the relationship between the above terms. The figure is excerpted from Frank Denneman Blog
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/virtualization/
The above figure is divided into three layers, they are the VM layer, Vmkernel layer and physical layer. For a physical server, all CPU resources are allocated to separate operating systems and applications running above. The application sends the request first to the operating system, then the operating system schedules the physical CPU resources.
In a virtualized platform, the Vmkernel layer is added between the VM layer and the physical layer, allowing all VMS to share the physical layer's resources. The application on the VM sends the request to the operating system on the VM, and then manipulates the system to schedule virtual CPU resources (operating system considers the virtual CPU to be the same as the physical CPU), and then vmkernel the layer for resource scheduling on multiple physical CPU core, In order to meet the virtual CPU needs. In virtualized platforms, OS CPU Scheduler and Hyperviisor CPU Scheduler are resource-scheduled in their respective domains.
On NUMA we'll explain it in other language.