Virtual machine construction method and device, computer equipment and storage medium

By selecting construction policies and optimizing memory access based on virtual machine requirements under the NUMA architecture, the problem of poor performance of traditional virtual machines is solved, and more efficient virtual machine performance and requirements matching are achieved.

CN119166285APending Publication Date: 2024-12-20SUGON INFORMATION IND +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411214681.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

The performance of virtual machines traditionally built under the NUMA architecture is poor and it is difficult to effectively match the actual usage requirements.

Method used

Determine the construction strategy based on the requirements of the virtual machine to be built, choose to build a virtual machine on a centralized or decentralized node of the physical machine, and optimize memory access through large-page memory division and virtual thread allocation to improve the performance and matching of the virtual machine.

Benefits of technology

By building policy matching, the performance of the virtual machine and the actual usage requirements are improved, and the overall performance of the virtual machine is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166285A_ABST
    Figure CN119166285A_ABST
Patent Text Reader

Abstract

The invention relates to a virtual machine construction method and device, computer equipment and a storage medium. The method comprises the steps of determining a corresponding construction strategy according to a construction requirement of a to-be-constructed target virtual machine; and constructing the target virtual machine on the target node of the physical machine according to the configuration parameters and the construction strategy of the target virtual machine. According to the method, the construction strategy is determined according to the construction requirement of the target virtual machine, so that the constructed target virtual machine is more matched with the actual use requirement, the target virtual machine can exert better performance in actual use, and meanwhile, according to the configuration parameters and the construction strategy of the target virtual machine, the construction efficiency of the target virtual machine is improved. And the matching degree of the target virtual machine and the actual use requirement is further improved, so that the performance of the target virtual machine is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of virtual machine technology, and in particular to a method, device, computer equipment and storage medium for constructing a virtual machine. Background Art

[0002] As the number of processor cores increases, the unified memory access architecture poses challenges to the bus bandwidth and is prone to conflicts in accessing the same memory block. To solve these problems, the Non-Uniform Memory Access (NUMA) technology has emerged. Under the NUMA architecture, different memory devices and processor cores belong to different nodes, and each node has an integrated memory controller (IMC), so that virtual machines can be built under the NUMA architecture.

[0003] However, traditional virtual machines built under the NUMA architecture have the problem of poor performance. Summary of the invention

[0004] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for building a virtual machine that can improve the performance of the virtual machine in response to the above technical problems.

[0005] In a first aspect, the present application provides a method for constructing a virtual machine, comprising:

[0006] Determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be built;

[0007] The target virtual machine is built on the target node of the physical machine according to the configuration parameters and building strategy of the target virtual machine.

[0008] In one embodiment, according to the construction requirements of the target virtual machine to be constructed, determining the corresponding construction strategy includes:

[0009] If the construction requirement is a construction requirement for a performance-type virtual machine, the construction strategy is determined to be a first construction strategy; the first construction strategy includes building a target virtual machine on a centralized node on a physical machine;

[0010] If the construction requirement is a construction requirement of a bandwidth-type virtual machine, the construction strategy is determined to be a second construction strategy; the second construction strategy includes constructing the target virtual machine on nodes dispersed on the physical machine.

[0011] In one embodiment, the construction strategy is a first construction strategy, and the target virtual machine is constructed on the target node of the physical machine according to the configuration parameters of the target virtual machine and the construction strategy, including:

[0012] Determine whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each slot of the physical machine;

[0013] When the number of virtual threads is less than the number of physical threads, the target node is determined according to the number of virtual threads and the number of physical threads, and the virtual threads of the target virtual machine are allocated to the physical threads of the target node; the target node is a node or multiple consecutive nodes on the physical machine.

[0014] In one embodiment, the construction strategy is a second construction strategy, and the target virtual machine is constructed on the target node of the physical machine according to the configuration parameters of the target virtual machine and the construction strategy, including:

[0015] Determine the target slot corresponding to the target virtual machine according to the number of virtual threads in the configuration parameters and the number of physical threads corresponding to each slot of the physical machine;

[0016] Evenly distribute the virtual threads of the target virtual machine to the physical threads of each node in the target slot.

[0017] In one embodiment, the method further comprises:

[0018] According to the hardware information of the nodes on the physical machine, the memory on the physical machine is divided into large pages of memory for each node;

[0019] Allocate the corresponding large page memory to the target node after building the target virtual machine.

[0020] In one embodiment, the memory on the physical machine is divided into large page memory of each node according to the hardware information of the node on the physical machine, including:

[0021] Determine the memory requirements of the virtual machines on the node based on the memory requirements of the nodes on the physical machine and the preset allocation ratio; the preset allocation ratio indicates the proportion of memory allocated to the physical machine and the virtual machine on the node;

