A memory hot shrinkage method, device, equipment and readable storage medium

Under the NUMA architecture, the problem of memory allocation chaos and crashes during the hot shrinking of virtual machine memory is solved by smoothly migrating virtual machine processes and binding vCPUs, thus achieving stable memory resource adjustment.

CN115113986BActive Publication Date: 2025-11-21LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210891148.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-27
Publication Date
2025-11-21
Estimated Expiration
2042-07-27

AI Technical Summary

Technical Problem

The hot shrinking of virtual machine memory can easily lead to problems such as memory allocation chaos and virtual machine crashes, which are difficult to solve effectively with existing technologies.

Method used

By using memory balloon devices in a NUMA architecture to smoothly migrate virtual machine processes to some NUMA nodes before expanding memory resources inside the virtual machine, memory is freed up for balloon expansion, avoiding interference with processes, and memory balloon expansion is performed after binding vCPUs.

Benefits of technology

It achieves smooth memory resource adjustment without process interference during virtual machine memory shrinkage, avoiding memory allocation chaos and virtual machine crash risk, and ensuring system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115113986B_ABST
    Figure CN115113986B_ABST
Patent Text Reader

Abstract

The application discloses a memory hot shrinkage method, device and equipment and a readable storage medium. The method comprises the following steps: receiving and analyzing a memory hot shrinkage request, determining a corresponding shrinkage size of a virtual machine; determining the number of shrinkage nodes by using the shrinkage size; selecting the shrinkage nodes from the numa nodes of the virtual machine; binding the vCPU bound with the shrinkage nodes with the failed numa nodes; and binding the vCPU, inflating the memory balloon in the virtual machine. In the application, by means of the feature that the virtual machine accesses the proximal memory, the processes in the virtual machine can be smoothly migrated to part of the numa nodes before the memory balloon is inflated, so that the corresponding memory of another part of the numa nodes is emptied, the inflation of the memory balloon does not interfere with the processes in the virtual machine, the memory allocation in the virtual machine is not disordered, and a large number of memory recycling and swapping processes in the virtual machine can be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer application, in particular to a memory hot shrinkage method, device and equipment and readable storage medium. BACKGROUND

[0002] Compared with the traditional physical cluster, the virtual cluster has great advantages in the scalability of physical resources. Specifically, due to the design limitations of machines and devices, the resource scalability of the physical cluster is extremely limited, and it is impossible to realize online resource scaling. Therefore, in a variable cluster environment, the virtual cluster is more widely used due to its flexible resource scalability.

[0003] At present, the virtual cluster manages resources, including but not limited to hot modification of virtual machine CPU resources, hot modification of memory resources, limitation and reservation of CPU and memory resources, and disk hot expansion. In the virtualization scenario, memory hot shrinkage is a high-risk function, which applies a technology called memory balloon. That is, a memory balloon device is installed in the virtual machine, which connects the virtual machine memory resources and the host memory resources. When the virtual machine memory specification is large but the utilization rate is low, the host can expand in the virtual machine through the memory balloon to absorb the virtual machine memory and release it for the host to use, or can shrink in the virtual machine through the memory balloon to allocate the host memory to the virtual machine again. The memory hot shrinkage technology uses the expansion principle of the memory balloon to achieve the purpose of online reduction of memory.

[0004] The expansion process is actually that the memory balloon device continuously applies free memory in the virtual machine until the host memory demand is met. However, this method of directly applying free memory may cause confusion in the memory allocation of the virtual machine, and the memory balloon will also set the maximum memory specification of the virtual machine after applying the memory, resulting in a large number of memory recycling and swapping processes in the virtual machine, which may cause the processes in the virtual machine to be interrupted or even the virtual machine to be down.

[0005] In summary, how to effectively solve the problem of virtual machine memory hot shrinkage is a technical problem that needs to be solved by the technical personnel in the field at present. SUMMARY

[0006] The purpose of the present application is to provide a memory hot shrinkage method, device and equipment and readable storage medium to solve the problem of virtual machine memory hot shrinkage.

[0007] To solve the above technical problems, the present application provides the following technical solutions:

[0008] A memory hot shrinkage method, comprising:

[0009] connect

[0010] receiving and analyzing the memory hot shrinkage request, determining the shrinkage size corresponding to the virtual machine;

[0011] determining the number of shrinkage nodes by using the shrinkage size;

