A virtual machine resource allocation method, device, electronic device and storage medium
By determining the resources of the same NUMA node as the virtual machine logical volume in the virtual machine resource allocation and binding them, the problem of unstable IO performance of the local disk-type virtual machine is solved and the IO performance and stability of the virtual machine are improved.
Patent Information
- Application Number
- CN202111012057.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-31
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-08-31
AI Technical Summary
The IO performance of the local disk-based virtual machine is unstable and has large jitter during operation. The IO performance and stability need to be improved.
By obtaining the resource information of the host machine where the virtual machine is located, it is determined that the target resource and the logical volume used by the virtual machine belong to the same NUMA node, and the target resource is bound to the virtual machine to be allocated to the virtual machine, thereby avoiding cross-NUMA node access and improving IO performance. stability.
It effectively avoids the degradation of IO performance caused by cross-NUMA node access of virtual machines, and improves the IO performance and stability of virtual machines.
Smart Images

Figure CN113760457B
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing, and in particular to a virtual machine resource allocation method, device, electronic device and storage medium. Background Art
[0002] At present, local disk virtual machines (i.e. cloud hosts) developed based on Intel's high-performance storage framework SPDK (storage performance develop kit, an Intel open source high-efficiency storage development kit) have greatly improved performance compared to virtual machines developed based on kernelvhost mode, and can basically bring into play all the performance of NVME SSD (Non-Volatile Memory Express solid-state drive).
[0003] However, it is found in practice that the IO performance of local disk-based virtual machines during operation is not stable and has large jitters. Therefore, a method is needed to improve the IO performance and stability of local disk-based virtual machines during use. Summary of the invention
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a virtual machine resource allocation method, device, electronic device and storage medium.
[0005] In a first aspect, the present application provides a virtual machine resource allocation method, comprising:
[0006] Obtain resource information of resources in a host machine where a virtual machine to which resources are to be allocated is located, the host machine being a non-uniform memory access NUMA server, the resource information including at least node information of a NUMA node to which the resources belong;
[0007] Based on the resource information, determining a target resource from the resources, wherein the target resource and the logical volume used by the virtual machine belong to the same NUMA node;
[0008] The target resource is bound to the virtual machine to allocate the target resource to the virtual machine.
[0009] As a possible implementation manner, determining the target resource from the resources based on the resource information includes:
[0010] Grouping the resources based on the resource information, wherein resources belonging to the same NUMA node are grouped into the same group, and resources belonging to different NUMA nodes are grouped into different groups;
[0011] Determine the target NUMA node to which the logical volume used by the virtual machine belongs;
[0012] A target resource is determined from the group corresponding to the target NUMA node.
[0013] As a possible implementation manner, the name of the logical volume carries node information of the NUMA node to which the solid-state hard disk constituting the logical volume belongs;
[0014] The determining the target NUMA node to which the logical volume used by the virtual machine belongs includes:
[0015] Obtain the name of the logical volume used by the virtual machine;
[0016] Parsing the name to obtain node information of the NUMA node to which the solid state drive constituting the logical volume belongs;
[0017] The NUMA node corresponding to the node information obtained by parsing is determined as the target NUMA node to which the logical volume used by the virtual machine belongs.
[0018] As a possible implementation manner, determining the target resource from the group corresponding to the target NUMA node includes:
[0019] Determine resources that are not allocated to other virtual machines in the group corresponding to the target NUMA node as candidate resources;
[0020] A target resource is determined from the candidate resource information.
[0021] As a possible implementation manner, determining the target resource from the candidate resources includes:
[0022] Determining a first resource quantity to be allocated to the virtual machine, and determining a second resource quantity of the candidate resources;
[0023] comparing the first resource quantity and the second resource quantity;
[0024] If it is determined by comparison that the second resource quantity is not less than the first resource quantity, resources with the first resource quantity are determined from the candidate resources as target resources.
[0025] As a possible implementation manner, the method further includes:
[0026] If it is compared that the second resource quantity is smaller than the first resource quantity, all the alternative resources are determined as target resources, and from the resources in other groups that are not allocated to other virtual machines, resources with a third resource quantity are determined as the target resources, and the third resource quantity is the difference between the first resource quantity and the second resource quantity.
[0027] In a second aspect, an embodiment of the present application further provides a virtual machine resource allocation device, including:
[0028] An acquisition module is used to acquire resource information of resources in a host machine where a virtual machine to which resources are to be allocated is located, wherein the host machine is a non-uniform memory access NUMA server, and the resource information at least includes node information of a NUMA node to which the resource belongs;
[0029] A resource determination module, configured to determine a target resource from the resources based on the resource information, wherein the target resource and the logical volume used by the virtual machine belong to the same NUMA node;
[0030] The resource binding module is used to bind the target resource to the virtual machine so as to allocate the target resource to the virtual machine.
[0031] As a possible implementation manner, the resource determination module includes:
[0032] A grouping submodule, configured to group the resources based on the resource information, wherein resources belonging to the same NUMA node are grouped into the same group, and resources belonging to different NUMA nodes are grouped into different groups;
[0033] A target node determination submodule, used to determine a target NUMA node to which the logical volume used by the virtual machine belongs;
[0034] The resource determination submodule is used to determine the target resource from the group corresponding to the target NUMA node.
[0035] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising: a processor and a memory, wherein the processor is used to execute a virtual machine resource allocation program stored in the memory to implement the virtual machine resource allocation method described in the first aspect.
[0036] In a fourth aspect, an embodiment of the present invention further provides a storage medium, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the virtual machine resource allocation method described in the first aspect.
[0037] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:
[0038] The embodiment of the present application provides a resource allocation method, which obtains resource information of resources in a host machine where a virtual machine to be allocated resources is located, determines a target resource from the resource based on the resource information, wherein the target resource and the logical volume used by the virtual machine belong to the same NUMA node, and binds the target resource to the virtual machine to allocate the target resource to the virtual machine. Since the target resource allocated to the virtual machine and the logical volume used by the virtual machine belong to the same NUMA node, the virtual machine will access the resources under the same NUMA node during operation, thereby avoiding the reduction of the IO performance of the virtual machine caused by the virtual machine accessing across NUMA nodes, thereby improving the stability of the IO performance of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0041] Figure 1 A flowchart of a virtual machine resource allocation method provided in an embodiment of the present application.
[0042] Figure 2 A flow chart of a method for determining a target resource from resources provided in an embodiment of the present application.
[0043] Figure 3 A flow chart of a method for determining a target resource from candidate resources provided in an embodiment of the present application.
[0044] Figure 4 A block diagram of a virtual machine resource allocation device provided in an embodiment of the present application.
[0045] Figure 5 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0047] With the rapid development of computer technology, cloud computing has been rapidly developed and widely used. Cloud computing integrates the originally scattered physical computer resources into a huge resource pool through virtualization technology, providing users with "inexhaustible" computing resources.
[0048] At present, when a virtual machine installed in a NUMA (Non Uniform Memory Access) server is running, the host machine where the virtual machine is located (that is, the NUMA server where the virtual machine is installed) usually uses the numad service to schedule and allocate resources to the virtual machine according to the number of resources required by the virtual machine. Here, the resources include but are not limited to processors, memory, NVME SSD, etc. Although this method of allocating virtual machine resources is relatively common, since the resources are only allocated to the virtual machine according to the number of resources required by the virtual machine, the host machine is not very targeted when allocating resources. Especially when there are multiple NUMA nodes in the host machine, the host machine often allocates resources under different NUMA nodes to the virtual machine, which causes the virtual machine to access across NUMA nodes during operation.
[0049] It is understandable to those skilled in the art that cross-NUMA node access by a virtual machine will result in reduced IO performance of the virtual machine, and different virtual machines are likely to access the same resources, which causes the same resource to be scheduled back and forth by different virtual machines, thereby causing mutual interference between different virtual machines, making the IO performance stability of the virtual machine less stable.
[0050] In order to solve the above technical problems, the present application provides a virtual machine resource allocation method. The method provided by the present application is explained in detail below with specific embodiments, and the embodiments do not constitute a specific limitation on the embodiments of the present application.
[0051] See also Figure 1 , is a flow chart of a virtual machine resource allocation method provided by an exemplary embodiment of the present application, such as Figure 1 As shown, the method may include the following steps:
[0052] S101. Obtain resource information of resources in a host machine where a virtual machine to which resources are to be allocated is located. The host machine is a NUMA server, and the resource information at least includes node information of a NUMA node to which the resources belong.
[0053] In practice, there may be multiple virtual machines in a host machine, and the embodiment of the present application does not limit the number of virtual machines included in a host machine. For ease of description, the following describes the virtual machine resource allocation method provided in the embodiment of the present application by taking the allocation of resources to a virtual machine (hereinafter referred to as the virtual machine to be allocated resources) as an example.
[0054] First of all, it is explained that on a host machine with multiple NUMA nodes, all resources in the host machine are equally divided according to NUMA nodes, that is, the resources in the host machine are evenly distributed to multiple NUMA nodes. Preferably, when wiring, the PCIE slots occupied by NVMESSD in the host machine can be designed to be evenly distributed according to multiple NUMA nodes, so that all NVME SSDs in the host machine can be evenly distributed under multiple NUMA nodes. Among them, the resources in the host machine include processor CPU and memory in addition to NVMESSD.
[0055] Furthermore, the host machine may record the correspondence between each NUMA node and the resource, so as to determine the resources contained in each NUMA node and the NUMA node to which each resource belongs based on the correspondence. Specifically, the correspondence between the above NUMA nodes and resources can be implemented as a correspondence between a NUMA node identifier and a resource identifier. Among them, the resource identifier includes but is not limited to: the system number corresponding to the NVME SSD, the memory number corresponding to the memory, the processor number corresponding to the CPU, etc.
[0056] In the embodiment of the present application, as described in S101, when allocating resources to a virtual machine, resource information of resources in the host machine where the virtual machine is located is first obtained. Here, the resource information at least includes node information of the NUMA node to which the resource belongs, such as a node identifier.
[0057] S102. Determine a target resource from the resources based on the resource information, wherein the target resource and the logical volume used by the virtual machine belong to the same NUMA node.
[0058] S103. Bind the target resource to the virtual machine to allocate the target resource to the virtual machine.
[0059] As can be seen from the descriptions in S102 and S103 above, in the embodiment of the present application, the target resource allocated to the virtual machine and the logical volume used by the virtual machine belong to the same NUMA node, which means that when the virtual machine is running, it will access the resources in the NUMA node where its logical volume is located, thereby avoiding the phenomenon that the virtual machine accesses resources across NUMA nodes when running, and further avoiding the reduction of the IO performance of the virtual machine caused by the virtual machine accessing across NUMA nodes, thereby improving the stability of the IO performance of the virtual machine. As for how to determine the target resource to be allocated to the virtual machine from the resources of the host machine based on the resource information, it will be described below through Figure 2 The process shown is explained and will not be described in detail here.
[0060] In the embodiment of the present application, binding the target resource to the virtual machine may include: creating a configuration file of the virtual machine, adding information of the target resource, such as the processor number of the CPU and the memory number of the memory, to the configuration file, so that the host machine can allocate the target resource to the virtual machine based on the configuration file of the virtual machine. Optionally, the host machine can allocate the target resource to the virtual machine when the virtual machine is started or during the operation of the virtual machine.
[0061] A resource allocation method provided in an embodiment of the present application obtains resource information of resources in a host machine where a virtual machine to be allocated resources is located, determines a target resource from the resource based on the resource information, wherein the target resource and a logical volume used by the virtual machine belong to the same NUMA node, binds the target resource to the virtual machine, and allocates the target resource to the virtual machine. Since the target resource allocated to the virtual machine and the logical volume used by the virtual machine belong to the same NUMA node, the virtual machine accesses resources within the NUMA node to which its own logical volume belongs during operation, thereby avoiding the phenomenon of the virtual machine accessing across NUMA nodes during operation, thereby improving the IO performance and stability of the virtual machine.
[0062] See also Figure 2 , is a flow chart of an embodiment of a virtual machine resource allocation method provided by another embodiment of the present application, in Figure 1 Based on the virtual machine resource allocation method shown, Figure 2 As shown, in the above S102, determining the target resource from the resources based on the resource information may include the following steps:
[0063] S201. Group resources based on resource information, wherein resources belonging to the same NUMA node are grouped into the same group, and resources belonging to different NUMA nodes are grouped into different groups.
[0064] In an embodiment of the present application, the resource information includes at least the node information of the NUMA node to which the resource belongs. Therefore, based on the resource information, resources belonging to the same NUMA node can be divided into the same group, and resources belonging to different NUMA nodes can be divided into different groups, thereby obtaining groups corresponding to each NUMA node.
[0065] S202: Determine the target NUMA node to which the logical volume used by the virtual machine belongs.
[0066] In an embodiment of the present application, a virtual machine can be developed based on SPDK, and information of all NVME SSDs in the host machine can be collected during the startup phase of the SPDK service in the host machine. Then, a name matching the NUMA node to which the NVME SSD belongs is set for each NVME SSD, so that the NUMA node to which the NVME SSD belongs can be determined based on the name of the NVME SSD.
[0067] As an optional implementation, the name of the NVME SSD can be composed of the system number of the NVME SSD, the number of namespaces, and the node identifier of the NUMA node to which the NVME SSD belongs. For example, the name of the NVME SSD is: Nvme0n1m0, where Nvme0 indicates that the system number of the NVME SSD is 0, n1 indicates that the NVME SSD includes 1 namespace, and m0 indicates that the node identifier of the NUMA node to which the NVME SSD belongs is 0.
[0068] Furthermore, after setting a name for the NVME SSD, a logical volume used by a virtual machine can be created by calling a command line encapsulated by SPDK, and the name of the created logical volume can carry the name of the NVME SSD that constitutes the logical volume, and the NUMA node to which the NVME SSD that constitutes the logical volume belongs is the NUMA node to which the logical volume belongs. It can be seen that the target NUMA node to which the logical volume belongs can be determined according to the name of the logical volume.
[0069] Specifically, determining the target NUMA node to which the logical volume used by the virtual machine belongs includes: obtaining the name of the logical volume used by the virtual machine, parsing the name, obtaining the node information of the NUMA node to which the solid-state drive (i.e., NVME SSD) constituting the logical volume belongs, and determining the NUMA node corresponding to the parsed node information as the target NUMA node to which the logical volume used by the virtual machine belongs. The node information of the NUMA node may be a node identifier of the NUMA node.
[0070] For example, assuming that the name of the logical volume is Nvme0n1m0-lv0, where lv0 represents the number 0 of the logical volume, the name of the logical volume is parsed, and the node information of the NUMA node to which the solid-state hard disk constituting the logical volume belongs is determined to be m0. In this way, it can be determined that the target NUMA node to which the logical volume belongs is the NUMA node with the node identifier m0.
[0071] S203. Determine the target resource from the group corresponding to the target NUMA node.
[0072] In an embodiment of the present application, in order to avoid mutual interference caused by different virtual machines calling the same resources, when determining the target resources from the group corresponding to the target NUMA node, the resources in the group corresponding to the target NUMA node that are not allocated to other virtual machines are first determined as alternative resources, and then the target resources are determined from the alternative resources.
[0073] Since the number of resources required by the virtual machine (hereinafter referred to as the first resource number) is known, when determining the target resource from the candidate resources, the target resource can be determined from the candidate resources according to the first resource number. However, in practice, the number of candidate resources (hereinafter referred to as the second resource number) is not necessarily greater than the first resource number, which means that it is possible that the candidate resources in the group corresponding to the target NUMA node are insufficient to meet the resource requirements of the virtual machine. Therefore, in the embodiment of the present application, it is proposed Figure 3 The example method is used to determine the target resource from the candidate resources.
[0074] like Figure 3 As shown, the following steps are included:
[0075] S301. Determine a first resource quantity to be allocated to a virtual machine, and determine a second resource quantity of candidate resources.
[0076] S302. Compare the first resource quantity and the second resource quantity. If the comparison shows that the second resource quantity is not less than the first resource quantity, execute S303. If the comparison shows that the second resource quantity is less than the first resource quantity, execute S304.
[0077] S303: Determine resources with a first resource quantity from candidate resources as target resources.
[0078] S304. Determine all candidate resources as target resources, and determine a third number of resources as target resources from resources in other groups that are not allocated to other virtual machines, where the third number of resources is the difference between the first number of resources and the second number of resources.
[0079] It is understandable that if the comparison shows that the second resource quantity is less than the first resource quantity, it means that the candidate resources are insufficient to meet the resource requirements of the virtual machine. At this time, in order to meet the resource requirements of the virtual machine, in addition to determining all the candidate resources as target resources, the target resources are also determined from the resources in other groups that are not allocated to other virtual machines. Preferably, when the resources in one other group can meet the resource requirements of the virtual machine, the resources of the third resource quantity are determined from the same group. Through this setting, the number of nodes across NUMA nodes can be reduced as much as possible when cross-NUMA node access cannot be completely avoided.
[0080] Specifically, as an embodiment, after comparing that the second resource quantity is smaller than the first resource quantity, the quantity of resources not allocated to other virtual machines in other groups can also be determined, and an alternative grouping in which the quantity of resources not allocated to other virtual machines is not less than the third resource quantity is selected; if the number of alternative groups is 1, resources with the third resource quantity are selected from the alternative grouping as target resources; if the number of alternative groups is greater than 1, any alternative grouping is selected, and resources with the third resource quantity are selected from any alternative grouping as target resources.
[0081] The virtual machine resource allocation method provided in the embodiment of the present application, when determining the target resources, gives priority to selecting resources that are not allocated to other virtual machines under the same NUMA node, thereby minimizing the occurrence of cross-NUMA node accesses, and also avoiding the mutual interference between different virtual machines caused by the same resource being called by different virtual machines, thereby reducing the IO performance loss caused by cross-NUMA node accesses, and improving the IO performance and stability of the virtual machine.
[0082] See also Figure 4 , is a schematic diagram of a virtual machine resource allocation device provided in an embodiment of the present application, such as Figure 4 As shown, the device may include:
[0083] An acquisition module 41 is used to acquire resource information of resources in a host machine where a virtual machine to be allocated resources is located, the host machine being a non-uniform memory access NUMA server, and the resource information at least includes node information of a NUMA node to which the resource belongs;
[0084] A resource determination module 42, configured to determine a target resource from the resources based on the resource information, wherein the target resource and the logical volume used by the virtual machine belong to the same NUMA node;
[0085] The resource binding module 43 is used to bind the target resource to the virtual machine to allocate the target resource to the virtual machine.
[0086] As an embodiment, the resource determination module 42 includes ( Figure 4Not shown):
[0087] A grouping submodule, used for grouping resources based on resource information, wherein resources belonging to the same NUMA node are grouped into the same group, and resources belonging to different NUMA nodes are grouped into different groups;
[0088] The target node determination submodule is used to determine the target NUMA node to which the logical volume used by the virtual machine belongs;
[0089] The resource determination submodule is used to determine the target resource from the group corresponding to the target NUMA node.
[0090] As an embodiment, the name of the logical volume carries the node information of the NUMA node to which the solid state drive constituting the logical volume belongs;
[0091] The target node determination submodule is specifically used for:
[0092] Get the name of the logical volume used by the virtual machine;
[0093] Parse the name to obtain the node information of the NUMA node to which the solid-state drive constituting the logical volume belongs;
[0094] The NUMA node corresponding to the node information obtained by parsing is determined as the target NUMA node to which the logical volume used by the virtual machine belongs.
[0095] As an embodiment, the resource determination submodule is specifically used for:
[0096] Determine the resources in the group corresponding to the target NUMA node that are not allocated to other virtual machines as candidate resources;
[0097] Determine the target resource from the candidate resource information.
[0098] As an embodiment, determining the target resource from the candidate resources includes:
[0099] Determining a first resource quantity to be allocated to the virtual machine, and determining a second resource quantity as an alternative resource;
[0100] comparing the first resource quantity to the second resource quantity;
[0101] If the comparison shows that the second resource quantity is not less than the first resource quantity, resources with the first resource quantity are determined from the candidate resources as target resources.
[0102] As an embodiment, the above device also includes:
[0103] If the comparison shows that the second resource quantity is less than the first resource quantity, all alternative resources are determined as target resources, and resources with a third resource quantity are determined as target resources from resources in other groups that are not allocated to other virtual machines, and the third resource quantity is the difference between the first resource quantity and the second resource quantity.
[0104] A resource allocation device provided in an embodiment of the present application obtains resource information of resources in a host machine where a virtual machine to be allocated resources is located, wherein the host machine is a non-uniform memory access NUMA server, and the resource information at least includes node information of the NUMA node to which the resource belongs, and determines a target resource from the resource based on the resource information, wherein the target resource and the logical volume used by the virtual machine belong to the same NUMA node, and binds the target resource to the virtual machine to allocate the target resource to the virtual machine. Since the target resource allocated to the virtual machine and the logical volume used by the virtual machine belong to the same NUMA node, the virtual machine accesses resources within the NUMA node to which its own logical volume belongs during operation, which avoids the phenomenon of virtual machines accessing across NUMA nodes during operation, and the target resource is a resource allocated to other virtual machines, which can also avoid the mutual interference between different virtual machines caused by the same resource being called by different virtual machines, thereby reducing the IO performance loss caused by cross-NUMA node access, while improving the IO performance and stability of the virtual machine.
[0105] This can improve the IO performance and stability of the virtual machine.
[0106] See also Figure 5 , Figure 5 It is a structural schematic diagram of an electronic device provided by another embodiment of the present application.
[0107] like Figure 5 As shown, the electronic device provided in this embodiment includes: at least one processor 501, a memory 502, at least one network interface 503 and other user interfaces 504. The various components in the electronic device 500 are coupled together through a bus system 505. It can be understood that the bus system 505 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 505 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 5 Various buses are labeled as bus system 505 .
[0108] The user interface 504 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).
[0109] It can be understood that the memory 502 in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DRRAM). The memory 502 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0110] In some implementations, the memory 502 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 5021 and a second application 5022 .
[0111] The operating system 5021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks. The second application 5022 includes various second application programs, such as a media player (Media Player), a browser (Browser), etc., for implementing various application services. The program for implementing the method of the embodiment of the present invention can be included in the second application 5022.
[0112] In the embodiment of the present invention, by calling the program or instruction stored in the memory 502, specifically, the program or instruction stored in the second application 5022, the processor 501 is used to execute the method steps provided by each method embodiment, for example, including:
[0113] Obtain resource information of resources in the host machine where the virtual machine to be allocated resources is located, the host machine is a non-uniform memory access NUMA server, and the resource information at least includes node information of the NUMA node to which the resources belong;
[0114] Based on the resource information, determine a target resource from the resources, wherein the target resource and a logical volume used by the virtual machine belong to the same NUMA node;
[0115] The target resource is bound to the virtual machine to allocate the target resource to the virtual machine.
[0116] The method disclosed in the above embodiment of the present invention can be applied to the processor 501, or implemented by the processor 501. The processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 501 or the instruction in the form of software. The above processor 501 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 502, and the processor 501 reads the information in the memory 502 and completes the steps of the above method in combination with its hardware.
[0117] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions of the present application, or a combination thereof.
[0118] For software implementation, the technology of this article can be implemented by a unit that performs the functions of this article. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0119] The embodiment of the present invention also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.
[0120] When one or more programs in the storage medium can be executed by one or more processors, the virtual machine resource allocation method executed on the electronic device side can be implemented.
[0121] The processor is used to execute the virtual machine resource allocation program stored in the memory to implement the following steps of the virtual machine resource allocation method executed on the electronic device side:
[0122] Obtain resource information of resources in the host machine where the virtual machine to be allocated resources is located, the host machine is a non-uniform memory access NUMA server, and the resource information at least includes node information of the NUMA node to which the resources belong;
[0123] Based on the resource information, determine a target resource from the resources, wherein the target resource and a logical volume used by the virtual machine belong to the same NUMA node;
[0124] The target resource is bound to the virtual machine to allocate the target resource to the virtual machine.
[0125] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0126] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0127] It should be noted that, in the description of this application, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" refers to at least two.
[0128] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0129] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0130] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0131] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0132] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0133] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0134] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A virtual machine resource allocation method, characterized in that: include: Obtain resource information of resources in a host machine where a virtual machine to which resources are to be allocated is located, the host machine being a non-uniform memory access NUMA server, the resource information including at least node information of a NUMA node to which the resources belong; Based on the resource information, determining a target resource from the resources, wherein the target resource and the logical volume used by the virtual machine belong to the same NUMA node; Binding the target resource to the virtual machine to allocate the target resource to the virtual machine; Determining the target resource from the resources based on the resource information includes: grouping the resources based on the resource information, wherein resources belonging to the same NUMA node are grouped into the same group, and resources belonging to different NUMA nodes are grouped into different groups; determining the target NUMA node to which the logical volume used by the virtual machine belongs; and determining the target resource from the group corresponding to the target NUMA node; The determining the target resource from the group corresponding to the target NUMA node includes: determining resources in the group corresponding to the target NUMA node that are not allocated to other virtual machines as candidate resources; and determining the target resource from the candidate resource information.
2. The method according to claim 1, characterized in that The name of the logical volume carries the node information of the NUMA node to which the solid-state hard disk constituting the logical volume belongs; The determining the target NUMA node to which the logical volume used by the virtual machine belongs includes: Obtain the name of the logical volume used by the virtual machine; Parsing the name to obtain node information of the NUMA node to which the solid state drive constituting the logical volume belongs; The NUMA node corresponding to the node information obtained by parsing is determined as the target NUMA node to which the logical volume used by the virtual machine belongs.
3. The method according to claim 1, characterized in that The determining of the target resource from the candidate resources comprises: Determining a first resource quantity to be allocated to the virtual machine, and determining a second resource quantity of the candidate resources; comparing the first resource quantity and the second resource quantity; If it is determined by comparison that the second resource quantity is not less than the first resource quantity, resources with the first resource quantity are determined from the candidate resources as target resources.
4. The method according to claim 3, characterized in that The method further comprises: If it is compared that the second resource quantity is smaller than the first resource quantity, all the alternative resources are determined as target resources, and from the resources in other groups that are not allocated to other virtual machines, resources with a third resource quantity are determined as the target resources, and the third resource quantity is the difference between the first resource quantity and the second resource quantity.
5. A virtual machine resource allocation device, characterized in that: include: An acquisition module is used to acquire resource information of resources in a host machine where a virtual machine to be allocated resources is located, wherein the host machine is a non-uniform memory access NUMA server, and the resource information at least includes node information of a NUMA node to which the resource belongs; A resource determination module, configured to determine a target resource from the resources based on the resource information, wherein the target resource and the logical volume used by the virtual machine belong to the same NUMA node; A resource binding module, used to bind the target resource to the virtual machine to allocate the target resource to the virtual machine; The resource determination module comprises: A grouping submodule, configured to group the resources based on the resource information, wherein resources belonging to the same NUMA node are grouped into the same group, and resources belonging to different NUMA nodes are grouped into different groups; A target node determination submodule, used to determine a target NUMA node to which the logical volume used by the virtual machine belongs; The resource determination submodule is used to determine the target resource from the group corresponding to the target NUMA node, including: determining the resources in the group corresponding to the target NUMA node that are not allocated to other virtual machines as candidate resources; and determining the target resource from the candidate resource information.
6. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a virtual machine resource allocation program stored in the memory to implement the virtual machine resource allocation method according to any one of claims 1 to 4.
7. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the virtual machine resource allocation method described in any one of claims 1-4.