[0022] The number of huge pages of the virtual machine on the node is determined according to the memory requirements of the virtual machine on the node and the attribute information of the huge page memory.

[0023] In a second aspect, the present application also provides a virtual machine construction device, including:

[0024] A determination module is used to determine a corresponding construction strategy according to the construction requirements of the target virtual machine to be constructed;

[0025] The building module is used to build the target virtual machine on the target node of the physical machine according to the configuration parameters and building strategy of the target virtual machine.

[0026] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0027] Determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be built;

[0028] The target virtual machine is built on the target node of the physical machine according to the configuration parameters and building strategy of the target virtual machine.

[0029] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0030] Determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be built;

[0031] The target virtual machine is built on the target node of the physical machine according to the configuration parameters and building strategy of the target virtual machine.

[0032] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0033] Determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be built;

[0034] The target virtual machine is built on the target node of the physical machine according to the configuration parameters and building strategy of the target virtual machine.

[0035] The above-mentioned virtual machine construction method, device, computer equipment and storage medium determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be constructed; thereby constructing the target virtual machine on the target node of the physical machine according to the configuration parameters and construction strategy of the target virtual machine. According to the construction requirements of the target virtual machine, the construction strategy is determined so that the constructed target virtual machine is more matched with the actual use requirements, so that the target virtual machine can exert better performance in actual use. At the same time, according to the configuration parameters and construction strategy of the target virtual machine, the matching degree between the target virtual machine and the actual use requirements is further improved, thereby further improving the performance of the target virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0037] FIG1 is an application environment diagram of a method for constructing a virtual machine in one embodiment;

[0038] FIG2 is a schematic diagram of a flow chart of a method for constructing a virtual machine in one embodiment;

[0039] FIG3 is a schematic diagram of a flow chart of a method for constructing a virtual machine in another embodiment;

[0040] FIG4 is a schematic diagram of a flow chart of a method for constructing a virtual machine in another embodiment;

[0041] FIG5 is a schematic diagram of a performance-based virtual machine in one embodiment;

[0042] FIG6 is a schematic diagram of a flow chart of a method for constructing a virtual machine in another embodiment;

[0043] FIG7 is a schematic diagram of a bandwidth-based virtual machine in one embodiment;

[0044] FIG8 is a schematic diagram of a flow chart of a method for constructing a virtual machine in another embodiment;

[0045] FIG9 is a schematic diagram of a flow chart of a method for constructing a virtual machine in another embodiment;

[0046] FIG10 is a schematic diagram of a flow chart of a method for constructing a virtual machine in another embodiment;

[0047] FIG. 11 is a structural block diagram of a device for constructing a virtual machine in one embodiment. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0049] The method for constructing a virtual machine provided in an embodiment of the present application can be applied to an application environment as shown in Figure 1. Wherein, the computer device can be a server, and its internal structure diagram can be shown in Figure 1. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Wherein, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Wherein, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the construction data of the virtual machine. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for constructing a virtual machine is implemented.

[0050] Those skilled in the art will understand that the structure shown in FIG. 1 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0051] In one embodiment, as shown in FIG. 2 , a method for constructing a virtual machine is provided, and the method is applied to the server in FIG. 1 as an example for explanation, including:

[0052] S201, determining a corresponding construction strategy according to construction requirements of a target virtual machine to be constructed.

[0053] The construction requirement may include the type of the target virtual machine; or the construction requirement may include the type and configuration parameters of the target virtual machine. The type of virtual machine includes a performance-based virtual machine and a bandwidth-based virtual machine.

[0054] In an embodiment of the present application, the server can pre-form a policy library with multiple construction strategies and store the correspondence between each construction requirement and the construction strategy, so as to determine the rated construction strategy corresponding to the construction requirement of the target virtual machine from the policy library based on the construction requirements and the correspondence of the target virtual machine.

[0055] S202: Build a target virtual machine on a target node of a physical machine according to configuration parameters and a build strategy of the target virtual machine.

[0056] The configuration parameters of the target virtual machine may include at least one of the number of virtual sockets, the number of virtual processor blocks in each virtual socket, the number of virtual cores in each virtual processor block, and the number of virtual threads in each virtual core, wherein the virtual socket may be represented as vSocket, the virtual processor block in each virtual socket may be represented as vDIES, the virtual core in each virtual processor block may be represented as vCores, and the virtual thread in each virtual core may be represented as vThreads; or, the configuration parameters of the target virtual machine may include the number of virtual threads, and the virtual thread may be represented as vCPU. The target node may be a node on a physical machine under a non-uniform memory access (NUMA) architecture.