[0012] selecting the shrinkage nodes from the NUMA nodes of the virtual machine;

[0013] binding the vCPUs bound to the shrinkage nodes with the failed NUMA nodes;

[0014] after binding the vCPUs, inflating the memory balloon inside the virtual machine.

[0015] Preferably, before inflating the memory balloon inside the virtual machine, the method further comprises:

[0016] if the total memory of the selected shrinkage nodes is less than the shrinkage size, limiting the memory of the threads inside the virtual machine.

[0017] Preferably, the method of determining the number of shrinkage nodes by using the shrinkage size comprises:

[0018] obtaining the memory size of the NUMA nodes;

[0019] determining the number of shrinkage nodes by using the shrinkage size and the memory size; wherein the number of shrinkage nodes is less than the number of NUMA nodes.

[0020] Preferably, the method of selecting the shrinkage nodes from the NUMA nodes of the virtual machine comprises:

[0021] obtaining the occupied memory of each NUMA node;

[0022] determining the NUMA node with the smallest occupied memory as the shrinkage node, until the corresponding number of shrinkage nodes is selected.

[0023] Preferably, after inflating the memory balloon inside the virtual machine, the method further comprises:

[0024] obtaining the actual shrinkage size;

[0025] if the actual shrinkage size is equal to the shrinkage size, feeding back the shrinkage end information.

[0026] Preferably, the method further comprises:

[0027] if the actual shrinkage size is less than the shrinkage size, and the number of failed NUMA nodes is greater than 1, continue to select the shrinkage nodes from the failed NUMA nodes;

[0028] bind the vCPU bound by the shrink node with the fallen-out numa node;

[0029] inflate the memory balloon inside the virtual machine after the vCPU is bound.

[0030] Preferably, further comprising:

[0031] if the actual shrink size is smaller than the shrink size and the number of fallen-out numa nodes is 1, then memory limit the process inside the virtual machine;

[0032] inflate the memory balloon inside the virtual machine after the memory limit is completed.

[0033] A memory hot shrink device, comprising:

[0034] a shrink size determination module configured to receive and parse a memory hot shrink request and determine a shrink size corresponding to a virtual machine;

[0035] a shrink node number determination module configured to determine the number of shrink nodes by using the shrink size;

[0036] a shrink node determination module configured to select the shrink nodes from the numa nodes of the virtual machine;

[0037] a vCPU binding module configured to bind the vCPU bound by the shrink node with the fallen-out numa node;

[0038] a hot shrink module configured to inflate the memory balloon inside the virtual machine after the vCPU is bound.

[0039] An electronic device, comprising:

[0040] a memory configured to store a computer program;

[0041] a processor configured to implement the steps of the memory hot shrink method when executing the computer program.

[0042] A readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the steps of the memory hot shrink method.

[0043] By using the method provided in the embodiments of the present application, a memory hot shrink request is received and parsed, a shrink size corresponding to a virtual machine is determined, the number of shrink nodes is determined by using the shrink size, the shrink nodes are selected from the numa nodes of the virtual machine, the vCPU bound by the shrink node is bound with the fallen-out numa node, and the memory balloon is inflated inside the virtual machine after the vCPU is bound.

[0044] In a non-uniform memory access (NUMA) mechanism, the memory access time depends on the memory location of the processor. Under the NUMA mechanism, the processor accesses the local memory faster than the non-local memory. In the present application, by means of the feature that the virtual machine numa accesses the proximal memory, the processes inside the virtual machine can be smoothly migrated to part of the numa nodes before the memory balloon is inflated, so as to vacate the memory corresponding to another part of the numa nodes, so that the memory balloon inflation does not interfere with the processes inside the virtual machine. Specifically, after receiving the memory hot shrinkage request and determining the shrinkage size corresponding to the virtual machine through analysis, the shrinkage size can be used to determine the number of shrinkage nodes. Then, the shrinkage nodes are selected from the numa nodes of the virtual machine, and the vCPU bound to the shrinkage nodes is bound to the failed numa nodes. In this way, the threads in the shrinkage nodes can be smoothly transitioned to the failed numa nodes, and the memory of the shrinkage nodes can be idle to provide the memory balloon for inflation. That is, after the vCPU is bound, the memory balloon can be inflated inside the virtual machine. Since the memory is idle in advance, the memory balloon inflation will not interfere with the processes of the virtual machine, nor will it cause the memory allocation inside the virtual machine to be chaotic, and it can also avoid a large number of memory recycling and swapping processes inside the virtual machine.

