Virtual machine memory configuration method and device, equipment and storage medium
By predicting changes in virtual machine memory requirements and dynamically adjusting memory configuration, the problem that traditional static memory allocation strategies are difficult to cope with dynamic requirements is solved, the accuracy and flexibility of memory allocation is improved, the performance of virtual machines is stable and the system operation efficiency is improved .
Patent Information
- Application Number
- CN202411527312.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The traditional virtual machine memory allocation strategy is static and it is difficult to effectively deal with dynamically changing memory requirements, resulting in waste of resources or degraded virtual machine performance.
By predicting the memory requirements changes of each virtual machine in the target host in the preset time period, determine the maximum memory requirements, and dynamically adjust the memory configuration based on the memory amount and demand change information of the virtual machine.
Improve the accuracy and flexibility of memory allocation, avoid insufficient memory or excessive allocation, and ensure stable performance of virtual machines. Especially in a multi-tenant environment, the resource use of each virtual machine is balanced and the overall operation of the system is improved. efficiency.
Smart Images

Figure CN119440728A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtual machine technology, and in particular to a virtual machine memory configuration method, device, equipment and storage medium. Background Art
[0002] With the rapid development of cloud computing and virtualization technology, more and more enterprises and users choose to deploy applications and services through virtualization platforms. Virtualization technology allows multiple virtual machines to run on a host machine, and multiple virtual machines share the host machine's memory. Among them, the effective configuration of memory resources is crucial to the performance of virtual machines.
[0003] In a multi-tenant cloud computing environment, the memory demand of each virtual machine may fluctuate over time. For example, the memory demand of virtual machines increases sharply during certain peak periods, while the memory demand is relatively low during non-peak periods. Traditional memory allocation strategies are usually static, that is, a fixed amount of memory is allocated to the virtual machine when it starts. This method is difficult to effectively cope with dynamically changing memory demands. Excessive memory allocation will lead to waste of host resources, while too little memory allocation may cause the virtual machine performance to degrade or even crash. Summary of the invention
[0004] The present application provides a virtual machine memory configuration method, device, equipment and storage medium to solve the problems raised by the above background technology.
[0005] In a first aspect, the present application provides a virtual machine memory configuration method, comprising: Predicting memory demand change information of each virtual machine in the target host machine within a first preset time period, respectively; wherein the first preset time period is a time period connected to the current moment and after the current moment; Determine the maximum total memory demand within the first preset time period based on each of the memory demand change information; Determine whether the maximum total memory requirement is less than the total memory of the target host machine; If so, in the target host machine, memory configuration is performed on each of the virtual machines based on the memory amount and memory requirement change information of each of the virtual machines and the remaining memory amount of the target host machine.
[0006] In a possible implementation, predicting the memory requirement change information of each virtual machine in the target host machine within the first preset time period includes: For each of the virtual machines, memory usage data of the virtual machine within a second preset time period is obtained, and the memory usage data is input into a preset correction parameter determination model to obtain corresponding correction parameters; wherein the second preset time period is a time period connected to the current moment and before the current moment, and the correction parameters include model parameters to be corrected and corresponding correction values; For each of the virtual machines, the historical memory usage change information of the virtual machine before the current moment is obtained, and the preset memory demand prediction model is corrected based on the correction parameters corresponding to the virtual machine to obtain the corrected memory demand prediction model, and the historical memory usage change information is input into the corrected memory demand prediction model to obtain the memory demand change information corresponding to the virtual machine.
[0007] In a possible implementation, the memory requirement change information is a memory requirement change curve, and determining the maximum total memory requirement within the first preset time period based on each piece of memory requirement change information includes: The maximum memory demand values on each of the memory demand change curves are added together to obtain the maximum total memory demand value.
[0008] In a possible implementation, the performing memory configuration on each of the virtual machines based on the memory amount and memory requirement change information of each of the virtual machines and the remaining memory amount of the target host machine includes: For each of the virtual machines, determining whether the memory amount of the virtual machine is less than the maximum total memory requirement in the memory requirement change information of the virtual machine; If yes, determine that the virtual machine is a first-class virtual machine, and use the maximum total memory requirement in the memory requirement change information of the virtual machine to subtract the memory amount of the virtual machine to obtain the memory increase amount of the virtual machine; If not, determine that the virtual machine is a second type virtual machine, and use the memory amount of the virtual machine to subtract the maximum total memory requirement in the memory requirement change information of the virtual machine to obtain the memory reduction amount of the virtual machine; Adding the memory increases corresponding to the first-type virtual machines to obtain the sum of the memory increases; Determine whether the sum of the memory increase amounts is greater than the remaining memory amount of the target host machine; If not, for each of the first-type virtual machines, memory is allocated to the first-type virtual machines from the remaining memory based on the memory increase of the first-type virtual machines.
[0009] In a possible implementation, after determining whether the sum of the memory increase amounts is greater than the remaining memory amount of the target host machine, the method further includes: If so, calculating a first memory amount difference between the sum of the memory increase amounts and the remaining memory amount of the target host machine; Arranging the memory reduction amounts in sequence to obtain a memory reduction amount sequence; wherein the memory reduction amounts in the memory reduction amount sequence decrease in sequence; comparing a first memory reduction amount in the memory reduction amount sequence with the first memory amount difference; If the first memory reduction amount is less than the first memory difference, adding the first memory reduction amount and the second memory reduction amount in the memory reduction amount sequence to obtain the sum of the first memory reduction amount; comparing the sum of the first memory reduction amounts with the first memory amount difference; If the sum of the first memory reduction amounts is less than the first memory difference, adding the first memory reduction amount, the second memory reduction amount and the third memory reduction amount in the memory reduction amount sequence to obtain the sum of the second memory reduction amount; comparing the sum of the second memory reduction amounts with the first memory amount difference; Iterate the steps after comparing the sum of the first memory reduction amounts with the first memory amount difference until the sum of the memory reduction amounts is not less than the first memory amount difference; When the sum of the memory reduction amounts is not less than the first memory amount difference, determining the second type virtual machines corresponding to the respective memory reduction amounts corresponding to the sum of the memory reduction amounts as the target second type virtual machines; For each of the target second-type virtual machines, releasing the memory of the target second-type virtual machine based on the memory reduction amount of the target second-type virtual machine; For each of the first-type virtual machines, memory is allocated to the first-type virtual machine from the remaining memory and the memory released by each of the target second-type virtual machines based on the memory increase of the first-type virtual machine.
[0010] In a possible implementation, after determining whether the maximum total memory requirement is less than the total memory of the target host machine, the method further includes: If not, determining, for each of the virtual machines, a maximum memory requirement in the memory requirement change information corresponding to the virtual machine; Arranging the maximum memory requirements of each virtual machine in sequence based on the priority of each virtual machine to obtain a maximum memory requirement sequence; wherein the priority corresponding to each maximum memory requirement in the maximum memory requirement sequence decreases in sequence; Calculating a second memory amount difference between the maximum total memory requirement and the total memory amount of the target host machine; Compare a first maximum memory requirement value in the maximum memory requirement value sequence with the second memory amount difference value; If the first maximum memory requirement value is less than the second memory requirement difference value, adding the first maximum memory requirement value and the second maximum memory requirement value in the maximum memory requirement value sequence to obtain the sum of the first maximum memory requirement values; Compare the sum of the first maximum memory requirements with the second memory difference; If the sum of the first maximum memory demand values is less than the second memory demand difference, the first maximum memory demand value, the second maximum memory demand value and the third maximum memory demand value in the sequence of maximum memory demand values are added together to obtain the sum of the second maximum memory demand values; comparing the sum of the second memory requirement maximum values with the second memory amount difference; Iterate the steps after comparing the sum of the first maximum memory demand values with the second memory quantity difference value until the sum of the maximum memory demand values is not less than the second memory quantity difference value; When the sum of the maximum memory demand values is not less than the second memory amount difference, determining the virtual machines corresponding to the respective maximum memory demand values corresponding to the sum of the maximum memory demand values as the virtual machines to be migrated; Based on a preset virtual machine migration method, each of the virtual machines to be migrated is migrated from the target host machine to the standby host machine.
[0011] In a second aspect, the present application provides a virtual machine memory configuration device, comprising: A prediction module, used to predict memory demand change information of each virtual machine in the target host machine within a first preset time period; wherein the first preset time period is a time period connected to the current moment and after the current moment; A determination module, configured to determine a maximum total memory demand within the first preset time period based on each of the memory demand change information; A determination module, used to determine whether the maximum total memory requirement is less than the total memory of the target host machine; A memory configuration module is used to, if yes, perform memory configuration on each of the virtual machines in the target host machine based on the memory amount and memory requirement change information of each of the virtual machines and the remaining memory amount of the target host machine.
[0012] In a third aspect, the present application provides a terminal device, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the virtual machine memory configuration method as described in any one of the above items is implemented.
[0013] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the virtual machine memory configuration method as described in any one of the above items is implemented.
[0014] The present application provides a virtual machine memory configuration method, device, equipment and storage medium. The method comprises: respectively predicting the memory demand change information of each virtual machine in the target host machine within the first preset time period; wherein the first preset time period is a time period connected to the current moment and after the current moment; determining the maximum total memory demand within the first preset time period based on each memory demand change information; judging whether the maximum total memory demand is less than the total memory of the target host machine; if so, in the target host machine, performing memory configuration on each virtual machine based on the memory amount and memory demand change information of each virtual machine and the remaining memory amount of the target host machine. The method ensures that the memory demand dynamics of different virtual machines can be understood in advance by analyzing and predicting the memory usage trend of each virtual machine in the target host machine within the first preset time period, thereby providing a reliable basis for subsequent resource allocation. This prediction mechanism improves the accuracy and flexibility of memory allocation, avoids insufficient or excessive memory allocation, and by predicting memory demand changes in advance, the target host machine can more effectively plan resources and ensure the performance stability of the virtual machine, especially in a multi-tenant environment, it can better balance the resource usage of each virtual machine, prevent the risk of memory contention or virtual machine performance degradation, thereby improving the overall operation efficiency of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0016] Figure 1 A flowchart of a virtual machine memory configuration method provided in an embodiment of the present application; Figure 2 A schematic block diagram of the structure of a virtual machine memory configuration device provided in an embodiment of the present application; Figure 3 A schematic block diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0018] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0019] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0020] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0021] With the rapid development of cloud computing and virtualization technology, more and more enterprises and users choose to deploy applications and services through virtualization platforms. Virtualization technology allows multiple virtual machines to run on a host machine, and multiple virtual machines share the host machine's memory. Among them, the effective configuration of memory resources is crucial to the performance of virtual machines.
[0022] In a multi-tenant cloud computing environment, the memory demand of each virtual machine may fluctuate over time. For example, the memory demand of virtual machines may increase dramatically during certain peak periods, while the memory demand may be relatively low during non-peak periods. Traditional memory allocation strategies are usually static, that is, a fixed amount of memory is allocated to the virtual machine when it starts. This method is difficult to effectively cope with dynamically changing memory requirements. Too much memory allocation will lead to waste of host resources, while too little memory allocation may cause the virtual machine to perform poorly or even crash. To this end, the present application provides a virtual machine memory configuration method, device, equipment and storage medium to solve the above problems.
[0023] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0024] See also Figure 1 , Figure 1A flowchart of a virtual machine memory configuration method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes steps S1 to S4.
[0025] Step S1, predicting the memory demand change information of each virtual machine in the target host machine within a first preset time period; wherein the first preset time period is a time period connected to the current moment and after the current moment.
[0026] Specifically, the memory demand change information of each virtual machine in the target host machine within a first preset time period is predicted respectively, including: for each of the virtual machines, obtaining the memory usage data of the virtual machine within a second preset time period, and inputting the memory usage data into a preset correction parameter determination model to obtain corresponding correction parameters, wherein the second preset time period is a time period connected to the current moment and before the current moment, and the correction parameters include model parameters that need to be corrected and corresponding correction values; for each of the virtual machines, obtaining the historical memory usage change information of the virtual machine before the current moment, correcting the preset memory demand prediction model based on the correction parameters corresponding to the virtual machine to obtain a corrected memory demand prediction model, and inputting the historical memory usage change information into the corrected memory demand prediction model to obtain the memory demand change information corresponding to the virtual machine.
[0027] Among them, the memory usage data includes but is not limited to the number of memory accesses, memory usage change information and memory amount change information. The correction parameter determination model and the memory demand prediction model are both pre-trained neural network models. One virtual machine corresponds to one correction parameter determination model and one memory demand prediction model.
[0028] It can be understood that by correcting the preset memory demand prediction model based on the correction parameters corresponding to the virtual machine to obtain a corrected memory demand prediction model, it is helpful to improve the accuracy of memory demand change information, thereby improving the effectiveness of the virtual machine memory configuration method.
[0029] Step S2: determining the maximum total memory demand within the first preset time period based on each of the memory demand change information.
[0030] Specifically, the memory demand change information is a memory demand change curve, and determining the maximum total memory demand within the first preset time period based on each memory demand change information includes: adding the maximum memory demand values on each memory demand change curve to obtain the maximum total memory demand.
[0031] It can be understood that the above method adds up the maximum memory demand values on the memory demand change curves to obtain the maximum total memory demand, which helps to ensure the effective operation of each virtual machine within the first preset time period.
[0032] Step S3, determining whether the maximum total memory requirement is less than the total memory of the target host machine; Step S4: If yes, in the target host machine, memory configuration is performed on each of the virtual machines based on the memory capacity and memory requirement change information of each of the virtual machines and the remaining memory capacity of the target host machine.
[0033] The memory capacity of the virtual machine refers to the current memory capacity of the virtual machine.
[0034] Specifically, the memory configuration of each virtual machine based on the memory amount and memory requirement change information of each virtual machine and the remaining memory amount of the target host machine includes the following steps: For each of the virtual machines, determining whether the memory amount of the virtual machine is less than the maximum total memory requirement in the memory requirement change information of the virtual machine; If yes, determine that the virtual machine is a first-class virtual machine, and use the maximum total memory requirement in the memory requirement change information of the virtual machine to subtract the memory amount of the virtual machine to obtain the memory increase amount of the virtual machine; If not, determine that the virtual machine is a second type virtual machine, and use the memory amount of the virtual machine to subtract the maximum total memory requirement in the memory requirement change information of the virtual machine to obtain the memory reduction amount of the virtual machine; Adding the memory increases corresponding to the first-type virtual machines to obtain the sum of the memory increases; Determine whether the sum of the memory increase amounts is greater than the remaining memory amount of the target host machine; If not, for each of the first-type virtual machines, allocate memory to the first-type virtual machines from the remaining memory based on the memory increase of the first-type virtual machines; it can be understood that the memory amount allocated to the first-type virtual machines is consistent with the memory increase of the first-type virtual machines; If so, calculating a first memory amount difference between the sum of the memory increase amounts and the remaining memory amount of the target host machine; Arranging the memory reduction amounts in sequence to obtain a memory reduction amount sequence; wherein the memory reduction amounts in the memory reduction amount sequence decrease in sequence; comparing a first memory reduction amount in the memory reduction amount sequence with the first memory amount difference; If the first memory reduction amount is less than the first memory difference, adding the first memory reduction amount and the second memory reduction amount in the memory reduction amount sequence to obtain the sum of the first memory reduction amount; comparing the sum of the first memory reduction amounts with the first memory amount difference; If the sum of the first memory reduction amounts is less than the first memory difference, adding the first memory reduction amount, the second memory reduction amount and the third memory reduction amount in the memory reduction amount sequence to obtain the sum of the second memory reduction amount; comparing the sum of the second memory reduction amounts with the first memory amount difference; Iterate the steps after comparing the sum of the first memory reduction amounts with the first memory amount difference until the sum of the memory reduction amounts is not less than the first memory amount difference; When the sum of the memory reduction amounts is not less than the first memory amount difference, determining the second type virtual machines corresponding to the respective memory reduction amounts corresponding to the sum of the memory reduction amounts as the target second type virtual machines; For each of the target second-type virtual machines, releasing the memory of the target second-type virtual machine based on the memory reduction amount of the target second-type virtual machine; it can be understood that the memory amount released by the target second-type virtual machine is consistent with the memory reduction amount of the target second-type virtual machine; For each of the first-type virtual machines, memory is allocated to the first-type virtual machine from the remaining memory and the memory released by each of the target second-type virtual machines based on the memory increase of the first-type virtual machine; it can be understood that the amount of memory allocated to the first-type virtual machine is consistent with the memory increase of the first-type virtual machine.
[0035] It can be understood that the above-mentioned method for configuring the memory of each virtual machine based on the memory amount and memory demand change information of each virtual machine and the remaining memory amount of the target host machine, first, determines whether it needs to increase or decrease the memory according to the memory demand change and memory amount of each virtual machine, and ensures that the memory amount of each virtual machine matches its actual demand. For the first type of virtual machines that need to increase memory, the remaining memory of the target host machine will be preferentially used for allocation to ensure the effective operation of the virtual machine. When the remaining memory is insufficient, the excess memory of the target second type virtual machine with lower memory demand is released to ensure that the high-demand virtual machine obtains the required memory. This dynamic balancing mechanism avoids the risk of performance degradation of high-load virtual machines by accurately calculating the amount of memory increase and decrease, and also avoids low-load virtual machines occupying too much memory, thereby improving the overall memory utilization efficiency and system stability of the target host machine.
[0036] The method provided in this embodiment ensures that the memory demand dynamics of different virtual machines can be understood in advance by analyzing and predicting the memory usage trends of each virtual machine in the target host machine within a first preset time period, thereby providing a reliable basis for subsequent resource allocation. This prediction mechanism improves the accuracy and flexibility of memory allocation and avoids insufficient or excessive memory allocation. By predicting changes in memory demand in advance, the target host machine can plan resources more effectively and ensure the performance stability of the virtual machine. Especially in a multi-tenant environment, it can better balance the resource usage of each virtual machine and prevent the risk of memory contention or virtual machine performance degradation, thereby improving the overall operating efficiency of the system.
[0037] In some embodiments, after determining whether the maximum total memory requirement is less than the total memory of the target host machine, the method further includes: If not, determining, for each of the virtual machines, a maximum memory requirement in the memory requirement change information corresponding to the virtual machine; Arranging the maximum memory requirements of each virtual machine in sequence based on the priority of each virtual machine to obtain a maximum memory requirement sequence; wherein the priority corresponding to each maximum memory requirement in the maximum memory requirement sequence decreases in sequence; Calculating a second memory amount difference between the maximum total memory requirement and the total memory amount of the target host machine; Compare a first maximum memory requirement value in the maximum memory requirement value sequence with the second memory amount difference value; If the first maximum memory requirement value is less than the second memory requirement difference value, adding the first maximum memory requirement value and the second maximum memory requirement value in the maximum memory requirement value sequence to obtain the sum of the first maximum memory requirement values; Compare the sum of the first maximum memory requirements with the second memory difference; If the sum of the first maximum memory demand values is less than the second memory demand difference, the first maximum memory demand value, the second maximum memory demand value and the third maximum memory demand value in the sequence of maximum memory demand values are added together to obtain the sum of the second maximum memory demand values; comparing the sum of the second memory requirement maximum values with the second memory amount difference; Iterate the steps after comparing the sum of the first maximum memory demand values with the second memory quantity difference value until the sum of the maximum memory demand values is not less than the second memory quantity difference value; When the sum of the maximum memory demand values is not less than the second memory amount difference, determining the virtual machines corresponding to the respective maximum memory demand values corresponding to the sum of the maximum memory demand values as the virtual machines to be migrated; Based on a preset virtual machine migration method, each of the virtual machines to be migrated is migrated from the target host machine to the standby host machine.
[0038] The method provided in this embodiment arranges the maximum memory requirements of each virtual machine in order based on the priority of each virtual machine to obtain a maximum memory requirement sequence, and determines the virtual machine to be migrated based on the difference between the maximum memory requirement sequence and the second memory amount when the maximum total memory requirement is greater than the total memory of the target host machine. On the one hand, it ensures that the needs of high-priority virtual machines are met first when the memory of the target host machine is insufficient. On the other hand, it optimizes the system's memory management and improves the stability of the virtual machines.
[0039] See also Figure 2 , Figure 2 A schematic block diagram of the structure of the virtual machine memory configuration device 110 provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the virtual machine memory configuration device provided in the embodiment of the present application includes: The prediction module 110 is used to predict the memory demand change information of each virtual machine in the target host machine within a first preset time period; wherein the first preset time period is a time period connected to the current moment and after the current moment.
[0040] The determination module 120 is used to determine the maximum total memory demand within the first preset time period based on each of the memory demand change information.
[0041] The determination module 130 is used to determine whether the maximum total memory requirement is less than the total memory of the target host machine.
[0042] The memory configuration module 140 is used to perform memory configuration on each of the virtual machines in the target host machine based on the memory amount and memory requirement change information of each of the virtual machines and the remaining memory amount of the target host machine.
[0043] It should be noted that technicians in the relevant technical field can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned virtual machine memory configuration method embodiment, and will not be repeated here.
[0044] The virtual machine memory configuration device 100 provided in the above embodiment can be implemented in the form of a computer program. The computer program can be used in Figure 3 The system is run on the terminal device 200 shown.
[0045] See also Figure 3 , Figure 3The terminal device 200 provided in the embodiment of the present application is a schematic block diagram of the structure, wherein the terminal device 200 includes a processor 201 and a memory 202, wherein the processor 201 and the memory 202 are connected via a system bus 203, wherein the memory 202 may include a non-volatile storage medium and an internal memory.
[0046] The non-volatile storage medium can store a computer program. The computer program includes program instructions, and when the program instructions are executed by the processor 201, the processor 201 can execute any of the above-mentioned virtual machine memory configuration methods.
[0047] The processor 201 is used to provide computing and control capabilities to support the operation of the entire terminal device 200.
[0048] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor 201, the processor 201 can execute any of the above-mentioned virtual machine memory configuration methods.
[0049] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the terminal device 200 involved in the scheme of the present application. The specific terminal device 200 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0050] It should be understood that the processor 201 may be a central processing unit (CPU), and the processor 201 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0051] In some embodiments, the processor 201 is used to run a computer program stored in the memory to implement the following steps: Predicting memory demand change information of each virtual machine in the target host machine within a first preset time period, respectively; wherein the first preset time period is a time period connected to the current moment and after the current moment; Determine the maximum total memory demand within the first preset time period based on each of the memory demand change information; Determine whether the maximum total memory requirement is less than the total memory of the target host machine; If so, in the target host machine, memory configuration is performed on each of the virtual machines based on the memory amount and memory requirement change information of each of the virtual machines and the remaining memory amount of the target host machine.
[0052] It should be noted that technicians in the relevant field can clearly understand that for the convenience and simplicity of description, the specific working process of the terminal device 200 described above can refer to the corresponding process of the aforementioned virtual machine memory configuration method, and will not be repeated here.
[0053] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by one or more processors, the one or more processors implement the virtual machine memory configuration method provided in the embodiment of the present application.
[0054] The computer-readable storage medium may be an internal storage unit of the terminal device 200 in the aforementioned embodiment, such as a hard disk or memory of the terminal device 200. The computer-readable storage medium may also be an external storage device of the terminal device 200, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped with the terminal device 200.
[0055] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A virtual machine memory configuration method, characterized in that: include: Predicting memory demand change information of each virtual machine in the target host machine within a first preset time period, respectively; wherein the first preset time period is a time period connected to the current moment and after the current moment; Determine the maximum total memory demand within the first preset time period based on each of the memory demand change information; Determine whether the maximum total memory requirement is less than the total memory of the target host machine; If so, in the target host machine, memory configuration is performed on each of the virtual machines based on the memory amount and memory requirement change information of each of the virtual machines and the remaining memory amount of the target host machine.
2. The virtual machine memory configuration method according to claim 1, characterized in that: The predicting of memory requirement change information of each virtual machine in the target host machine within a first preset time period includes: For each of the virtual machines, memory usage data of the virtual machine within a second preset time period is obtained, and the memory usage data is input into a preset correction parameter determination model to obtain corresponding correction parameters; wherein the second preset time period is a time period connected to the current moment and before the current moment, and the correction parameters include model parameters to be corrected and corresponding correction values; For each of the virtual machines, the historical memory usage change information of the virtual machine before the current moment is obtained, and the preset memory demand prediction model is corrected based on the correction parameters corresponding to the virtual machine to obtain the corrected memory demand prediction model, and the historical memory usage change information is input into the corrected memory demand prediction model to obtain the memory demand change information corresponding to the virtual machine.
3. The virtual machine memory configuration method according to claim 1, characterized in that: The memory requirement change information is a memory requirement change curve, and determining the maximum total memory requirement within the first preset time period based on each piece of memory requirement change information includes: The maximum memory demand values on each of the memory demand change curves are added together to obtain the maximum total memory demand value.
4. The virtual machine memory configuration method according to claim 1, characterized in that: The performing memory configuration on each of the virtual machines based on the memory amount and memory requirement change information of each of the virtual machines and the remaining memory amount of the target host machine includes: For each of the virtual machines, determining whether the memory amount of the virtual machine is less than the maximum total memory requirement in the memory requirement change information of the virtual machine; If yes, determine that the virtual machine is a first-class virtual machine, and use the maximum total memory requirement in the memory requirement change information of the virtual machine to subtract the memory amount of the virtual machine to obtain the memory increase amount of the virtual machine; If not, determine that the virtual machine is a second type virtual machine, and use the memory amount of the virtual machine to subtract the maximum total memory requirement in the memory requirement change information of the virtual machine to obtain the memory reduction amount of the virtual machine; Adding the memory increases corresponding to the first-type virtual machines to obtain the sum of the memory increases; Determine whether the sum of the memory increase amounts is greater than the remaining memory amount of the target host machine; If not, for each of the first-type virtual machines, memory is allocated to the first-type virtual machines from the remaining memory based on the memory increase of the first-type virtual machines.
5. The virtual machine memory configuration method according to claim 4, characterized in that: After determining whether the sum of the memory increase amounts is greater than the remaining memory amount of the target host machine, the method further includes: If so, calculating a first memory amount difference between the sum of the memory increase amounts and the remaining memory amount of the target host machine; Arranging the memory reduction amounts in sequence to obtain a memory reduction amount sequence; wherein the memory reduction amounts in the memory reduction amount sequence decrease in sequence; comparing a first memory reduction amount in the memory reduction amount sequence with the first memory amount difference; If the first memory reduction amount is less than the first memory difference, adding the first memory reduction amount and the second memory reduction amount in the memory reduction amount sequence to obtain the sum of the first memory reduction amount; comparing the sum of the first memory reduction amounts with the first memory amount difference; If the sum of the first memory reduction amounts is less than the first memory difference, adding the first memory reduction amount, the second memory reduction amount and the third memory reduction amount in the memory reduction amount sequence to obtain the sum of the second memory reduction amount; comparing the sum of the second memory reduction amounts with the first memory amount difference; Iterate the steps after comparing the sum of the first memory reduction amounts with the first memory amount difference until the sum of the memory reduction amounts is not less than the first memory amount difference; When the sum of the memory reduction amounts is not less than the first memory amount difference, determining the second type virtual machines corresponding to the respective memory reduction amounts corresponding to the sum of the memory reduction amounts as the target second type virtual machines; For each of the target second-type virtual machines, releasing the memory of the target second-type virtual machine based on the memory reduction amount of the target second-type virtual machine; For each of the first-type virtual machines, memory is allocated to the first-type virtual machine from the remaining memory and the memory released by each of the target second-type virtual machines based on the memory increase of the first-type virtual machine.
6. The virtual machine memory configuration method according to claim 1, characterized in that: After determining whether the maximum total memory requirement is less than the total memory of the target host machine, the method further includes: If not, determining, for each of the virtual machines, a maximum memory requirement in the memory requirement change information corresponding to the virtual machine; Arranging the maximum memory requirements of each virtual machine in sequence based on the priority of each virtual machine to obtain a maximum memory requirement sequence; wherein the priority corresponding to each maximum memory requirement in the maximum memory requirement sequence decreases in sequence; Calculating a second memory amount difference between the maximum total memory requirement and the total memory amount of the target host machine; Compare a first maximum memory requirement value in the maximum memory requirement value sequence with the second memory amount difference value; If the first maximum memory requirement value is less than the second memory requirement difference value, adding the first maximum memory requirement value and the second maximum memory requirement value in the maximum memory requirement value sequence to obtain the sum of the first maximum memory requirement values; Compare the sum of the first maximum memory requirements with the second memory difference; If the sum of the first maximum memory demand values is less than the second memory demand difference, the first maximum memory demand value, the second maximum memory demand value and the third maximum memory demand value in the sequence of maximum memory demand values are added together to obtain the sum of the second maximum memory demand values; comparing the sum of the second memory requirement maximum values with the second memory amount difference; Iterate the steps after comparing the sum of the first maximum memory demand values with the second memory quantity difference value until the sum of the maximum memory demand values is not less than the second memory quantity difference value; When the sum of the maximum memory demand values is not less than the second memory amount difference, determining the virtual machines corresponding to the respective maximum memory demand values corresponding to the sum of the maximum memory demand values as the virtual machines to be migrated; Based on a preset virtual machine migration method, each of the virtual machines to be migrated is migrated from the target host machine to the standby host machine.
7. A virtual machine memory configuration device, characterized in that: include: A prediction module, used to predict memory demand change information of each virtual machine in the target host machine within a first preset time period; wherein the first preset time period is a time period connected to the current moment and after the current moment; A determination module, configured to determine a maximum total memory demand within the first preset time period based on each of the memory demand change information; A judgment module, used to judge whether the maximum total memory requirement is less than the total memory of the target host machine; A memory configuration module is used to, if yes, perform memory configuration on each of the virtual machines in the target host machine based on the memory amount and memory requirement change information of each of the virtual machines and the remaining memory amount of the target host machine.
8. A terminal device, characterized in that: The terminal device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the virtual machine memory configuration method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: A computer program is stored on the computer-readable storage medium, wherein when the computer program is executed by a processor, the virtual machine memory configuration method according to any one of claims 1 to 6 is implemented.