Summary of the relationship between physical CPU and VCPU

http://support.huawei.com/ecommunity/bbs/10258020.html

 

Background note:
In projects and training, many questions have been asked about the correspondence or allocation between FusionSphere physical CPUs and vCPUs, how many vCPUs can be virtualized from a physical CPU, and what is the main frequency of a vCPU. What happens when CPU reservations, shares, and limits are set.
After reading some of the previous discussions, there is no conclusion. Based on the fact that practice is the only standard for testing and sorting, this article uses experiments and related documents to sort out these issues, hoping to give everyone a clearer understanding.

1. Calculate the total number of VCPUs available to the system

Server CPU information:
1 R2288H V3, 2 CPUs, 10 cores, hyperthreading is 2. A total of 2x10x2 = 40 threads, each 2.3GHz.
Haswell EP CPU 02311CDJ BC1M12CPU X86 series, 2300**z, 1.8V, 64bit, 105000mW, Haswell EP Xeon E5-2650 v3, 10Core, with heatsink 2 2
Check the CPU information on the  

Intel official website and see the E5-2650 on the BMC management interface of the server information


http://ark.intel.com/products/81705/Intel-Xeon-Processor-E5-2650-v3-25M-Cache-2_30-GHz
Deploy FusionCompute R5C00 on the host, log in to the CNA host and run the xentop command to view CPU information
CPUs :40 @ 2294 **z, clocked for a total capacity of 40 x 2.294 GHz = 91.76 GHz.
Domain 0 is configured with 2 VCPUs by default, occupying 2 x 2.294 = 4.588 GHz
. The total frequency available to users = 91.76 - 4.588 = 87.172 GHz

. Check the CPU information on the FC portal. The total capacity of 87.17 GHz is exactly equal to the total system capacity minus the occupation of Domain 0. capacity.


Conclusion 1: The total number of vCPUs available in the system (logical processors) = the number of sockets (the number of CPUs) x the number of cores (cores) x the number of threads (hyperthreads)
1 VCPU = 1 hyperthread Thread. As shown below:



CPU QoS
As shown in the figure, the reserved CPU capacity is 4.59GHz, and the available capacity is 82.58GHz, indicating that the VCPU frequency except the reserved capacity of 2 VCPUs of VRM01 is 4588**z. There are 7 VMs with 4 VCPUs created, and more VMs can be created with total VCPUs that can far exceed the 38 VCPUs the current system shows available.

Without limiting the VCPU of VRM01, the VCPU share is customized to 128000, and the number of available CPUs is displayed as 38, indicating that VRM01 can occupy all VCPUs on the host except Domain 0 (Domain 0 takes up 2 VCPUs).





2. Allocation and scheduling
of virtual machine VCPUs For virtual machines, they do not directly perceive physical CPUs, and the computing units of virtual machines are presented through vCPU objects. The virtual machine only sees the vCPUs presented to it by the VMM. In VMM, each vCPU corresponds to a VMCS (Virtual-Machine Control Structure) structure. When the VCPU is switched off from the physical CPU, its running context will be saved in its corresponding VMCS structure; when the VCPU is switched to When running on the PCPU, its running context will be imported from the corresponding VMCS structure to the physical CPU. In this way, the independent operation of each vCPU is realized.
From the structure and function division of the virtual machine system, it can be seen that the guest operating system and the virtual machine monitor together constitute the two-level scheduling framework of the virtual machine system, as shown in the figure is a two-level scheduling framework of the virtual machine system in a multi-core environment . The guest operating system is responsible for level 2 scheduling, that is, the scheduling of threads or processes on vCPUs (mapping core threads to the corresponding VCPUs). The hypervisor is responsible for level 1 scheduling, the scheduling of vCPUs on physical processing units. There is no dependency on the scheduling strategy and mechanism of two-level scheduling. The vCPU scheduler is responsible for the allocation and scheduling of physical processor resources among virtual machines. In essence, the vCPUs in each virtual machine are scheduled on the physical processing unit according to certain policies and mechanisms, and any policy can be used to allocate physical resources. , to meet the different needs of virtual machines. The vCPU can be scheduled to execute on one or more physical processing units (time-multiplexing or spatial multiplexing of physical processing units), or it can establish a one-to-one fixed mapping relationship with physical processing units (restrict access to specified physical processing units).