[0045] Correspondingly, the embodiments of the present application also provide a memory hot shrinkage device, equipment and a readable storage medium corresponding to the above-mentioned memory hot shrinkage method, which have the above-mentioned technical effects, which will not be described here. BRIEF DESCRIPTION OF DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the embodiments or the related art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0047] Figure 1 The implementation flowchart of the memory hot shrinkage method in the embodiments of the present application;

[0048] Figure 2 The structure schematic diagram of the memory hot shrinkage device in the embodiments of the present application;

[0049] Figure 3 The structure schematic diagram of the electronic equipment in the embodiments of the present application;

[0050] Figure 4 The specific structure schematic diagram of the electronic equipment in the embodiments of the present application. DETAILED DESCRIPTION

[0051] For those skilled in the technical field, the present application is better understood, the following will be further described in detail in conjunction with the drawings and specific embodiments. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of the present application.

[0052] Please refer to Figure 1 , Figure 1 The flow chart of one of the memory hot shrinkage methods in the embodiments of the present application, the method comprises the following steps:

[0053] S101, receiving and analyzing the memory hot shrinkage request, determining the corresponding shrinkage size of the virtual machine.

[0054] Memory hot shrinkage request, that is, requesting to shrink the memory of the virtual machine in the running state, so as to increase the available memory of the physical host.

[0055] Specifically, the user can issue a memory hot shrinkage instruction or confirm the memory hot shrinkage through a graphical operation interface, so that the memory hot shrinkage request can be received.

[0056] After receiving the memory hot shrinkage request, the corresponding memory size of the virtual machine that needs to be shrunk can be determined. This size is referred to as shrinkage size in this paper.

[0057] S102, using the shrinkage size to determine the number of shrinkage nodes.

[0058] In the embodiments of the present application, the numa nodes that need to contribute to the memory hot shrinkage are referred to as shrinkage nodes.

[0059] If the virtual machine has the demand for hot shrinkage, at least two numa nodes are configured for the virtual machine before starting, the number of numa nodes can be consistent with the number of numa nodes of the host, and the number of vCPUs and the size of memory of the virtual machine are evenly distributed in each numa node, so as to correspond to the numa architecture of the physical environment. The memory size of the shrinkage node is accumulated to meet the shrinkage size. Numa node is at least bound to one vCPU and one memory. Among them, vCPU, that is, virtual processor, is the CPU in the virtual machine, not physical CPU.

[0060] In one specific embodiment of the present application, step S102 uses the shrinkage size to determine the number of shrinkage nodes, comprising:

[0061] Step one, obtaining the memory size of the numa node;

[0062] Step two, determine the number of shrink nodes by using the shrink size and the memory size; wherein the number of shrink nodes is less than the number of numa nodes.

[0063] For the convenience of description, the above two steps are combined for description.

[0064] Since the memory size and the number of vCPUs of the numa nodes have been configured before booting, after the shrink size is determined, the number of shrink nodes can be determined directly according to the shrink size. Specifically, the number of shrink nodes is the ratio of the shrink size to the memory size of the numa nodes, and when the remainder cannot be divided, the remainder can be rounded up. It should be noted that the number of shrink nodes should be less than the number of numa nodes. That is, at least one numa node needs to be reserved for the vCPUs of the virtual machine. For example, the virtual machine has 4 numa nodes, each of which is allocated 2G of memory, and if the shrink size is 4G of memory, the number of shrink nodes is determined to be 2; if the shrink size is 6G of memory, the number of shrink nodes is determined to be 3; and if the shrink size is greater than 6G, the number of shrink nodes is determined to be 3.

[0065] S103, select the shrink nodes from the numa nodes of the virtual machine.

[0066] After the number of shrink nodes is determined, the shrink nodes can be selected from the numa nodes of the virtual machine. It should be noted that in this embodiment, the shrink nodes can be selected by a random selection method; or a selection condition such as memory occupancy rate or number of running threads can be set to select the numa nodes that meet the selection condition as the shrink nodes. That is, in this embodiment, how to select the shrink nodes is not limited.

[0067] In one specific embodiment of the present application, step S103 selects the shrink nodes from the numa nodes of the virtual machine, including:

[0068] Step one, obtain the occupied memory of each numa node;

