A method, system, and device for hot expansion of virtual machine memory on a cloud platform.
By acquiring NUMA node information of virtual machines and physical hosts, and employing flexible memory allocation methods and resource locking mechanisms, the problem of unsuccessful allocation during hot memory expansion was solved, improving the success rate of expansion and memory access performance, and ensuring business continuity.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JINAN INSPUR DATA TECH CO LTD
- Filing Date
- 2022-08-29
- Publication Date
- 2026-05-26
AI Technical Summary
Existing hot-scaling methods for memory are prone to allocation failures, especially when the remaining memory of NUMA nodes on the physical host is uneven, which may lead to memory over-allocation and affect business stability.
By obtaining the number of virtual machine NUMA nodes and the remaining memory capacity of each NUMA node on the physical host, a flexible memory allocation method is adopted. Different expansion capacities are configured for virtual machine NUMA nodes according to preset expansion rules, and resource locks are created after receiving a request to ensure the smooth completion of memory allocation.
It improves the success rate of hot memory expansion, ensures memory access performance, avoids memory over-allocation issues, and ensures business continuity and stability.
Smart Images

Figure CN115344353B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud platform resource configuration technology, and in particular to a method, system and device for hot expansion of virtual machine memory in a cloud platform. Background Technology
[0002] In virtualization scenarios, hot memory expansion can increase the virtual machine's running memory without interrupting virtual machine services, which can largely ensure business continuity.
[0003] Hot-scaling memory depends on the number of NUMA (Non-Uniform Memory Access Architecture) nodes in the virtual machine, the current remaining memory on the physical machine, and the remaining memory capacity on each NUMA node. Without granular memory management, hot-scaling may lead to memory over-allocation on the physical machine, posing a threat to business stability. For example, if the virtual machine to be hot-scaled has two NUMA nodes, and the physical host also has two NUMA nodes, the current publicly available implementations would hot-scale 64GB of memory evenly across the two NUMA nodes (i.e., 32GB of memory would be hot-scaled onto each NUMA node).
[0004] Since the remaining memory of each NUMA Node on the physical host is usually not the same, the method of evenly allocating the memory to be increased will lead to allocation failure when there is not much physical memory left. Summary of the Invention
[0005] This invention provides a method, system, and device for hot-expanding virtual machine memory on a cloud platform, which solves the problem that existing hot-expanding memory methods are prone to allocation failures.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] The first aspect of this invention provides a method for hot-expanding virtual machine memory on a cloud platform, the method comprising the following steps:
[0008] In response to a virtual machine's hot memory expansion request, obtain the memory expansion capacity M and the current number of NUMA nodes N in the request.
[0009] Calculate the remaining memory capacity of each NUMA node on the physical host and the remaining memory capacity of all NUMA nodes, and F. Each NUMA node is the physical host NUMA node corresponding to the current virtual machine NUMA node, and all NUMA nodes are composed of each NUMA node.
[0010] Based on the preset expansion rules, as well as the memory to be expanded M, the number of virtual machine NUMA nodes N, and the remaining memory capacity F of all NUMA nodes, the expansion capacity is allocated to the current virtual machine memory.
[0011] Furthermore, after obtaining a memory expansion request, the method further includes a step of creating a resource lock on the physical host corresponding to the current virtual machine before responding to the memory expansion request, and releasing the resource lock after allocating expansion capacity to the current virtual machine's memory.
[0012] Furthermore, the expansion rules are specifically as follows:
[0013] If the remaining memory capacity of all NUMA nodes and F are less than the memory capacity to be expanded, then the memory allocation fails.
[0014] Determine whether the remaining memory capacity of each NUMA node on the physical host is greater than the value of M / N;
[0015] If so, then allocate M / N memory on each NUMA node of the virtual machine;
[0016] If not, the ratio of the remaining capacity of each NUMA node on the physical host to the remaining memory capacity of all NUMA nodes and F is used as the weight to allocate memory to the corresponding virtual machine NUMA node.
[0017] Furthermore, the method also includes storing the memory capacity of the virtual machine NUMA node before expansion and the expanded capacity in the first database and the second database, respectively.
[0018] Furthermore, during the hot expansion of memory, the data difference between the same NUMA node in the second database and the first database is used as the expansion capacity.
[0019] A second aspect of the present invention provides a system for hot-expanding virtual machine memory on a cloud platform, the system comprising:
[0020] The request processing unit responds to the virtual machine's hot memory expansion request by obtaining the memory expansion capacity M and the current number of NUMA nodes N in the request.
[0021] The information acquisition unit calculates the remaining memory capacity of each NUMA node on the physical host and the remaining memory capacity of all NUMA nodes and F, respectively. Each NUMA node is the physical host NUMA node corresponding to the current virtual machine NUMA node, and all NUMA nodes are composed of each NUMA node.
[0022] The expansion analysis unit allocates expansion capacity to the current virtual machine memory according to preset expansion rules, as well as the memory to be expanded capacity M, the number of virtual machine NUMA nodes N, and the remaining memory capacity F of all NUMA nodes.
[0023] Furthermore, the system also includes a resource processing unit, which is connected to the request processing unit and the expansion analysis unit respectively. Upon receiving a memory expansion request, the resource processing unit is triggered to create a resource lock for the physical host corresponding to the current virtual machine, and releases the resource lock after allocating expansion capacity to the current virtual machine's memory.
[0024] Furthermore, the capacity expansion analysis unit includes:
[0025] In the pre-analysis subunit, if the remaining memory capacity of all NUMA nodes and F are less than the memory expansion capacity, then the memory allocation fails.
[0026] The judgment subunit is used to determine whether the remaining memory capacity of each NUMA node of the physical host is greater than the value of M / N;
[0027] The first allocation subunit is used to allocate M / N memory on each NUMA node of the virtual machine when the judgment result is yes;
[0028] The second allocation subunit is used to allocate memory to the corresponding virtual machine NUMA node by using the ratio of the remaining capacity of each NUMA node of the physical host to the remaining memory capacity of all NUMA nodes and F as the weight when the judgment result is negative.
[0029] A third aspect of the present invention provides a device for hot expansion of virtual machine memory in a cloud platform, including a virtual machine and a physical host corresponding to the virtual machine. NUMA nodes are respectively set on the virtual machine and the physical host, and each virtual machine NUMA node corresponds to a physical host NUMA node. The device also includes the system described above, which is deployed on the physical host. When the memory of the virtual machine NUMA node needs to be expanded, the physical host runs the system to perform the expansion operation.
[0030] A third aspect of the present invention provides a computer storage medium storing computer instructions, which, when executed on the system, cause the system to perform the steps of the method.
[0031] The apparatus for hot expansion of cloud platform virtual machine memory described in the second aspect of the present invention and the device for hot expansion of cloud platform virtual machine memory described in the third aspect can both implement the methods in the first aspect and various implementations of the first aspect, and achieve the same effect.
[0032] The effects described in the invention are merely those of the embodiments, and not all the effects of the invention. One of the above technical solutions has the following advantages or beneficial effects:
[0033] 1. Upon receiving a memory expansion request from a virtual machine, this invention configures different expansion capacities for the virtual machine's NUMA nodes based on the virtual machine's expansion capacity, the number of NUMA nodes, the remaining memory capacity of each NUMA node on the physical host, and the remaining memory capacity of all NUMA nodes. It adopts a flexible memory allocation method, while ensuring the success rate of hot memory expansion and maximizing memory access performance.
[0034] 2. Upon receiving a content hot expansion request, a resource lock is created for the physical host to resolve the disconnect between memory checks and the actual hot-plugging process. In concurrent scenarios, there may be a situation where there is sufficient memory during the check, but memory over-allocation occurs after hot-plugging. This further ensures the smooth completion of memory allocation. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 This is a flowchart illustrating an embodiment of the method described in this invention;
[0037] Figure 2 This is a flowchart illustrating one implementation of the method described in this invention;
[0038] Figure 3 This is a schematic diagram of the structure of an embodiment of the system described in this invention;
[0039] Figure 4 This is a schematic diagram of the structure of an embodiment of the device described in this invention. Detailed Implementation
[0040] To clearly illustrate the technical features of this solution, the invention will be described in detail below through specific embodiments and in conjunction with the accompanying drawings. The following disclosure provides many different embodiments or examples for implementing different structures of the invention. To simplify the disclosure of the invention, components and arrangements of specific examples are described below. Furthermore, reference numerals and / or letters may be repeated in different examples. This repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed. It should be noted that the components illustrated in the drawings are not necessarily drawn to scale. Descriptions of well-known components, processing techniques, and processes are omitted in this invention to avoid unnecessarily limiting the invention.
[0041] like Figure 1 As shown, this embodiment of the invention provides a method for hot-expanding virtual machine memory on a cloud platform, including the following steps:
[0042] S1, in response to the virtual machine's hot memory expansion request, obtain the memory expansion capacity M and the current number of NUMA nodes N in the request;
[0043] S2, calculate the remaining memory capacity of each NUMA node on the physical host and the remaining memory capacity of all NUMA nodes and F respectively, where each NUMA node is the physical host NUMA node corresponding to the current virtual machine NUMA node, and all NUMA nodes are composed of each NUMA node;
[0044] S3. Based on the preset expansion rules, as well as the memory to be expanded M, the number of virtual machine NUMA nodes N, and the remaining memory capacity F of all NUMA nodes, allocate expansion capacity to the current virtual machine memory.
[0045] In one implementation of the method of the present invention, in step S1, after obtaining the memory expansion request and before responding to the memory expansion request, the method further includes creating a resource lock on the physical host corresponding to the current virtual machine, and releasing the resource lock after allocating expansion capacity to the current virtual machine memory in step S3.
[0046] Before step S1, the process includes checking and allocating virtual machine memory: before hot expansion, the memory status of each NUMANode of the virtual machine is stored in the first database migration_context.old_numa_topology; it also includes initializing temporary specifications: the difference between the target specification memory and the original specification memory is denoted as M, and the current number of NUMA nodes of the virtual machine is denoted as N.
[0047] In step S3, the expansion rule is specifically as follows:
[0048] If the physical host has less than M of remaining memory, the memory allocation will fail.
[0049] If the remaining memory capacity of all NUMA nodes and F are less than the memory capacity to be expanded, then the memory allocation fails.
[0050] Determine whether the remaining memory capacity of each NUMA node on the physical host is greater than the value of M / N;
[0051] If so, then allocate M / N memory on each NUMA node of the virtual machine;
[0052] If not, the ratio of the remaining capacity of each NUMA node on the physical host to the remaining memory capacity of all NUMA nodes and F is used as the weight to allocate memory to the corresponding virtual machine NUMA node.
[0053] The memory allocation details are recorded in the second database, migration_context.new_numa_topology.
[0054] When performing a hot memory expansion operation, the data difference between the same NUMA node in the second database and the first database is used as the expansion capacity.
[0055] like Figure 2 As shown, the process involves locking physical host resources, saving the initial resource state of the virtual machine, and initializing temporary specifications, including memory specifications and the current number of NUMA nodes N for the virtual machine. The difference between the target memory specification and the original memory specification is denoted as M. Upon receiving a content hot-expansion request, the process first checks if the remaining memory of the physical host is less than M. If so, the allocation fails. If not, it checks if the sum of the memory of the physical host NUMA nodes corresponding to the virtual NUMA nodes in the hot-expansion request is less than M. If so, the allocation fails. If not, it checks if the remaining memory of the corresponding host NUMA nodes is greater than M / N. If so, M / N memory is allocated to each virtual machine NUMA node. Otherwise, hot-expansion memory is allocated according to the weight of the remaining memory of the physical host NUMA nodes relative to the total remaining memory. After allocation and configuration, the allocated memory in the migration_context of the migration chain is updated, the memory usage in the compute_nodes table of the compute_nodes table of the compute_nodes table is updated, and the resource lock is released, ending the memory hot-expansion process.
[0056] like Figure 3 As shown in the figure, this embodiment of the invention also provides a system for hot expansion of virtual machine memory on a cloud platform. The system includes a request processing unit 1, an information acquisition unit 2, an expansion analysis unit 3, and a resource processing unit 4.
[0057] Request processing unit 1 responds to the virtual machine's hot memory expansion request by obtaining the memory expansion capacity M and the number of NUMA nodes N of the current virtual machine from the request; information acquisition unit 2 calculates the remaining memory capacity of each NUMA node on the physical host and the sum of the remaining memory capacities F of all NUMA nodes, where each NUMA node is the physical host NUMA node corresponding to the current virtual machine NUMA node, and all NUMA nodes are composed of each NUMA node; expansion analysis unit 3 allocates expansion capacity to the current virtual machine memory according to preset expansion rules, as well as the memory expansion capacity M, the number of virtual machine NUMA nodes N, and the sum of the remaining memory capacities F of all NUMA nodes.
[0058] The resource processing unit 4 is connected to the request processing unit and the expansion analysis unit respectively. After receiving a memory expansion request, the resource processing unit is triggered to create a resource lock for the physical host corresponding to the current virtual machine, and releases the resource lock after allocating expansion capacity to the current virtual machine memory.
[0059] The expansion analysis unit 4 includes a pre-analysis subunit, a judgment subunit, a first allocation subunit, and a second allocation subunit:
[0060] The pre-analysis subunit analyzes whether the remaining memory capacity and F of all NUMA nodes are less than the memory expansion capacity; if so, the memory allocation fails.
[0061] The judgment subunit is used to determine whether the remaining memory capacity of each NUMA node of the physical host is greater than the value of M / N;
[0062] The first allocation subunit is used to allocate M / N memory on each NUMA node of the virtual machine when the judgment result is yes;
[0063] The second allocation subunit is used to allocate memory to the corresponding virtual machine NUMA node when the judgment result is negative, by using the ratio of the remaining capacity of each NUMA node of the physical host to the remaining memory capacity of all NUMA nodes and F as the weight.
[0064] like Figure 4 As shown in the figure, this embodiment of the invention also provides a device for hot expansion of virtual machine memory in a cloud platform, including a virtual machine and a physical host corresponding to the virtual machine. NUMA nodes are respectively set on the virtual machine and the physical host, and each virtual machine NUMA node corresponds to a physical host NUMA node. The device also includes the system described in the above embodiment. The system is deployed on the physical host. When the memory of the virtual machine NUMA node needs to be expanded, the physical host runs the system to perform the expansion operation.
[0065] This invention also provides a computer storage medium storing computer instructions, which, when executed on a system, cause the system to perform the steps of the method.
[0066] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A method for hot-expanding virtual machine memory on a cloud platform, characterized in that, The method includes the following steps: In response to a virtual machine's hot memory expansion request, obtain the memory expansion capacity M and the current number of NUMA nodes N in the request. Calculate the remaining memory capacity of each NUMA node on the physical host and the remaining memory capacity of all NUMA nodes, and F. Each NUMA node is the physical host NUMA node corresponding to the current virtual machine NUMA node, and all NUMA nodes are composed of each NUMA node. Based on the preset expansion rules, as well as the memory to be expanded M, the number of virtual machine NUMA nodes N, and the remaining memory capacity F of all NUMA nodes, the expansion capacity is allocated to the current virtual machine memory. The expansion rules are as follows: If the remaining memory capacity of all NUMA nodes and F are less than the memory capacity to be expanded, then the memory allocation fails. Determine whether the remaining memory capacity of each NUMA node on the physical host is greater than the value of M / N; If so, then allocate M / N memory on each NUMA node of the virtual machine; If not, the ratio of the remaining capacity of each NUMA node on the physical host to the remaining memory capacity of all NUMA nodes and F is used as the weight to allocate memory to the corresponding virtual machine NUMA node.
2. The method for hot-expanding virtual machine memory on a cloud platform according to claim 1, characterized in that, After receiving a memory expansion request, the method further includes a step of creating a resource lock on the physical host corresponding to the current virtual machine before responding to the memory expansion request, and releasing the resource lock after allocating expansion capacity to the current virtual machine's memory.
3. The method for hot-expanding virtual machine memory on a cloud platform according to claim 1, characterized in that, The method also includes storing the memory capacity of the virtual machine NUMA node before and after expansion in the first database and the second database, respectively.
4. The method for hot-expanding virtual machine memory on a cloud platform according to claim 3, characterized in that, When performing a hot memory expansion operation, the data difference between the same NUMA node in the second database and the first database is used as the expansion capacity.
5. A system for hot-expanding virtual machine memory on a cloud platform, characterized in that, The system includes: The request processing unit responds to the virtual machine's hot memory expansion request by obtaining the memory expansion capacity M and the current number of NUMA nodes N in the request. The information acquisition unit calculates the remaining memory capacity of each NUMA node on the physical host and the remaining memory capacity of all NUMA nodes and F, respectively. Each NUMA node is the physical host NUMA node corresponding to the current virtual machine NUMA node, and all NUMA nodes are composed of each NUMA node. The expansion analysis unit allocates expansion capacity to the current virtual machine memory according to the preset expansion rules, as well as the memory to be expanded capacity M, the number of virtual machine NUMA nodes N, and the remaining memory capacity F of all NUMA nodes. The capacity expansion analysis unit includes: The pre-analysis subunit is used to analyze whether the remaining memory capacity and F of all NUMA nodes are less than the memory expansion capacity; if so, the memory allocation fails. The judgment subunit is used to determine whether the remaining memory capacity of each NUMA node of the physical host is greater than the value of M / N; The first allocation subunit is used to allocate M / N memory on each NUMA node of the virtual machine when the judgment result is yes; The second allocation subunit is used to allocate memory to the corresponding virtual machine NUMA node by using the ratio of the remaining capacity of each NUMA node of the physical host to the remaining memory capacity of all NUMA nodes and F as the weight when the judgment result is negative.
6. The system for hot-expanding virtual machine memory on a cloud platform according to claim 5, characterized in that, The system also includes a resource processing unit, which is connected to the request processing unit and the expansion analysis unit. Upon receiving a memory expansion request, the resource processing unit is triggered to create a resource lock for the physical host corresponding to the current virtual machine, and releases the resource lock after allocating expansion capacity to the current virtual machine's memory.
7. A device for hot-scaling virtual machine memory in a cloud platform, comprising a virtual machine and a physical host corresponding to the virtual machine, wherein NUMA nodes are respectively configured on the virtual machine and the physical host, and each virtual machine NUMA node corresponds to one physical host NUMA node, characterized in that, The device also includes the system according to any one of claims 5-6, wherein the system is deployed on the physical host and the physical host runs the system to perform the expansion operation when the memory of the virtual machine NUMA node needs to be expanded.
8. A computer storage medium storing computer instructions, characterized in that, When the computer instructions are executed on the system of any one of claims 5-6, the system causes the system to perform the steps of the method of any one of claims 1-4.