[0057] In an embodiment of the present application, the server itself is a physical machine, and a virtual machine can be built in a physical node of the physical machine. The server can parse the build requirements to obtain the configuration parameters of the target virtual machine; or, the server can determine the default configuration parameters from a preset database; or, the server can parse the build requirements to determine at least one of the number of vSockets, the number of vDIES, the number of vCores, and the number of vThreads of the target virtual machine, and determine the remaining configuration parameters that are not in the build requirements from a preset database. Furthermore, according to the configuration parameters and build strategy of the target virtual machine, a preset build script can be run to build the target virtual machine on the target node of the physical machine.

[0058] Optionally, when the configuration parameters include the number of vSockets, the number of vDIES, the number of vCores, and the number of vThreads, the product of the number of vSockets, the number of vDIES, the number of vCores, and the number of vThreads may be determined as the number of vCPUs, thereby building the target virtual machine on the target node of the physical machine according to the number of vCPUs and the building strategy. When the configuration parameters include the number of vCPUs, the target virtual machine is built on the target node of the physical machine according to the number of vCPUs and the building strategy.

[0059] In the above-mentioned virtual machine construction method, the corresponding construction strategy is determined according to the construction requirements of the target virtual machine to be constructed; thus, the target virtual machine is constructed on the target node of the physical machine according to the configuration parameters and construction strategy of the target virtual machine. According to the construction requirements of the target virtual machine, the construction strategy is determined so that the constructed target virtual machine is more matched with the actual use requirements, so that the target virtual machine can exert better performance in actual use. At the same time, according to the configuration parameters and construction strategy of the target virtual machine, the matching degree between the target virtual machine and the actual use requirements is further improved, thereby further improving the performance of the target virtual machine.

[0060] In one embodiment, an implementation of the above S201 is provided, as shown in FIG3 , wherein the above “determining a corresponding construction strategy according to the construction requirements of the target virtual machine to be constructed” includes:

[0061] S301, determine whether the construction requirement is the construction requirement of a performance-type virtual machine or the construction requirement of a bandwidth-type virtual machine. If the construction requirement is the construction requirement of a performance-type virtual machine, execute S302; if the construction requirement is the construction requirement of a bandwidth-type virtual machine, execute S303.

[0062] The construction requirements of the target virtual machine include the construction requirements of a performance-type virtual machine or a bandwidth-type virtual machine. A performance-type virtual machine can provide powerful central processing unit (CPU) computing power to meet workloads with high computing requirements. It is suitable for application scenarios that require a large amount of computing resources, such as scientific computing, big data analysis, and complex engineering simulations. A bandwidth-type virtual machine is a high-memory bandwidth virtual machine that can provide high memory bandwidth and a large amount of random access memory (RAM) to support memory-intensive workloads. It is suitable for large databases, memory caches, and real-time big data analysis.

[0063] In the embodiment of the present application, the first construction strategy and the second construction strategy are pre-stored in the server, so as to match the corresponding construction strategy for the target virtual machine according to the construction requirements.

[0064] S302, determining that the construction strategy is a first construction strategy; the first construction strategy includes building a target virtual machine on a centralized node on a physical machine.

[0065] In an embodiment of the present application, the first construction strategy includes constructing a target virtual machine on a centralized node on a physical machine, wherein the centralized node is a node or a plurality of consecutive nodes on the physical machine. Since performance-oriented virtual machines require powerful CPU computing power, virtual machines established on centralized nodes can perform operations such as computing and processing in a centralized manner in the memory corresponding to the centralized node, so the first construction strategy is determined as the construction strategy corresponding to the performance-oriented virtual machine.

[0066] S303, determining that the construction strategy is a second construction strategy; the second construction strategy includes constructing a target virtual machine on nodes dispersed on the physical machine.

[0067] In an embodiment of the present application, the second construction strategy includes constructing a target virtual machine on dispersed nodes on a physical machine, wherein the dispersed nodes are multiple nodes corresponding to one slot on the physical machine, or multiple nodes corresponding to multiple slots on the physical machine. Since a bandwidth-type virtual machine can provide high memory bandwidth, when constructing a target virtual machine on dispersed nodes, the target virtual machine can simultaneously access the memory corresponding to multiple nodes, so the second construction strategy is determined as the construction strategy corresponding to the bandwidth-type virtual machine.

[0068] In the above application embodiment, when the construction requirement is a construction requirement for a performance-type virtual machine, the construction strategy is determined to be the first construction strategy, and when the construction requirement is a construction requirement for a bandwidth-type virtual machine, the construction strategy is determined to be the second construction strategy, which improves the matching degree between the construction requirement and the construction strategy, thereby improving the matching degree between the target virtual machine and the application scenario, so that the target virtual machine can perform better performance during use.

[0069] In one embodiment, an implementation of the above S202 is provided, the construction strategy is a first construction strategy, as shown in FIG4 , and the above “constructing the target virtual machine on the target node of the physical machine according to the configuration parameters and construction strategy of the target virtual machine” includes:

[0070] S401, determining whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each socket of the physical machine.

[0071] In an embodiment of the present application, it is determined whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each slot of the physical machine. If not, the construction of the target virtual machine fails. If less, the server can continue to build the target virtual machine according to the first construction strategy.

[0072] For example, as shown in FIG5 , FIG5 includes two slots of a physical machine, namely slot 1 and slot 2, each slot includes two nodes, namely node 0, node 1, node 2 and node 2, each node includes 8 physical threads, that is, each slot of the physical machine includes 16 physical threads. If the number of virtual threads is 15, it is determined that the number of virtual threads is less than the number of physical threads.

[0073] S402, when the number of virtual threads is less than the number of physical threads, determine the target node according to the number of virtual threads and the number of physical threads, and allocate the virtual threads of the target virtual machine to the physical threads of the target node; the target node is a node or multiple consecutive nodes on the physical machine.

[0074] In the embodiment of the present application, when the number of virtual threads is less than the number of physical threads, it is determined whether the number of virtual threads is less than the number of physical threads corresponding to each node. If the number of virtual threads is less than the number of physical threads corresponding to each node, the number of target nodes is determined to be 1, and the target node is determined from multiple nodes of the physical machine according to the construction order of the target virtual machine. Further, a physical thread with the same number as the virtual thread is randomly selected from the target node, and the virtual threads of the target virtual machine are allocated to the physical threads of the target node in a one-to-one correspondence manner.

[0075] For example, if a total of 6 virtual machines are built, namely virtual machine 0, virtual machine 1, virtual machine 2, virtual machine 3, virtual machine 4, virtual machine 5 and virtual machine 6, and the physical machine includes 4 nodes, namely node 0, node 1, node 2 and node 3, then the target node of virtual machine 0 is node 0, the target node of virtual machine 1 is node 1, the target node of virtual machine 2 is node 2, the target node of virtual machine 3 is node 3, the target node of virtual machine 4 is node 0, and the target node of virtual machine 5 is node 1.

[0076] Exemplarily, if the number of virtual threads of a virtual machine is 4, the schematic diagram of the virtual threads of the target virtual machine at the target node can be as shown in Figure 5, where VM0, VM1, VM2, VM3, VM4, and VM5 in Figure 5 represent the virtual threads of virtual machine 0, virtual machine 1, virtual machine 2, virtual machine 3, virtual machine 4, and virtual machine 5, respectively.

[0077] In the embodiment of the present application, if the number of virtual threads is not less than the number of physical threads corresponding to each node, the number of virtual threads is divided by the number of physical threads corresponding to each node, and the ceiling function is constructed and rounded up to determine the number of target nodes, and multiple target nodes are determined from multiple nodes of the physical machine according to the construction order of the target virtual machine. Further, physical threads with the same number of virtual threads are randomly selected from the multiple target nodes, and the virtual threads of the target virtual machine are allocated to the physical threads of the target node in a one-to-one correspondence manner.

[0078] Exemplarily, if the number of virtual threads is 9 and the number of physical threads corresponding to each node is 8, then 8 is divided by 9 and a ceiling function is constructed to round up to determine the number of target nodes to be 2. Further, if a total of 4 virtual machines are constructed, namely virtual machine 0, virtual machine 1, virtual machine 2, and virtual machine 3, and the physical machine includes 4 nodes, namely node 0, node 1, node 2, and node 3, then the target nodes of virtual machine 0 are node 0 and node 1, the target nodes of virtual machine 1 are node 2 and node 3, the target nodes of virtual machine 2 are node 0 and node 1, and the target nodes of virtual machine 3 are node 2 and node 3.

[0079] It should be noted that one virtual thread corresponds to one physical thread, but one physical thread can correspond to multiple virtual threads.

[0080] In the above application embodiment, a performance-based virtual machine is constructed on the target node based on the number of virtual threads and the number of physical threads, thereby improving the centralization of the node where the performance-based virtual machine is located, thereby improving the performance of the performance-based virtual machine.

[0081] In one embodiment, an implementation of the above S202 is provided, the construction strategy is a second construction strategy, as shown in FIG6 , and the above “constructing the target virtual machine on the target node of the physical machine according to the configuration parameters and construction strategy of the target virtual machine” includes:

[0082] S501, determining a target slot corresponding to a target virtual machine according to the number of virtual threads in the configuration parameters and the number of physical threads corresponding to each slot of the physical machine.

[0083] In the embodiment of the present application, it is determined whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each slot of the physical machine. If so, the number of target slots corresponding to the target virtual machine is determined to be 1; if not, the number of target slots is determined based on the number of virtual threads and the number of physical threads corresponding to each slot. Further, the corresponding number of target slots is determined in the physical machine based on the number of target slots.