[0069] Step two, determine the numa node with the smallest occupied memory as the shrink node, until the corresponding number of shrink nodes are selected.

[0070] For the convenience of description, the above two steps are combined for description.

[0071] The occupied memory size of each numa node can be monitored inside the virtual machine, and then the numa nodes are sorted based on the occupied memory, and then the corresponding number of shrink nodes are selected from the side with the smallest occupied memory.

[0072] Of course, in actual application, the range of the virtual machine memory that can be scaled down can also be calculated according to the occupied memory of each numa node, and the range is fed back to the user, so that the user can decide the specific size of the scaling down.

[0073] S104, bind the vCPU bound by the scaling-down node to the failed numa node.

[0074] For the sake of distinction, the numa node selected to share memory is referred to as the scaling-down node, and the numa node not selected is referred to as the failed numa node in this application.

[0075] After the scaling-down node is selected, the vCPU bound by the scaling-down node can be bound to the failed numa node. That is, the vCPU originally bound to the scaling-down node is unbound, and the vCPU is bound to the failed numa node. For example, the numa node is originally bound to vCPU1, and when it is determined that the numa node is the scaling-down node, vCPU1 can be bound to the failed numa node.

[0076] S105, after the vCPU is bound, inflate the memory balloon inside the virtual machine.

[0077] After the vCPU is bound, the memory allocated to the scaling-down node is idle. At this time, the memory balloon is inflated inside the virtual machine, and the idle memory is provided for the memory balloon to inflate, thereby reducing the interference to the threads inside the virtual machine.

[0078] In a specific embodiment of the present application, inflating the memory balloon inside the virtual machine includes continuously applying free memory inside the virtual machine using a memory balloon device until the scaling size is reached. Specifically, a memory balloon device can be installed inside the virtual machine to connect the virtual machine memory resources and the host memory resources. When the virtual machine memory specification is large but the usage rate is low, the host can inflate inside the virtual machine through the memory balloon, thereby absorbing the virtual machine memory and releasing it for use by the host. When the vCPU of the scaling-down node is bound to the failed numa node, the memory of the scaling-down node is idle at this time, which can be directly applied by the memory balloon device until the inflation amount of the memory balloon reaches the scaling size. The virtual machine memory hot scaling can be completed, that is, the memory hot scaling request is completed.

[0079] By applying the method provided in the embodiments of the present application, the memory hot scaling request is received and parsed, the scaling size corresponding to the virtual machine is determined, the number of scaling-down nodes is determined using the scaling size, the scaling-down nodes are selected from the numa nodes of the virtual machine, the vCPU bound by the scaling-down node is bound to the failed numa node, and the memory balloon is inflated inside the virtual machine after the vCPU is bound.

[0080] In a non-uniform memory access (NUMA) mechanism, the memory access time depends on the memory location of the processor. Under the NUMA mechanism, the processor accesses the local memory faster than the non-local memory. In the present application, by means of the feature that the virtual machine numa accesses the proximal memory, the processes inside the virtual machine can be smoothly migrated to part of the numa nodes before the memory balloon is inflated, so as to vacate the memory corresponding to another part of the numa nodes, so that the memory balloon inflation does not interfere with the processes inside the virtual machine. Specifically, after receiving the memory hot shrinkage request and determining the shrinkage size corresponding to the virtual machine through analysis, the shrinkage size can be used to determine the number of shrinkage nodes. Then, the shrinkage nodes are selected from the numa nodes of the virtual machine, and the vCPU bound to the shrinkage nodes is bound to the failed numa nodes. In this way, the threads in the shrinkage nodes can be smoothly transitioned to the failed numa nodes, and the memory of the shrinkage nodes can be idle to provide the memory balloon for inflation. That is, after the vCPU is bound, the memory balloon can be inflated inside the virtual machine. Since the memory is idle in advance, the memory balloon inflation will not interfere with the processes of the virtual machine, nor will it cause the memory allocation inside the virtual machine to be chaotic, and it can also avoid a large number of memory recycling and swapping processes inside the virtual machine.

[0081] It should be noted that based on the above embodiments, the present application embodiments also provide corresponding improvement schemes. The preferred / modified embodiments involve the same steps or corresponding steps between the above embodiments, which can be mutually referred to, and the corresponding beneficial effects can also be mutually referred to. In the preferred / modified embodiments herein, they will not be described one by one.