3. CPU QoS description
The hypervisor layer implements scheduling of VCPUs according to the principle of time-sharing and multiplexing. The principle of CPU QoS is to regularly allocate running time slices to each VCPU, and account for the running time of each VCPU. The virtual CPU will be throttled until a time slice is obtained. In this way, the proportion of physical computing resources obtained by the virtual machine is controlled. The above time period for allocating time slices and accounting is very short, and it will feel like running all the time for virtual machine users.
The CPU reservation defines the minimum CPU resources allocated to this VM.
The CPU limit defines the upper limit of the CPU resources allocated to a virtual machine.
CPU shares define the proportional allocation of multiple virtual machines when competing for CPU resources.
CPU shares only play a role when each virtual machine competes for computing resources. If there is no competition, a virtual machine in need can monopolize the physical CPU resources of the host.
If the computing power calculated by the virtual machine based on the share value is less than the reserved value of the virtual machine, the scheduling algorithm will give priority to assigning the virtual machine to the virtual machine according to the reserved value of the virtual machine. Deducted from the CPU of other virtual machines on the host in proportion to their respective shares.
If the computing power of the virtual machine based on the share value is greater than the reserved value of the virtual machine, the computing power of the virtual machine will be calculated based on the share value.
Taking a single-core physical machine with a main frequency of 2800**z as an example, if three virtual machines A, B, and C with a single VCPU are run at full load, the allocation is as follows.


Conclusion 2: Due to the time-sharing multiplexing method, the total number of VCPUs that the system can allocate to VMs is much larger than the actual number of VCPUs that can be provided without VCPU reservation (the specific number of additional VCPUs that can be created depends on the physical CPU performance and VCPU usage rate), and allocate resources according to reservations and shares in CPU QoS when resource contention occurs.

 

---------------------------------------------

 

Cloud computing vCPU resource calculation formula (**z)

http://support.huawei.com/ecommunity/bbs/10254390.html

 

vCPU resource = number of physical CPUs * number of physical CPU cores * number of threads per core * CPU frequency

Example : 1 CPU, dual core, 2 threads per core, 3.0GHz, then vCPU resources = 1 * 2 * 2 * 3.0GHz = 12GHz = 12000**z.

FusionCompute can limit CPU resources in the process of provisioning virtual machines. There are two important parameters:
share reservation: the minimum value of the allocated vCPU
resources ;

share limit: the maximum value of the allocated vCPU resources;

When the maximum value is selected, the

vCPU .

In virtualization scenarios, overloading, in many cases, one virtual machine has one physical CPU thread per vCPU. Therefore, for cloud computing engineers to quickly and easily estimate the number of virtual machines that a physical server can host, it can be considered that 1 physical CPU thread = 1 vCPU.

Example 1: Virtualization scenario, 10 servers, each server has 2-socket 8-core 2.8GHz CPU, the number of vCPUs provided = 10 * 2 * 8 * 2 = 320 vCPUs, which can host 160 virtual machines of 2U2G.

Example 2: Virtualization scenario, 10 servers, each server has 2-way 8-core 2.8GHz CPU, provided vCPU resources = 10 * 2 * 8 * 2 * 2.8GHz = 896GHz, can host 2 vCPU 2.8GHz virtual machines 160 machines.

In desktop cloud scenarios, under heavy load, each physical CPU core can carry 5 virtual machines in many cases. Therefore, for cloud computing engineers to quickly and easily estimate the virtual machine density of physical servers, it can be considered that 1 physical core = 5 virtual machines.

Example: desktop cloud scenario, 10 servers, each server has 2-socket 8-core 2.8GHz CPU, virtual machine density = 10 * 2 * 8 * 5 = 800 virtual machines.


Summary:
Virtualization scenario: 1 physical CPU thread = 1 vCPU
Desktop cloud scenario: 1 physical core = 5 virtual machines


Note : The calculation method of the above scenario is only for quick estimation, the exact number of vCPUs, virtual machine density and CPU The model, frequency, domain0 specification, and virtual machine specification are strongly related, and detailed analysis and calculation are required.

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326891107&siteId=291194637