[0084] Optionally, the number of virtual threads is divided by the number of physical threads corresponding to each slot, and a ceiling function is constructed to round up. For example, as shown in Figure 7, the number of physical threads corresponding to each slot is 16. If the number of virtual threads is 4, the number of target slots is determined to be 1; if the number of virtual threads is 18, 18 is divided by 16 and a ceiling function is constructed to round up to determine the number of target slots to be 2.

[0085] S502, evenly distribute the virtual threads of the target virtual machine to the physical threads of each node in the target slot.

[0086] In an embodiment of the present application, if the target slot is 1, the virtual threads of the target virtual machine are evenly distributed to each node in the target slot. For example, if the number of virtual threads is 5, namely virtual thread 0, virtual thread 1, virtual thread 2, virtual thread 3 and virtual thread 4, and the target slot includes 4 nodes, namely node 0, node 1, node 2 and node 3, then virtual thread 0 can be distributed to any physical thread in node 0, virtual thread 1 can be distributed to any physical thread in node 1, virtual thread 2 can be distributed to any physical thread in node 2, virtual thread 3 can be distributed to any physical thread in node 3, and virtual thread 4 can be distributed to any physical thread in node 0; if the number of virtual threads is 2, namely virtual thread 0 and virtual thread 1, and the target slot includes 4 nodes, namely node 0, node 1, node 2 and node 3, then virtual thread 0 can be distributed to any physical thread in node 0, and virtual thread 1 can be distributed to any physical thread in node 1.

[0087] Exemplarily, if the number of virtual threads of the target virtual machine is 18, the target virtual machine may be as shown in FIG. 7 , where the VM in FIG. 7 is the virtual thread of the target virtual machine.

[0088] In the embodiment of the present application, if there is one target slot, all nodes in the target slot are used as target nodes, and virtual threads are evenly distributed to the physical threads of each target node.

[0089] In the above application embodiment, a bandwidth-type virtual machine is constructed on the target node according to the number of virtual threads and the number of physical threads, thereby improving the bandwidth of the bandwidth-type virtual machine and thus improving the performance of the bandwidth-type virtual machine.

[0090] In one embodiment, as shown in FIG8 , the method for constructing the virtual machine further includes:

[0091] S203, dividing the memory on the physical machine into large pages for each node according to the hardware information of the node on the physical machine.

[0092] The hardware information of the node includes node information, the number of cores of each node, etc.

[0093] In an embodiment of the present application, the memory capacity corresponding to each node on the physical machine is determined, and the memory capacity corresponding to each node is divided. The number of large page memories corresponding to each node can be determined, and the total number of large page memories can be determined based on the number of large page memories corresponding to the node, and the number of large page memories corresponding to each node and the total number of large page memories are stored in a preset storage location.

[0094] Optionally, the correspondence between the hardware information of each node and the large page memory information can be pre-set. The large page memory information can include the memory capacity corresponding to each large page, etc., so as to determine the corresponding large page memory information based on the hardware information and the correspondence, and then divide the large page memory of each node on the physical machine according to the large page memory information.

[0095] S204, allocating corresponding large page memory to the target node after the target virtual machine is built.

[0096] In an embodiment of the present application, after the target virtual machine is built on the target node of the physical machine according to the configuration parameters and construction strategy of the target virtual machine, the pre-stored large page memory number corresponding to each node and the total large page memory number are written into the startup parameters of the target virtual machine, thereby allocating a corresponding number of large page memories to each node, so that the virtual thread can access the large page memory of the corresponding node.

[0097] In the above-mentioned application embodiment, the memory on the physical machine is divided into large page memory of each node, and the corresponding large page memory is allocated to the target node after the target virtual machine is built. The memory is allocated and managed through the large page memory, which improves the access speed and call speed of the target virtual machine to the memory, thereby improving the performance of the target virtual machine.

[0098] In one embodiment, an implementation of the above S203 is provided, as shown in FIG9 , wherein the above “dividing the memory on the physical machine into large pages of each node according to the hardware information of the node on the physical machine” includes:

[0099] S601, determining the memory requirement of the virtual machine on the node according to the memory requirement of the node on the physical machine and the preset allocation ratio; the preset allocation ratio represents the proportion of the memory allocated to the physical machine and the virtual machine on the node.

[0100] The memory requirement of the nodes on the physical machine is the memory capacity corresponding to each node.

[0101] In an embodiment of the present application, the product of the memory requirement of the node on the physical machine and the preset allocation ratio is used as the memory requirement of the virtual machine on the node, that is, the available memory of the virtual machine.

[0102] For example, if the memory requirement of the node is 512 GB and the preset allocation ratio is 90%, the memory requirement of the virtual machine on the node is 460.8 GB.