[0082] In a specific embodiment of the present application, before performing step S105 to inflate the memory balloon inside the virtual machine, if the total memory of the selected shrinkage nodes is less than the shrinkage size, the threads inside the virtual machine are limited in memory. If the total memory of the selected shrinkage nodes is less than the shrinkage size, it means that the memory contributed by the shrinkage nodes cannot meet the demand at this time, and direct memory balloon inflation may cause the virtual machine threads to compete for memory, resulting in chaos. Therefore, before the memory balloon is inflated, the threads inside the virtual machine can be limited in memory again, so as to extract the idle memory, so that when the memory balloon is inflated, the interference to the threads is avoided or reduced.

[0083] Of course, in actual application, the occupied memory size can be first queried through internal monitoring of the virtual machine, and then the maximum memory value of the hot shrinkable capacity is calculated. If the maximum memory value is less than the shrinkable capacity, it indicates that the demand cannot be met based on the shrinkable node. At this time, the memory of the virtual machine process can be limited based on the idle memory extracted from the shrinkable node, so as to free up as much memory as possible and avoid chaos caused by thread competition for memory.

[0084] In an embodiment of the present application, the shrinkage condition can also be monitored. The specific implementation process includes the following steps:

[0085] Step one, obtain the actual shrinkable size;

[0086] Step two, if the actual shrinkable size is equal to the shrinkable size, feedback the shrinkage end information.

[0087] For ease of description, the above two steps will be combined for description.

[0088] Specifically, the actual shrinkable size, i.e. the idle memory size actually applied for by the memory balloon device, can be obtained from the memory balloon device. If the actual shrinkable size is equal to the shrinkable size, it can be determined that the current shrinkage has ended, and the shrinkage end information can be fed back. When the actual shrinkable size is less than the shrinkable size, if there is still idle memory, the memory balloon can be inflated until the actual shrinkable size is equal to the shrinkable size. If the actual shrinkable size is less than the shrinkable size and there is no idle memory at this time, it can be determined that the current shrinkage has not completed the intended target.

[0089] In an embodiment of the present application, a new shrinkable node can also be selected from the failed numa nodes to free up as much memory as possible for the memory balloon to inflate. That is, if it is determined that the current shrinkage has not been completed, the following steps can also be performed:

[0090] Step one, if the actual shrinkable size is less than the shrinkable size, and the number of failed numa nodes is greater than 1, continue to select a shrinkable node from the failed numa nodes;

[0091] Step two, bind the vCPU bound to the shrinkable node to the failed numa node;

[0092] Step three, after binding the vCPU, inflate the memory balloon in the virtual machine.

[0093] For ease of description, the above three steps will be combined for description.

[0094] The actual shrink size is smaller than the shrink size, at this time, the memory balloon has no free memory to continue to expand, if the number of the failed numa nodes is greater than 1, at this time, the shrink node can be further selected from the failed numa nodes. Then, the vCPU bound to the shrink node is bound to the failed numa node, and after the vCPU binding is completed, the memory balloon is continued to be inflated inside the virtual machine.

[0095] If there is no more failed numa node to select the shrink node to contribute memory, at this time, the process inside the virtual machine can also be subjected to memory limitation, so as to squeeze out free memory for the memory balloon to expand. Specifically, the implementation process includes:

[0096] Step one, if the actual shrink size is smaller than the shrink size, and the number of the failed numa nodes is 1, the process inside the virtual machine is subjected to memory limitation;

[0097] Step two, after the memory limitation is completed, the memory balloon is inflated inside the virtual machine.

[0098] If the free memory obtained based on the shrink node is insufficient to meet the size of the shrink, the memory limitation can be performed on the process inside the virtual machine, and the extra memory is left for the memory balloon device, so as to prevent the situation of memory competition between processes.

[0099] That is, if all vCPUs of the virtual machine only use one numa node, and the hot shrink requirement cannot be met, the process inside the virtual machine is subjected to memory limitation, so as to leave memory in advance, prevent memory competition between the memory balloon and other processes during the expansion process, and prevent the process from being killed or even down. For example, simply releasing the numa node memory is not enough to meet the shrink requirement, at this time, the operation of limiting the memory of the process inside the virtual machine through the cgroup can be started. The memory can be reserved in advance before the memory balloon is inflated, so as to prevent memory competition caused by sudden increase of memory demand of the host process.

[0100] In order to better understand and apply the memory hot shrink method provided by the embodiments of the present application by the person skilled in the art, the specific implementation of the memory hot shrink method will be described in detail below in combination with specific application scenarios.

[0101] The method for hot memory shrinkage provided by the embodiment of the application is used for a virtual machine that needs to be hot memory shrinkage, and the virtual machine is configured with a numa node before starting, and the numa node accesses the near-end memory according to the characteristics. When the shrinkage is performed, the free capacity of the numa node is calculated first, and then the vCPU is bound to the remaining numa node (i.e. the failed numa node) to free the far-end memory for the memory balloon. If the shrinkage size cannot be met, the memory limit operation is performed on the internal processes of the virtual machine, so as to avoid the problem caused by memory competition. The number of numa nodes in a virtual machine can be 2, 4, 8, 16 and the like.

[0102] After the virtual machine starts, if the memory hot shrinkage needs to be performed, the occupied memory size is queried through the internal monitoring of the virtual machine first, and then the maximum memory value that can be hot shrinkage is calculated. If the maximum memory value is greater than the shrinkage size, only the free memory based on the shrinkage node is needed. If the maximum memory value is less than the shrinkage size, the memory limit is continued to be performed on the threads of the virtual machine after the free memory based on the shrinkage node is obtained.

[0103] Specifically, after the interface is clicked to perform the memory hot shrinkage, to prevent the problem caused by the memory balloon directly applying for the memory, the following steps can be executed in sequence:

[0104] First, according to the size of the hot shrinkage and the memory size of each numa node of the virtual machine, the vCPU binding is started, and the memory of some numa nodes is freed by using the characteristics that the numa node accesses the memory nearby, so as to free some memory of the numa nodes. For example, if the virtual machine has four numa nodes, each of which is allocated with 2G memory, and 6G memory needs to be hot shrinkage, all the vCPUs need to be bound to numa0, so as to free 6G memory of numa1, numa2 and numa3 nodes for the expansion of the memory balloon.

[0105] If the virtual machine uses only one numa node, and the hot shrinkage demand cannot be met, the memory limit is started to be performed on the processes in the virtual machine, so as to free the memory in advance, prevent the memory competition between the memory balloon and other processes during the expansion of the memory balloon, and avoid the situation that the processes are killed or even the machine is down. The memory is reserved in advance before the memory balloon is expanded, so as to prevent the memory competition caused by the sudden increase of the memory demand of the host process.

[0106] After the memory is contributed only by the shrinkage node or by the shrinkage node and the threads of the virtual machine, the expansion operation of the memory balloon is performed, so that the memory balloon is more smooth and stable when applying for the memory of the virtual machine. In addition, since the memory for the expansion of the memory balloon is freed in advance, the memory fragmentation can also be reduced.

[0107] Corresponding to the above method embodiments, the embodiments of the present application also provide a memory hot shrinkage device. The memory hot shrinkage device described below can be referred to in correspondence with the memory hot shrinkage method described above.

[0108] Referring to Figure 2 As shown in the figure, the device comprises the following modules:

[0109] The shrinkage size determination module 101 is configured to receive and analyze the memory hot shrinkage request, and determine the shrinkage size corresponding to the virtual machine.

[0110] The shrinkage node number determination module 102 is configured to determine the number of shrinkage nodes by using the shrinkage size.

[0111] The shrinkage node determination module 103 is configured to select the shrinkage nodes from the numa nodes of the virtual machine.

[0112] The vCPU binding module 104 is configured to bind the vCPUs bound by the shrinkage nodes to the failed numa nodes.

[0113] The hot shrinkage module 105 is configured to inflate the memory balloon inside the virtual machine after binding the vCPUs.

[0114] By using the device provided by the embodiments of the present application, the memory hot shrinkage request is received and analyzed, the shrinkage size corresponding to the virtual machine is determined, the number of shrinkage nodes is determined by using the shrinkage size, the shrinkage nodes are selected from the numa nodes of the virtual machine, the vCPUs bound by the shrinkage nodes are bound to the failed numa nodes, and the memory balloon is inflated inside the virtual machine after binding the vCPUs.