[0103] S602, determining the number of huge pages of the virtual machine on the node according to the memory requirement of the virtual machine on the node and the attribute information of the huge page memory.

[0104] The attribute information of the large page memory may include the content capacity corresponding to each large page.

[0105] In an embodiment of the present application, the ratio of the memory demand of the virtual machine on the node to the attribute information of the huge page memory is determined, and the integer part of the ratio is determined as the number of huge pages of the virtual machine on the node. For example, if the memory demand of the virtual machine on the node is 460.8G and the attribute information of the huge page memory is 2G, then the ratio of the memory demand of the virtual machine on the node to the attribute information of the huge page memory is 230.4G, and the number of huge pages of the virtual machine on the node is determined to be 230.

[0106] In the above-mentioned application embodiment, the number of large pages of the virtual machine on the node is determined based on the memory requirement of the node on the physical machine, the preset allocation ratio and the attribute information of the large page memory, so that the division of the large page memory is more accurate, and the memory requirement of the virtual machine on the node is determined based on the memory requirement of the node on the physical machine and the preset allocation ratio, so that the server can guarantee the memory requirements of both the physical machine and the virtual machine at the same time.

[0107] In one embodiment, a complete method for building a virtual machine is also provided, as shown in FIG10 , including:

[0108] S1, determining a corresponding construction strategy according to the construction requirements of the target virtual machine to be constructed.

[0109] S2, build the target virtual machine on the target node of the physical machine according to the configuration parameters and building strategy of the target virtual machine.

[0110] S3, if the construction requirement is the construction requirement of a performance-type virtual machine, execute S4-S5; if the construction requirement is the construction requirement of a bandwidth-type virtual machine, execute S6-S7.

[0111] S4, determining whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each slot of the physical machine;

[0112] S5, when the number of virtual threads is less than the number of physical threads, determine the target node according to the number of virtual threads and the number of physical threads, and allocate the virtual threads of the target virtual machine to the physical threads of the target node; the target node is a node or multiple consecutive nodes on the physical machine.

[0113] S6, determining a target slot corresponding to the target virtual machine according to the number of virtual threads in the configuration parameters and the number of physical threads corresponding to each slot of the physical machine.

[0114] S7, evenly distribute the virtual threads of the target virtual machine to the physical threads of each node in the target slot.

[0115] S8, determining the memory requirement of the virtual machine on the node according to the memory requirement of the node on the physical machine and the preset allocation ratio; the preset allocation ratio represents the proportion of memory allocated to the physical machine and the virtual machine on the node.

[0116] S9, determining the number of huge pages of the virtual machine on the node according to the memory requirement of the virtual machine on the node and the attribute information of the huge page memory.

[0117] S10, allocating corresponding large page memory to the target node after the target virtual machine is built.

[0118] In the above-mentioned virtual machine construction method, the corresponding construction strategy is determined according to the construction requirements of the target virtual machine to be constructed; thus, the target virtual machine is constructed on the target node of the physical machine according to the configuration parameters and construction strategy of the target virtual machine. According to the construction requirements of the target virtual machine, the construction strategy is determined so that the constructed target virtual machine is more matched with the actual use requirements, so that the target virtual machine can exert better performance in actual use. At the same time, according to the configuration parameters and construction strategy of the target virtual machine, the matching degree of the target virtual machine with the actual use requirements is further improved, thereby further improving the performance of the target virtual machine.

[0119] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0120] Based on the same inventive concept, the embodiment of the present application also provides a virtual machine construction device for implementing the virtual machine construction method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of the construction device for one or more virtual machines provided below can refer to the limitations of the virtual machine construction method above, and will not be repeated here.

[0121] In one embodiment, as shown in FIG11 , a virtual machine construction device is provided, including: a determination module 10 and a construction module 11, wherein:

[0122] The determination module 10 is used to determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be constructed.

[0123] The construction module 11 is used to construct the target virtual machine on the target node of the physical machine according to the configuration parameters and construction strategy of the target virtual machine.

[0124] In one embodiment, the above-mentioned determination module 10 includes: a first determination unit and a second determination unit, wherein:

[0125] The first determining unit is used to determine the construction strategy as a first construction strategy when the construction requirement is a construction requirement of a performance-type virtual machine; the first construction strategy includes building a target virtual machine on a centralized node on a physical machine.

[0126] The second determining unit is used to determine the construction strategy as a second construction strategy when the construction requirement is a construction requirement of a bandwidth-type virtual machine; the second construction strategy includes constructing the target virtual machine on dispersed nodes on the physical machine.

[0127] In one embodiment, the above-mentioned first determination unit is specifically used to determine whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each slot of the physical machine; when the number of virtual threads is less than the number of physical threads, the target node is determined according to the number of virtual threads and the number of physical threads, and the virtual threads of the target virtual machine are allocated to the physical threads of the target node; the target node is a node or multiple consecutive nodes on the physical machine.