[0115] In a non-uniform memory access (NUMA) mechanism, the memory access time depends on the memory location of the processor. Under the NUMA mechanism, the processor accesses the local memory faster than the non-local memory. In the present application, by means of the feature that the virtual machine numa accesses the proximal memory, the processes inside the virtual machine can be smoothly migrated to part of the numa nodes before the memory balloon is inflated, so as to vacate the memory corresponding to another part of the numa nodes, so that the memory balloon inflation does not interfere with the processes inside the virtual machine. Specifically, after receiving the memory hot shrinkage request and determining the shrinkage size corresponding to the virtual machine through analysis, the shrinkage size can be used to determine the number of shrinkage nodes. Then, the shrinkage nodes are selected from the numa nodes of the virtual machine, and the vCPU bound to the shrinkage nodes is bound to the failed numa nodes. In this way, the threads in the shrinkage nodes can be smoothly transitioned to the failed numa nodes, and the memory of the shrinkage nodes can be idle to provide the memory balloon for inflation. That is, after the vCPU is bound, the memory balloon can be inflated inside the virtual machine. Since the memory is idle in advance, the memory balloon inflation will not interfere with the processes of the virtual machine, nor will it cause the memory allocation inside the virtual machine to be chaotic, and it can also avoid a large number of memory recycling and swapping processes inside the virtual machine.

[0116] In one specific embodiment of the present application, it further comprises:

[0117] The process limiting module is configured to limit the memory of the threads inside the virtual machine if the total memory of the selected shrinkage nodes is less than the shrinkage size before the memory balloon is inflated inside the virtual machine.

[0118] In one specific embodiment of the present application, the shrinkage node number determining module 102 is specifically configured to obtain the memory size of the numa nodes.

[0119] The shrinkage node number is determined by using the shrinkage size and the memory size, and the number of shrinkage nodes is less than the number of numa nodes.

[0120] In one specific embodiment of the present application, the shrinkage node determining module 103 is specifically configured to obtain the occupied memory of each numa node.

[0121] The numa node with the smallest occupied memory is determined as the shrinkage node, and the corresponding number of shrinkage nodes is selected.

[0122] In one specific embodiment of the present application, it further comprises:

[0123] The monitoring module obtains the actual shrinkage size after the memory balloon is inflated inside the virtual machine.

[0124] If the actual shrink size is equal to the shrink size, the shrink end information is fed back.

[0125] In an embodiment of the present application, further comprising:

[0126] The secondary shrink module, if the actual shrink size is less than the shrink size, and the number of the failed numa nodes is greater than 1, continues to select the shrink node from the failed numa nodes.

[0127] The vCPU bound to the shrink node is bound to the failed numa node.

[0128] After the vCPU is bound, the memory balloon is inflated in the virtual machine.

[0129] In an embodiment of the present application, the secondary shrink module is further configured to, if the actual shrink size is less than the shrink size, and the number of the failed numa nodes is 1, limit the memory of the process in the virtual machine.

[0130] After the memory is limited, the memory balloon is inflated in the virtual machine.

[0131] In an embodiment of the present application, the hot shrink module 105 is specifically configured to continuously apply the free memory in the virtual machine by using the memory balloon device until the shrink size is reached.

[0132] Corresponding to the above method embodiments, the present application also provides an electronic device. The electronic device described below can be correspondingly referred to the memory hot shrink method described above.

[0133] Referring to Figure 3 The electronic device includes:

[0134] The memory 332 is configured to store the computer program.

[0135] The processor 322 is configured to execute the computer program to implement the steps of the memory hot shrink method of the above method embodiments.

[0136] Specifically, refer to Figure 4 , Figure 4A specific structure schematic diagram of an electronic device is provided for the embodiment, the electronic device can have great difference due to different configurations or performances, and can include one or more than one processor (central processing units, CPU) 322 (for example, one or more than one processor) and a memory 332, the memory 332 stores one or more than one computer application program 342 or data 344. The memory 332 can be temporary storage or persistent storage. The program stored in the memory 332 can include one or more than one module (not shown in the figure), each module can include a series of instruction operations in the data processing device. Further, the central processor 322 can be arranged to communicate with the memory 332, and execute a series of instruction operations in the memory 332 on the electronic device 301.

[0137] The electronic device 301 can further include one or more than one power supply 326, one or more than one wired or wireless network interface 350, one or more than one input and output interface 358, and / or one or more than one operating system 341.

[0138] The steps in the memory hot shrinkage method described above can be implemented by the structure of the electronic device.

[0139] Corresponding to the above method embodiment, the embodiment of the application also provides a readable storage medium, and the readable storage medium described below can be correspondingly referred to the memory hot shrinkage method described above.