[0128] In one embodiment, the second determination unit is specifically used to determine the target slot corresponding to the target virtual machine based on the number of virtual threads in the configuration parameters and the number of physical threads corresponding to each slot of the physical machine; and evenly distribute the virtual threads of the target virtual machine to the physical threads of each node in the target slot.

[0129] In one embodiment, the above-mentioned virtual machine construction device further includes: a partitioning module and an allocation module, wherein:

[0130] The partitioning module is used to partition the memory on the physical machine into large pages for each node according to the hardware information of the node on the physical machine.

[0131] The allocation module is used to allocate the corresponding large page memory to the target node after the target virtual machine is built.

[0132] In one embodiment, the above-mentioned division module includes: a third determination unit and a fourth determination unit, wherein:

[0133] The third determining unit is used to determine the memory demand of the virtual machine on the node according to the memory demand of the node on the physical machine and the preset allocation ratio; the preset allocation ratio represents the proportion of memory allocated to the physical machine and the virtual machine on the node.

[0134] The fourth determining unit is used to determine the number of huge pages of the virtual machine on the node according to the memory requirement of the virtual machine on the node and the attribute information of the huge page memory.

[0135] Each module in the above-mentioned virtual machine construction device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0136] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0137] Determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be built;

[0138] The target virtual machine is built on the target node of the physical machine according to the configuration parameters and building strategy of the target virtual machine.

[0139] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0140] If the construction requirement is a construction requirement for a performance-type virtual machine, the construction strategy is determined to be a first construction strategy; the first construction strategy includes building a target virtual machine on a centralized node on a physical machine;

[0141] If the construction requirement is a construction requirement of a bandwidth-type virtual machine, the construction strategy is determined to be a second construction strategy; the second construction strategy includes constructing the target virtual machine on nodes dispersed on the physical machine.

[0142] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0143] Determine whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each slot of the physical machine;

[0144] When the number of virtual threads is less than the number of physical threads, the target node is determined according to the number of virtual threads and the number of physical threads, and the virtual threads of the target virtual machine are allocated to the physical threads of the target node; the target node is a node or multiple consecutive nodes on the physical machine.

[0145] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0146] Determine the target slot corresponding to the target virtual machine according to the number of virtual threads in the configuration parameters and the number of physical threads corresponding to each slot of the physical machine;

[0147] Evenly distribute the virtual threads of the target virtual machine to the physical threads of each node in the target slot.

[0148] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0149] According to the hardware information of the nodes on the physical machine, the memory on the physical machine is divided into large pages of memory for each node;

[0150] Allocate the corresponding large page memory to the target node after building the target virtual machine.

[0151] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0152] Determine the memory requirements of the virtual machines on the node based on the memory requirements of the nodes on the physical machine and the preset allocation ratio; the preset allocation ratio indicates the proportion of memory allocated to the physical machine and the virtual machine on the node;

[0153] The number of huge pages of the virtual machine on the node is determined according to the memory requirements of the virtual machine on the node and the attribute information of the huge page memory.

[0154] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0155] Determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be built;

[0156] The target virtual machine is built on the target node of the physical machine according to the configuration parameters and building strategy of the target virtual machine.

[0157] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0158] If the construction requirement is a construction requirement for a performance-type virtual machine, the construction strategy is determined to be a first construction strategy; the first construction strategy includes building a target virtual machine on a centralized node on a physical machine;

[0159] If the construction requirement is a construction requirement of a bandwidth-type virtual machine, the construction strategy is determined to be a second construction strategy; the second construction strategy includes constructing the target virtual machine on nodes dispersed on the physical machine.

[0160] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0161] Determine whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each slot of the physical machine;

[0162] When the number of virtual threads is less than the number of physical threads, the target node is determined according to the number of virtual threads and the number of physical threads, and the virtual threads of the target virtual machine are allocated to the physical threads of the target node; the target node is a node or multiple consecutive nodes on the physical machine.

[0163] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0164] Determine the target slot corresponding to the target virtual machine according to the number of virtual threads in the configuration parameters and the number of physical threads corresponding to each slot of the physical machine;

[0165] Evenly distribute the virtual threads of the target virtual machine to the physical threads of each node in the target slot.

[0166] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0167] According to the hardware information of the nodes on the physical machine, the memory on the physical machine is divided into large pages of memory for each node;

[0168] Allocate the corresponding large page memory to the target node after building the target virtual machine.

[0169] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0170] Determine the memory requirements of the virtual machines on the node based on the memory requirements of the nodes on the physical machine and the preset allocation ratio; the preset allocation ratio indicates the proportion of memory allocated to the physical machine and the virtual machine on the node;

[0171] The number of huge pages of the virtual machine on the node is determined according to the memory requirements of the virtual machine on the node and the attribute information of the huge page memory.

[0172] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0173] Determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be built;

[0174] The target virtual machine is built on the target node of the physical machine according to the configuration parameters and building strategy of the target virtual machine.

[0175] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0176] If the construction requirement is a construction requirement for a performance-type virtual machine, the construction strategy is determined to be a first construction strategy; the first construction strategy includes building a target virtual machine on a centralized node on a physical machine;

[0177] If the construction requirement is a construction requirement of a bandwidth-type virtual machine, the construction strategy is determined to be a second construction strategy; the second construction strategy includes constructing the target virtual machine on nodes dispersed on the physical machine.

[0178] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0179] Determine whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each slot of the physical machine;

[0180] When the number of virtual threads is less than the number of physical threads, the target node is determined according to the number of virtual threads and the number of physical threads, and the virtual threads of the target virtual machine are allocated to the physical threads of the target node; the target node is a node or multiple consecutive nodes on the physical machine.

[0181] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0182] Determine the target slot corresponding to the target virtual machine according to the number of virtual threads in the configuration parameters and the number of physical threads corresponding to each slot of the physical machine;

[0183] Evenly distribute the virtual threads of the target virtual machine to the physical threads of each node in the target slot.

[0184] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0185] According to the hardware information of the nodes on the physical machine, the memory on the physical machine is divided into large pages of memory for each node;

[0186] Allocate the corresponding large page memory to the target node after building the target virtual machine.

[0187] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0188] Determine the memory requirements of the virtual machines on the node based on the memory requirements of the nodes on the physical machine and the preset allocation ratio; the preset allocation ratio indicates the proportion of memory allocated to the physical machine and the virtual machine on the node;

[0189] The number of huge pages of the virtual machine on the node is determined according to the memory requirements of the virtual machine on the node and the attribute information of the huge page memory.

[0190] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0191] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0192] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for constructing a virtual machine, characterized in that: The method comprises: Determine the corresponding construction strategy according to the construction requirements of the target virtual machine to be built; The target virtual machine is constructed on a target node of a physical machine according to the configuration parameters of the target virtual machine and the construction strategy.

2. The method according to claim 1, characterized in that Determining a corresponding construction strategy according to the construction requirements of the target virtual machine to be constructed includes: If the construction requirement is a construction requirement for a performance-type virtual machine, determining the construction strategy to be a first construction strategy; the first construction strategy includes constructing the target virtual machine on a node concentrated on the physical machine; If the construction requirement is a construction requirement of a bandwidth-type virtual machine, the construction strategy is determined to be a second construction strategy; the second construction strategy includes constructing the target virtual machine on nodes dispersed on the physical machine.

3. The method according to claim 2, characterized in that The construction strategy is the first construction strategy, and the construction of the target virtual machine on the target node of the physical machine according to the configuration parameters of the target virtual machine and the construction strategy includes: Determine whether the number of virtual threads in the configuration parameters is less than the number of physical threads corresponding to each slot of the physical machine; When the number of virtual threads is less than the number of physical threads, the target node is determined according to the number of virtual threads and the number of physical threads, and the virtual threads of the target virtual machine are allocated to the physical threads of the target node; the target node is a node or multiple consecutive nodes on the physical machine.

4. The method according to claim 2, characterized in that: The construction strategy is a second construction strategy, and the target virtual machine is constructed on a target node of a physical machine according to the configuration parameters of the target virtual machine and the construction strategy, including: Determine the target slot corresponding to the target virtual machine according to the number of virtual threads in the configuration parameters and the number of physical threads corresponding to each slot of the physical machine; Evenly distribute the virtual threads of the target virtual machine to the physical threads of each node in the target slot.

5. The method according to claim 1, characterized in that The method further comprises: According to the hardware information of the nodes on the physical machine, the memory on the physical machine is divided into large page memory of each node; The corresponding large page memory is allocated to the target node after the target virtual machine is built.

6. The method according to claim 5, characterized in that The dividing the memory on the physical machine into large page memory of each node according to the hardware information of the node on the physical machine includes: Determine the memory demand of the virtual machine on the node according to the memory demand of the node on the physical machine and the preset allocation ratio; the preset allocation ratio represents the proportion of memory allocated to the physical machine and the virtual machine on the node; The number of huge pages of the virtual machine on the node is determined according to the memory requirement of the virtual machine on the node and the attribute information of the huge page memory.

7. A device for constructing a virtual machine, characterized in that: The device comprises: A determination module is used to determine a corresponding construction strategy according to the construction requirements of the target virtual machine to be constructed; A construction module is used to construct the target virtual machine on a target node of a physical machine according to the configuration parameters of the target virtual machine and the construction strategy.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.