[0140] A readable storage medium, the readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the memory hot shrinkage method of the above method embodiment.

[0141] The readable storage medium can be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and various readable storage media that can store program codes.

[0142] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been described in general terms in the above description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

Claims

1. A method for memory hot shrinkage, characterized in that, The method comprises the following steps: receiving and analyzing a memory hot shrinkage request to determine the shrinkage size corresponding to the virtual machine; when configuring the virtual machine, configuring at least two NUMA nodes for the virtual machine, and evenly distributing the number of vCPUs and the memory size of the virtual machine in each NUMA node to correspond to the NUMA architecture of the physical environment; determining the number of shrinkage nodes by using the shrinkage size; selecting the shrinkage nodes from the NUMA nodes of the virtual machine; binding the vCPUs bound to the shrinkage nodes to the failed NUMA nodes; after binding the vCPUs, inflating the memory balloon in the virtual machine; wherein, before inflating the memory balloon in the virtual machine, the method further comprises: if the total memory of the selected shrinkage nodes is less than the shrinkage size, limiting the memory of the threads in the virtual machine; the step of determining the number of shrinkage nodes by using the shrinkage size comprises: obtaining the memory size of the NUMA nodes; determining the number of shrinkage nodes by using the shrinkage size and the memory size; wherein the number of shrinkage nodes is less than the number of NUMA nodes.

2. The method of claim 1, wherein, the step of selecting the shrinkage nodes from the NUMA nodes of the virtual machine comprises: obtaining the occupied memory of each NUMA node; determining the NUMA node with the smallest occupied memory as the shrinkage node, until the corresponding number of shrinkage nodes is selected.

3. The method of claim 1 or 2, wherein, after inflating the memory balloon in the virtual machine, the method further comprises: obtaining the actual shrinkage size; if the actual shrinkage size is equal to the shrinkage size, feeding back the shrinkage end information.

4. The method of claim 3, wherein, the method further comprises: if the actual shrinkage size is less than the shrinkage size, and the number of failed NUMA nodes is greater than 1, continue to select the shrinkage nodes from the failed NUMA nodes; binding the vCPUs bound to the shrinkage nodes to the failed NUMA nodes; after binding the vCPUs, inflating the memory balloon in the virtual machine.

5. The method of claim 3, wherein, the method further comprises: if the actual shrinkage size is less than the shrinkage size, and the number of failed NUMA nodes is 1, limiting the memory of the processes in the virtual machine; after completing the memory limitation, inflating the memory balloon in the virtual machine.

6. A memory thermal shrinkage device, characterized by, The method comprises the following steps: a shrinkage size determination module for receiving and analyzing a memory hot shrinkage request to determine the shrinkage size corresponding to the virtual machine; when configuring the virtual machine, configuring at least two NUMA nodes for the virtual machine, and evenly distributing the number of vCPUs and the memory size of the virtual machine in each NUMA node to correspond to the NUMA architecture of the physical environment; a shrinkage node number determination module for determining the number of shrinkage nodes by using the shrinkage size; a shrinkage node determination module for selecting the shrinkage nodes from the NUMA nodes of the virtual machine; a vCPU binding module for binding the vCPUs bound to the shrinkage nodes to the failed NUMA nodes; a hot shrinkage module for inflating the memory balloon in the virtual machine after binding the vCPUs. The process limiting module is configured to limit the memory of threads in the virtual machine if the total memory of the selected shrink nodes is less than the shrink size before the memory balloon in the virtual machine is inflated. The shrink node number determining module is configured to: acquire the memory size of the NUMA node; and determine the number of the shrink nodes by using the shrink size and the memory size, wherein the number of the shrink nodes is less than the number of the NUMA nodes.

7. An electronic device, comprising: The memory hot shrinkage method comprises the following steps: The memory is configured to store a computer program. The processor is configured to implement the steps of the memory hot shrinkage method according to any one of claims 1 to 5 when the computer program is executed.

8. A readable storage medium, characterized by, The computer program is stored on the readable storage medium, and the computer program is configured to implement the steps of the memory hot shrinkage method according to any one of claims 1 to 5 when the computer program is executed by the processor.

Citation Information

Patent Citations

  • Elastic scaling method and system for computing resources on the basis of DPDK (Data Plane Development Kit)

    CN108062269A

  • Irradiation conversion of thermoplastic to thermoset polyurethane

    US5900444A