Virtual machine management method and device, storage medium and program product
By comprehensively evaluating the resource status of virtual machines and physical machines, and using a scoring system to determine the target virtual machines and physical machines, the dynamic migration of virtual machines is realized, which solves the problem of unbalanced resource allocation in the existing technology and improves resource utilization efficiency.
Patent Information
- Application Number
- CN202412000512.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-27
AI Technical Summary
In the prior art, the virtual machine management method is too single and fails to effectively pay attention to the utilization of virtual machines, resulting in the problem of unbalanced resource allocation.
By comprehensively evaluating the resource status of candidate virtual machines and physical machines, a scoring system is used to determine the target virtual machines and physical machines, and dynamic migration of virtual machines is realized to achieve dynamic balanced allocation of resources.
It effectively solves the problem of unbalanced resource allocation. By dynamically adjusting the host of the virtual machine, the optimization and reasonable allocation of resources are achieved, and the resource utilization efficiency of the cloud computing environment is improved.
Smart Images

Figure CN120045276A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computers. Specifically, the present application relates to a method and apparatus for managing virtual machines, a storage medium, and a program product. Background Art
[0002] With the popularization of cloud computing, more and more services have been migrated to the cloud environment, so that more and more application programs need to run on virtual machines. However, due to the great differences among application programs, including running types, computing requirements, data access modes, and network requirements, etc., how to effectively manage these virtual machines to meet their different requirements and reduce resource costs has become a major challenge in cloud computing deployment.
[0003] Currently, the management of virtual machines in most cloud computing environments is static. The main consideration is the resource utilization of the host where the virtual machine is located, and it is determined whether the virtual machine needs to be migrated to other hosts for running according to the resource utilization of the host.
[0004] However, in the virtual machine management method adopted in the above related technologies, only the resource utilization of the host where the virtual machine is located is considered, and the utilization of the virtual machine is not concerned, which may lead to the technical problem of unbalanced resource allocation.
[0005] Therefore, there is a technical problem of unbalanced resource allocation caused by the overly single management method of virtual machines in the prior art. Summary of the Invention
[0006] The embodiments of the present application provide a method and apparatus for managing virtual machines, a storage medium, and a program product, so as to solve at least the technical problem of unbalanced resource allocation.
[0007] According to an embodiment of the present application, a method for managing virtual machines is provided, including: determining a first virtual machine score corresponding to a candidate virtual machine based on the central processing unit (CPU) waiting time of the candidate virtual machine, where the CPU waiting time is the time when the candidate virtual machine is stopped from running due to the CPU resources of a first physical machine being occupied by other virtual machines, and the first physical machine is the host machine of the candidate virtual machine; determining a second virtual machine score corresponding to the candidate virtual machine based on the memory usage rate of the candidate virtual machine, where the memory usage rate is used to indicate the ratio between the memory resources used by the candidate virtual machine and the total memory resources of the first physical machine; determining a third virtual machine score corresponding to the candidate virtual machine based on the quantity of first service resources stored in a first disk of the first physical machine, where the first service resources are the service resources managed by the candidate virtual machine; using the first virtual machine score, the second virtual machine score, and the third virtual machine score to determine the target virtual machine score corresponding to the candidate virtual machine, and when the target virtual machine score reaches a first threshold and the candidate virtual machine meets the migration conditions of the virtual machine, determining the candidate virtual machine as the target virtual machine to be migrated; determining a first physical machine score corresponding to a candidate physical machine based on the CPU idle time of the candidate physical machine, where the CPU idle time is the time when the CPU of the candidate physical machine is in an idle state within a first time period; determining a second physical machine score corresponding to the candidate physical machine based on the available memory amount of the candidate physical machine, where the available memory amount is the remaining memory amount of the candidate physical machine; determining a third physical machine score corresponding to the candidate physical machine based on the quantity of virtual machine service resources stored in a second disk of the candidate physical machine; using the first physical machine score, the second physical machine score, and the third physical machine score to determine the target physical machine score corresponding to the candidate physical machine, and when the target physical machine score reaches a second threshold, determining the candidate physical machine as the target physical machine; migrating the target virtual machine to the target physical machine for running.
[0008] According to another embodiment of the present application, there is provided a management device for virtual machines, including: a first determination unit configured to determine a first virtual machine score corresponding to a candidate virtual machine based on the central processing unit (CPU) waiting time of the candidate virtual machine, where the CPU waiting time is the time when the candidate virtual machine is stopped from running due to the CPU resources of the first physical machine being occupied by other virtual machines, and the first physical machine is the host machine of the candidate virtual machine; determine a second virtual machine score corresponding to the candidate virtual machine based on the memory usage rate of the candidate virtual machine, where the memory usage rate is used to indicate the ratio between the memory resources used by the candidate virtual machine and the total memory resources of the first physical machine; determine a third virtual machine score corresponding to the candidate virtual machine based on the quantity of first service resources stored in the first disk of the first physical machine, where the first service resources are the service resources managed by the candidate virtual machine; a second determination unit configured to use the first virtual machine score, the second virtual machine score, and the third virtual machine score to determine the target virtual machine score corresponding to the candidate virtual machine, and determine the candidate virtual machine as the target virtual machine to be migrated when the target virtual machine score reaches a first threshold and the candidate virtual machine meets the migration conditions of the virtual machine; a third determination unit configured to determine a first physical machine score corresponding to the candidate physical machine based on the CPU idle time of the candidate physical machine, where the CPU idle time is the time when the CPU of the candidate physical machine is in an idle state within a first time period; determine a second physical machine score corresponding to the candidate physical machine based on the available memory amount of the candidate physical machine, where the available memory amount is the remaining memory amount of the candidate physical machine; determine a third physical machine score corresponding to the candidate physical machine based on the quantity of virtual machine service resources stored in the second disk of the candidate physical machine; a fourth determination unit configured to use the first physical machine score, the second physical machine score, and the third physical machine score to determine the target physical machine score corresponding to the candidate physical machine, and determine the candidate physical machine as the target physical machine when the target physical machine score reaches a second threshold; a migration unit configured to migrate the target virtual machine to the target physical machine for running.
[0009] According to yet another embodiment of the present application, there is also provided a computer-readable storage medium storing a computer program, where the computer program is configured to execute the steps in any one of the above method embodiments when running.
[0010] According to yet another embodiment of the present application, there is also provided an electronic device including a memory and a processor, where the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0011] According to another embodiment of the present application, there is also provided a computer program product, including a computer program, which when executed by a processor, implements the steps of the methods in the various embodiments of the present application.
[0012] Through the embodiments provided by the present application, based on the central processing unit (CPU) waiting time of a candidate virtual machine, a first virtual machine score corresponding to the candidate virtual machine is determined, where the CPU waiting time is the time when the candidate virtual machine is stopped from running due to the CPU resources of a first physical machine being occupied by other virtual machines, and the first physical machine is the host machine of the candidate virtual machine; based on the memory usage rate of the candidate virtual machine, a second virtual machine score corresponding to the candidate virtual machine is determined, where the memory usage rate is used to indicate the ratio between the memory resources already used by the candidate virtual machine and the total memory resources of the first physical machine; based on the quantity of first service resources stored in a first disk of the first physical machine, a third virtual machine score corresponding to the candidate virtual machine is determined, where the first service resources are the service resources managed by the candidate virtual machine; using the first virtual machine score, the second virtual machine score, and the third virtual machine score, a target virtual machine score corresponding to the candidate virtual machine is determined, and when the target virtual machine score reaches a first threshold and the candidate virtual machine meets the migration conditions of the virtual machine, the candidate virtual machine is determined as the target virtual machine to be migrated; based on the CPU idle time of a candidate physical machine, a first physical machine score corresponding to the candidate physical machine is determined, where the CPU idle time is the time when the CPU of the candidate physical machine is in an idle state within a first time period; based on the available memory amount of the candidate physical machine, a second physical machine score corresponding to the candidate physical machine is determined, where the available memory amount is the remaining memory amount of the candidate physical machine; based on the quantity of service resources of virtual machines stored in a second disk of the candidate physical machine, a third physical machine score corresponding to the candidate physical machine is determined; using the first physical machine score, the second physical machine score, and the third physical machine score, a target physical machine score corresponding to the candidate physical machine is determined, and when the target physical machine score reaches a second threshold, the candidate physical machine is determined as the target physical machine; the target virtual machine is migrated to the target physical machine for running. In other words, by adopting the embodiments of the present application, through comprehensively evaluating the resource status of virtual machines and physical machines and replacing the host machine of the virtual machine, the technical effect of dynamically and evenly allocating resources is achieved, and the technical problem of uneven resource allocation caused by a too single management method for virtual machines in the related art is solved. Description of the Drawings
[0013] Figure 1 is a flowchart of a method for managing a virtual machine according to an embodiment of the present application;
[0014] Figure 2 is a flowchart of another method for managing a virtual machine according to an embodiment of the present application;
[0015] Figure 3 is a flowchart of another virtual machine management method according to an embodiment of the present application;
[0016] Figure 4 is a flowchart of a virtual machine management method according to an embodiment of the present application;
[0017] Figure 5 is a structural block diagram of a virtual machine management device according to an embodiment of the present application. Detailed implementation manners
[0018] Hereinafter, embodiments of the present application will be described in detail with reference to the accompanying drawings and in conjunction with the embodiments.
[0019] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances, so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or are inherent to these processes, methods, products, or devices.
[0020] As an optional solution, the virtual machine management method has specific steps as Figure 1 shown and includes:
[0021] S102. Based on the central processing unit (CPU) waiting time of the candidate virtual machine, determine the first virtual machine score corresponding to the candidate virtual machine, where the CPU waiting time is the time when the candidate virtual machine is stopped from running due to the CPU resources of the first physical machine being occupied by other virtual machines, and the first physical machine is the host machine of the candidate virtual machine; based on the memory usage rate of the candidate virtual machine, determine the second virtual machine score corresponding to the candidate virtual machine, where the memory usage rate is used to indicate the ratio of the memory resources already used by the candidate virtual machine to the total memory resources of the first physical machine; based on the quantity of the first service resources stored in the first disk of the first physical machine, determine the third virtual machine score corresponding to the candidate virtual machine, where the first service resources are the service resources managed by the candidate virtual machine.
[0022] Optionally, the above method for managing virtual machines can be but is not limited to being applied to the scenario of managing virtual machines in a virtualized environment. Specifically, a virtualized environment is a technology that can simulate multiple independent computer systems on a physical computer. These computer systems can run their respective operating systems and application programs without interfering with each other. Since multiple virtual machines may be running on a single physical machine in a virtualized environment, as the business develops, the resource requirements of the virtual machines may increase, and the original host machine may not be able to meet these requirements, so it is necessary to switch to a host machine with stronger performance.
[0023] Furthermore, the above CPU waiting time can be but is not limited to being used to indicate the CPU steal time of a candidate virtual machine. The CPU steal time is the waiting time that occurs in a virtualized environment when the hypervisor steals CPU resources from a virtual machine to meet the needs of other virtual machines. In virtual machine performance monitoring, Steal Time is usually used as an indicator to show the time spent by the virtual machine OS waiting for the hypervisor to provide CPU resources. This indicates that the virtual machine does not get enough CPU time, which may be caused by resource contention on the physical host. A high Steal Time usually means that the CPU resources of the virtual machine are insufficient, and it may be necessary to adjust the resource allocation or optimize the virtual machine configuration to ensure that the virtual machine can get enough CPU time to run its workload. In some virtualized environments, Steal Time can also be used to detect whether it is necessary to increase the CPU resources of the physical host to better support all the virtual machines running on it.
[0024] Optionally, in some embodiments, a first virtual machine score corresponding to a candidate virtual machine can be determined based on the CPU waiting time of the candidate virtual machine according to a predetermined calculation rule. Here, the first virtual machine score is inversely proportional to the CPU waiting time. In this embodiment, the specific implementation manner of determining the first virtual machine score corresponding to the candidate virtual machine based on the CPU waiting time of the candidate virtual machine is not limited.
[0025] For example, the above first virtual score can be calculated in the following way:
[0026] Assume that a maximum score value M and a constant K based on system performance or configuration are defined. Then the first virtual machine score S1 can be defined as: S1 = M - K × CPU waiting time. Here, K is a positive number used to adjust the sensitivity of the score.
[0027] For another example, the above first virtual score can also be calculated in the following way:
[0028] Still assume that a maximum score value M and a constant K based on system performance or configuration are defined. Then the first virtual machine score S1 can be defined as: S1 = M × e -K\CPU等待时间 , where M and K are defined as above. e is the base of the natural logarithm, approximately equal to 2.71828.
[0029] It should be noted that the above examples are all optional embodiments provided for the convenience of explaining the above steps, and there is no limitation on the calculation method of the above first virtual machine score. Other calculation methods can also be used to calculate the above first virtual machine score.
[0030] Optionally, in some embodiments, the second virtual machine score corresponding to the candidate virtual machine can also be determined according to a predetermined calculation rule based on the memory usage rate of the candidate virtual machine. Among them, the second virtual machine score is inversely proportional to the memory usage rate. In this embodiment, the specific implementation method of the second virtual machine score is not limited.
[0031] For example, the above second virtual score can be calculated in the following way:
[0032] Assume that the total memory resource is T (T is a constant representing the total memory resource of the first physical machine). The second virtual machine score S2 can be defined as: S2 = T - M 1 × T, where, to ensure that the range of S2 is between 0 and 1, the following adjustment can be made: S2 = 1 - M 1 , where M 1 is used to represent the memory usage rate.
[0033] For another example, the above second virtual score can also be calculated in the following way: S2 = e -kM , where S2 is used to represent the second virtual machine score, and M 1 is used to represent the memory usage rate.
[0034] It should be noted that the above examples are all optional embodiments provided for the convenience of explaining the above steps, and there is no limitation on the calculation method of the above second virtual machine score. Other calculation methods can also be used to calculate the above second virtual machine score.
[0035] It should be noted that in some embodiments, a part of the first service resources of the candidate virtual machine can be stored in the host machine where it is located (i.e., the first physical machine). When the virtual machine reads data, it will preferentially access the local copy on the host machine to shorten the I / O latency and improve performance. The system will score according to the proportion of the data block of the virtual machine's copy owned by the node where the virtual machine is located. For example, if the host machine where the virtual machine runs has all the data blocks of a complete copy of it, then its storage score is 100%; if it only has some copies, it means that the virtual machine needs to read data across the network when accessing data, then the storage score of the virtual machine will decrease, and the other first service resources of the candidate virtual machine can be stored at the remote storage end, and when the virtual machine obtains this part of the resources, it needs to communicate through the remote storage end to obtain them.
[0036] Optionally, in some embodiments, the third virtual machine score corresponding to the candidate virtual machine can also be determined according to a predetermined calculation rule based on the quantity of the first service resources stored in the first disk of the first physical machine, where the third virtual machine score is proportional to the quantity of the first service resources. In this embodiment, the specific implementation manner of the third virtual machine score is not limited.
[0037] For example, the above-mentioned third virtual score can be calculated in the following way: S3 = k × the quantity of the first service resources, where (k) is a constant representing the contribution degree of each first service resource to the score, and S3 is used to represent the third virtual machine score.
[0038] For another example, the above-mentioned third virtual score can also be calculated in the following way: S3 = k × e beta ×第一业务资源数量÷资源总量 , where both k and beta are adjustment coefficients, and beta controls the growth rate of the score. When beta > 0, the third virtual machine score grows exponentially, where the above-mentioned total resource quantity is used to represent the total quantity of the first service resources corresponding to the candidate virtual machine.
[0039] It should be noted that the above examples are all optional embodiments provided for the convenience of explaining the above steps, and there is no limitation on the calculation method of the above-mentioned third virtual machine score. Other calculation methods can also be used to calculate the above-mentioned third virtual machine score.
[0040] S104. Use the first virtual machine score, the second virtual machine score, and the third virtual machine score to determine the target virtual machine score corresponding to the candidate virtual machine, and when the target virtual machine score reaches the first threshold and the candidate virtual machine meets the migration conditions of the virtual machine, determine the candidate virtual machine as the target virtual machine to be migrated.
[0041] Optionally, in some embodiments, determining the target virtual machine score corresponding to the candidate virtual machine by using the first virtual machine score, the second virtual machine score, and the third virtual machine score may include, but is not limited to: determining a first target virtual machine score based on the first virtual machine score and the first weight; determining a second target virtual machine score based on the second virtual machine score and the second weight, where the second weight is less than the first weight; determining a third target virtual machine score based on the third virtual machine score and the third weight, where the third weight is equal to the second weight; and determining the target virtual machine score by using the first target virtual machine score, the second target virtual machine score, and the third target virtual machine score.
[0042] It should be noted that, in some embodiments, determining the candidate virtual machine as the target virtual machine to be migrated when the target virtual machine score reaches the first threshold and the candidate virtual machine meets the migration conditions of the virtual machine may include, but is not limited to: determining the candidate virtual machine as the target virtual machine to be migrated when the target virtual machine score is less than the first threshold and the candidate virtual machine meets the migration conditions of the virtual machine. In addition, in the case of multiple candidate virtual machines, the candidate virtual machine whose corresponding target virtual machine score is less than the first threshold, and whose target virtual machine score is the smallest among the target virtual machine scores of all candidate virtual machines and meets the migration conditions will be determined as the target virtual machine.
[0043] It should be noted that, before determining the target virtual machine score corresponding to the candidate virtual machine by using the first virtual machine score, the second virtual machine score, and the third virtual machine score, and determining the candidate virtual machine as the target virtual machine to be migrated when the target virtual machine score reaches the first threshold and the candidate virtual machine meets the migration conditions of the virtual machine, it may include, but is not limited to: determining the memory resource occupancy of the candidate virtual machine for the memory resources of the first physical machine; and determining that the candidate virtual machine meets the migration conditions when the memory resource occupancy is less than the third threshold.
[0044] S106. Determine the first physical machine score corresponding to the candidate physical machine based on the CPU idle time of the candidate physical machine, where the CPU idle time is the time when the CPU of the candidate physical machine is in the idle state within the first time period; determine the second physical machine score corresponding to the candidate physical machine based on the available memory amount of the candidate physical machine, where the available memory amount is the remaining memory amount of the candidate physical machine; determine the third physical machine score corresponding to the candidate physical machine based on the number of virtual machine service resources stored in the second disk of the candidate physical machine.
[0045] Optionally, in some embodiments, the CPU idle time of the above candidate physical machine can be used, but is not limited to, indicating the CPU idle time of the candidate physical machine. The more the idle time, the higher the score of the first physical machine of the candidate physical machine. Conversely, the busier the CPU of the candidate physical machine, the lower the score of the first physical machine of the candidate physical machine.
[0046] Optionally, in some embodiments, a first physical machine score corresponding to the candidate physical machine can be determined based on the CPU idle time of the candidate physical machine according to a predetermined calculation rule. Among them, the first physical machine score is proportional to the CPU idle time. The CPU idle time is the time when the CPU of the candidate physical machine is in an idle state within the first time period. In this embodiment, the specific implementation manner of scoring the third virtual machine is not limited.
[0047] For example, the above first physical machine score can be calculated in the following way: W1 = alpha × CPU idle time + beta, where alpha and beta are adjustment coefficients and can be set according to actual requirements. For example, if it is desired that the score increases by 0.5 for each 1-unit increase in the idle time, then alpha = 0.5; if a base score needs to be set, beta can be set; Wl is used to represent the first physical machine score.
[0048] For another example, the above first physical machine score can also be calculated in the following way: W1 = alpha × e beta ×CPU空闲时间 , where alpha and beta are also adjustment coefficients. Selecting beta > 0 can ensure that the score increases as the CPU idle time increases; alpha is used to adjust the starting value and growth rate of the score.
[0049] It should be noted that the above examples are all optional embodiments provided for the convenience of explaining the above steps, and there is no limitation on the calculation method of the above first physical machine score. Other calculation methods can also be used to calculate the above first physical machine score.
[0050] Optionally, in some embodiments, determining the second physical machine score corresponding to the candidate physical machine based on the available memory amount of the candidate physical machine can include, but is not limited to: determining the second physical machine score corresponding to the candidate physical machine based on the ratio of the available memory amount of the candidate physical machine to the total memory amount of the candidate physical machine. In other words, the system collects the available memory ratio of the host and scores according to whether there is memory overcommitment on the host. In the case of no overcommitment, the more available memory, the higher the score.
[0051] Optionally, in some embodiments, a second physical machine score corresponding to the candidate physical machine may be determined based on the available memory amount of the candidate physical machine according to a predetermined calculation rule, where the second physical machine score is proportional to the available memory amount. In this embodiment, the specific implementation manner of the second virtual machine score is not limited.
[0052] For example, the above second physical machine score may be calculated in the following manner:
[0053] W2 = k × available memory amount ÷ total memory amount, where the total memory amount is used to indicate the total memory capacity of the candidate physical machine, and k is a proportionality factor, which may be a constant preset according to the system design. For example, k = 0.01, indicating that for every 1 MB increase in memory, the score increases by 0.01 points. The above W2 is used to indicate the above second physical machine score.
[0054] For another example, the above second physical machine score may also be calculated in the following manner: W2 = (available memory amount ÷ total memory amount)p, where p is a power parameter p>0, and its size can be adjusted according to requirements. For example, if p = 2, the second physical machine score will increase with the square of the available memory amount.
[0055] It should be noted that the above examples are all optional embodiments provided for the convenience of explaining the above steps, and there is no limitation on the calculation method of the above second physical machine score. Other calculation methods may also be used to calculate the above second physical machine score.
[0056] Optionally, in some embodiments, determining the third physical machine score corresponding to the candidate physical machine based on the number of virtual machine service resources stored in the second disk of the candidate physical machine may include, but is not limited to: determining the third physical machine score corresponding to the candidate physical machine based on the proportion of the number of virtual machine service resources stored in the second disk of the candidate physical machine to the total number of virtual machine service resources corresponding to the virtual machines. In other words, the built-in storage engine of the hyper-converged storage supports automatic balancing of storage capacity, so the host storage score is not evaluated based on the usage rate of the host local storage capacity. The host storage score mainly focuses on the proportion of data blocks of virtual machine replicas owned by the host. The higher the ownership ratio, the higher the score.
[0057] Optionally, in some embodiments, a third physical machine score corresponding to the candidate physical machine may be determined based on the number of virtual machine service resources stored in the second disk of the candidate physical machine according to a predetermined calculation rule, where the third physical machine score is proportional to the number of virtual machine service resources stored in the second disk. In this embodiment, the specific implementation manner of the third virtual machine score is not limited.
[0058] For example, the above third physical machine score may be calculated in the following manner:
[0059] W3 = a × (the number of business resources) ÷ (the total number of business resources) + b, where the total number of business resources is used to indicate the total number of business resources corresponding to all virtual machines with the candidate physical machine as the host machine, a and b are constants, a > 0 ensures that the score is proportional to the resource quantity, and b is the baseline score. The values of these two constants can be adjusted according to specific requirements.
[0060] For another example, the above-mentioned third physical machine score can also be calculated in the following way:
[0061] W3 = c × e d×业务资源的数量÷总业务资源的数量 , where c and d are constants, and it is necessary to ensure that c > 0 and d > 0.
[0062] It should be noted that the above examples are all optional embodiments provided for the convenience of explaining the above steps, and there is no limitation on the calculation method of the above-mentioned third physical machine score. Other calculation methods can also be used to calculate the above-mentioned third physical machine score.
[0063] S108. Use the first physical machine score, the second physical machine score, and the third physical machine score to determine the target physical machine score corresponding to the candidate physical machine, and when the target physical machine score reaches the second threshold, determine the candidate physical machine as the target physical machine.
[0064] It should be noted that in some embodiments, the above-mentioned determining the candidate physical machine as the target physical machine to be migrated when the target physical machine score reaches the second threshold may but is not limited to including: determining the candidate physical machine as the target physical machine to be migrated when the target physical machine score is greater than the second threshold. In addition, in the case of multiple candidate physical machines, the candidate physical machine with the target physical machine score greater than the second threshold and the largest ranking among the target physical machine scores of all candidate physical machines will be determined as the target physical machine.
[0065] Optionally, in some embodiments, the above-mentioned using the first physical machine score, the second physical machine score, and the third physical machine score to determine the target physical machine score corresponding to the candidate physical machine may but is not limited to including: determining the first target physical machine score based on the first physical machine score and the fourth weight; determining the second target physical machine score based on the second physical machine score and the fifth weight, where the fifth weight is less than the fourth weight; determining the third target physical machine score based on the third physical machine score and the sixth weight, where the sixth weight is equal to the fifth weight; using the first target physical machine score, the second target physical machine score, and the third target physical machine score to determine the target physical machine score.
[0066] S110. Migrate the target virtual machine to the target physical machine for running.
[0067] It should be noted that, in some embodiments, the above-mentioned step S202 and the above-mentioned step S206 are executed in parallel, and the above-mentioned step S204 and the above-mentioned step S208 can also be executed in parallel. There is no limitation in this regard in the above-mentioned embodiments.
[0068] Furthermore, it should be noted that the above-mentioned steps S202 to the above-mentioned step S210 can be, but are not limited to, executed by a virtualization management technology module (Distributed Resource Scheduler, abbreviated as DRS). DRS is an advanced virtualization management technology mainly used to achieve optimized resource allocation and load balancing in a data center. DRS can automatically monitor and analyze the resource usage of virtual machines, such as CPU, memory, storage, and network, etc., and then automatically adjust the distribution of virtual machines on physical hosts according to preset policies and rules to ensure the efficient use of resources and the performance of virtual machines.
[0069] Through the embodiments provided in this application, based on the central processing unit (CPU) waiting time of a candidate virtual machine, determine the first virtual machine score corresponding to the candidate virtual machine, where the CPU waiting time is the time when the candidate virtual machine is stopped from running due to the CPU resources of the first physical machine being occupied by other virtual machines, and the first physical machine is the host machine of the candidate virtual machine; based on the memory usage rate of the candidate virtual machine, determine the second virtual machine score corresponding to the candidate virtual machine, where the memory usage rate is used to indicate the ratio between the memory resources already used by the candidate virtual machine and the total memory resources of the first physical machine; based on the quantity of the first service resources stored in the first disk of the first physical machine, determine the third virtual machine score corresponding to the candidate virtual machine, where the first service resources are the service resources managed by the candidate virtual machine; use the first virtual machine score, the second virtual machine score, and the third virtual machine score to determine the target virtual machine score corresponding to the candidate virtual machine, and when the target virtual machine score reaches the first threshold and the candidate virtual machine meets the migration conditions of the virtual machine, determine the candidate virtual machine as the target virtual machine to be migrated; based on the CPU idle time of the candidate physical machine, determine the first physical machine score corresponding to the candidate physical machine, where the CPU idle time is the time when the CPU of the candidate physical machine is in an idle state within the first time period; based on the available memory amount of the candidate physical machine, determine the second physical machine score corresponding to the candidate physical machine, where the available memory amount is the remaining memory amount of the candidate physical machine; based on the quantity of the service resources of the virtual machines stored in the second disk of the candidate physical machine, determine the third physical machine score corresponding to the candidate physical machine; use the first physical machine score, the second physical machine score, and the third physical machine score to determine the target physical machine score corresponding to the candidate physical machine, and when the target physical machine score reaches the second threshold, determine the candidate physical machine as the target physical machine; migrate the target virtual machine to the target physical machine for running. In other words, by adopting the embodiments of this application, through the method of comprehensively evaluating the resource status of virtual machines and physical machines to replace the host machine of the virtual machine, the technical effect of dynamically and evenly allocating resources is achieved, and the technical problem of uneven resource allocation caused by the overly single management method of virtual machines in the related art is solved.
[0070] As an optional solution, using the first virtual machine score, the second virtual machine score, and the third virtual machine score to determine the target virtual machine score corresponding to the candidate virtual machine includes:
[0071] Step S1, determine the first target virtual machine score based on the first virtual machine score and the first weight.
[0072] Step S2, determine the second target virtual machine score based on the second virtual machine score and the second weight, where the second weight is less than the first weight.
[0073] Step S3, determine the third target virtual machine score based on the third virtual machine score and the third weight, where the third weight is equal to the second weight.
[0074] Step S4, determine the target virtual machine score by using the first target virtual machine score, the second target virtual machine score, and the third target virtual machine score.
[0075] For example, but not limited to, the above steps can be illustrated by the following example: S4 = a 1 ×S1 + a 2 ×S2 + a 3 ×S3, where S4 is used to represent the target virtual machine score, S1 is used to represent the first virtual machine score, S2 is used to represent the second virtual machine score, and S3 is used to represent the third virtual machine score.
[0076] It should be noted that the above example is an optional example provided for the convenience of explaining the above virtual machine management method, and there is no limitation on the specific implementation manner of the above virtual machine management method.
[0077] In the embodiment of the present application, the first target virtual machine score is determined based on the first virtual machine score and the first weight. Then, the second target virtual machine score is determined based on the second virtual machine score and the second weight, where the second weight is less than the first weight. Next, the third target virtual machine score is determined based on the third virtual machine score and the third weight, where the third weight is equal to the second weight. Furthermore, the target virtual machine score is determined by using the first target virtual machine score, the second target virtual machine score, and the third target virtual machine score. In other words, by adopting the embodiment of the present application, different weights can be assigned to the scores of different virtual machines to achieve a comprehensive consideration of different dimensions such as the performance, stability, and resource utilization rate of the virtual machines. The setting of the weights reflects the importance of each index in the overall evaluation, so that the final target virtual machine score can more comprehensively and accurately reflect the comprehensive performance of the virtual machine. In other words, the above target virtual machine score can effectively reflect the comprehensive performance of the virtual machine, thereby making the management of the virtual machine more effective and reasonable, and solving the technical problem of unbalanced resource allocation caused by the overly single management method of virtual machines in the prior art.
[0078] As an optional solution, determining the target physical machine score corresponding to the candidate physical machine by using the first physical machine score, the second physical machine score, and the third physical machine score includes:
[0079] Step S1, determine the first target physical machine score based on the first physical machine score and the fourth weight;
[0080] Step S2, determine the second target physical machine score based on the second physical machine score and the fifth weight, where the fifth weight is less than the fourth weight;
[0081] Step S3, determine the third target physical machine score based on the third physical machine score and the sixth weight, where the sixth weight is equal to the fifth weight;
[0082] Step S4, determine the target physical machine score by using the first target physical machine score, the second target physical machine score, and the third target physical machine score.
[0083] For example, the above steps can be but are not limited to being illustrated by the following example: W4 = a 4 ×W1 + a 5 ×W2 + a 6 ×W3, where W4 is used to represent the target physical machine score, W1 is used to represent the first physical machine score, W2 is used to represent the second physical machine score, and W3 is used to represent the third physical machine score.
[0084] It should be noted that the above example is an optional example provided for facilitating the explanation of the above virtual machine management method, and there is no limitation on the specific implementation manner of the above virtual machine management method.
[0085] In the embodiment of the present application, determine the first target physical machine score based on the first physical machine score and the fourth weight. Then, determine the second target physical machine score based on the second physical machine score and the fifth weight, where the fifth weight is less than the fourth weight. Next, determine the third target physical machine score based on the third physical machine score and the sixth weight, where the sixth weight is equal to the fifth weight. Furthermore, determine the target physical machine score by using the first target physical machine score, the second target physical machine score, and the third target physical machine score. That is to say, by adopting the embodiment of the present application, by assigning different weights to different physical machines, it can be ensured that physical machines with high priority or high requirements obtain more scoring weights, so that these physical machines are preferentially considered during resource allocation, realizing the optimization and reasonable allocation of resources.
[0086] As an optional solution, before determining the candidate virtual machine as the target virtual machine to be migrated when the target virtual machine score reaches the first threshold and the candidate virtual machine meets the migration conditions of the virtual machine, it further includes:
[0087] S1, determine the memory resource occupancy of the candidate virtual machine occupying the memory resources of the first physical machine.
[0088] S2, when the memory resource occupancy is less than the third threshold, determine that the candidate virtual machine meets the migration conditions.
[0089] It should be noted that for the dynamic adjustment of virtual machines, simply referring to the scores of virtual machines and hosts is still insufficient. Because not all situations require migrating virtual machines to hosts with higher scores, the migration cost also needs to be considered. Only when the benefits brought by migration are greater than the costs will DRS recommend or execute the migration action. For example, if a virtual machine has a large amount of memory and a relatively large amount of data needs to be transferred during migration, although the load will be more balanced after migration, if the time and resources consumed during this migration are excessive, then DRS will not recommend migrating the virtual machine.
[0090] In the embodiment of the present application, the memory resource occupancy of the candidate virtual machine occupying the memory resources of the first physical machine is determined. Then, when the memory resource occupancy is less than the third threshold, it is determined that the candidate virtual machine meets the migration condition. In other words, by adopting the embodiment of the present application, when the memory resource occupancy is less than the third threshold, it is judged that the candidate virtual machine meets the migration condition. This step can ensure that after the virtual machine is migrated, the resource load of the target physical machine (or target cluster) will not be overloaded, thereby ensuring the stability and performance of the system. The setting of the third threshold can prevent migration failures caused by insufficient resources or have a negative impact on the performance of the target physical machine after migration.
[0091] As an optional solution, before determining the candidate virtual machine as the target virtual machine to be migrated when the score of the target virtual machine reaches the first threshold and the candidate virtual machine meets the migration condition of the virtual machine, it further includes:
[0092] Determine the memory resource occupancy of the candidate virtual machine occupying the memory resources of the first physical machine;
[0093] When the memory resource occupancy is less than the third threshold, determine that the candidate virtual machine meets the migration condition.
[0094] As an optional solution, the score of the first physical machine is proportional to the CPU idle time; the score of the second physical machine is proportional to the available memory amount; the score of the third physical machine is proportional to the number of business resources of the virtual machines stored in the second disk.
[0095] As an optional example, it can be but is not limited to the following example shown as Figure 2 to illustrate the scoring calculation method of the virtual machine by way of example;
[0096] Execute step S202-1, step S202-2, and step S202-3:
[0097] Step S202-1, obtain the CPU waiting time of the virtual machine.
[0098] Step S202-2, calculate the memory usage rate.
[0099] Step S202-3: Calculate the proportion of replica data blocks on the host where it is located.
[0100] Then execute Step S204-1, Step S204-2, and Step S204-3:
[0101] Step S204-1: Determine the CPU score based on the CPU waiting time. Specifically, the system calculates the virtual machine CPU score through a corresponding formula by monitoring the Steal Time of the virtual machine CPU. The more severe the competition for virtual machine CPU resources, the lower the virtual machine CPU score.
[0102] Step S204-2: Determine the memory score based on the memory usage rate. Specifically, when there is no memory overcommitment, the virtual machine memory score should be 100% because there is no competition for memory resources. In the scenario of memory overcommitment, the system will monitor the degree of the virtual machine's use of shared memory. The higher the usage ratio, the more severe the resource competition and the lower the score.
[0103] Step S204-3: Determine the disk score based on the data block proportion. Specifically, the hyper-converged cluster has an I / O localization function. When the virtual machine reads data, it will preferentially access the replicas on the local host to shorten the I / O latency and improve performance. The system will score according to the proportion of replica data blocks of the virtual machine on the node where it is located. For example, if the host where the virtual machine runs has all the data blocks of a complete replica of it, then its storage score is 100%; if it only has some replicas, which means that the virtual machine needs to read data across the network when accessing data, then the storage score of the virtual machine will be reduced.
[0104] Then execute Step S206: Calculate the virtual machine score based on the CPU score, memory score, and disk score. For example, virtual machine score = CPU score × 50% + memory score × 25% + disk score × 25%.
[0105] As another optional example, it can be but is not limited to the following example shown as Figure 3 to illustrate the scoring calculation method of the host (physical machine):
[0106] Execute Step S302-1, Step S302-2, and Step S302-3:
[0107] Step S302-1: Obtain the idle time of the host CPU.
[0108] Step S302-2: Calculate the proportion of available memory of the host.
[0109] Step S302-3: Calculate the proportion of stored replica data blocks.
[0110] Then perform step S304-1, step S304-2, and step S304-3:
[0111] In step S304-1, determine the CPU score based on the CPU idle time. Specifically, the system collects the CPU idle time of the host. The more idle time, the higher the score. Conversely, the busier the host CPU, the lower the score.
[0112] In step S304-2, determine the memory score based on the proportion of available memory of the host. Specifically, the system collects the proportion of available memory of the host and scores according to whether there is memory overcommitment on the host. In the case of no overcommitment, the more available memory, the higher the score.
[0113] In step S304-3, determine the storage score based on the proportion of stored replica data blocks. Specifically, the storage engine built into the hyper-converged storage supports automatic balancing of storage capacity. Therefore, the host storage score is not evaluated based on the utilization rate of the local storage capacity of the host. The host storage score mainly focuses on the proportion of data blocks of virtual machine replicas owned by the host. The higher the proportion, the higher the score.
[0114] Then perform step S306, calculate the host score based on the CPU score, memory score, and disk score. For example, host score = CPU score × 50% + memory score × 25% + storage score × 25%.
[0115] As another optional example, it can be but is not limited to the following example shown as Figure 4 to give an illustrative explanation of organizing the above virtual machine management method:
[0116] Perform step S402-1 and step S402-2:
[0117] In step S402-1, calculate the virtual machine score periodically;
[0118] In step S402-2, calculate the host score periodically;
[0119] Then perform step S404-1, step S406, and step S404-2:
[0120] Perform step S404-1, determine whether the virtual machine score is the minimum value. In the case where the virtual machine score is the minimum value, perform step S406 to determine whether the virtual machine meets the migration conditions. In the case where the virtual machine score is not the minimum value, abandon the migration;
[0121] Perform step S404-2, determine whether the host score is the maximum value. In the case where the host score is not the maximum value, do not migrate to this host;
[0122] Then, when it is determined that the virtual machine meets the migration conditions and the host score is the maximum value, step S408 is executed to migrate the virtual machine to the host.
[0123] In this embodiment, a virtual machine management device is also provided. This device is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used hereinafter, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0124] Figure 5 is a structural block diagram of a virtual machine management device according to an embodiment of the present application, as Figure 5 shown, the device includes:
[0125] A first determination unit 502, configured to determine a first virtual machine score corresponding to a candidate virtual machine based on the central processing unit (CPU) waiting time of the candidate virtual machine. The CPU waiting time is the time when the candidate virtual machine is stopped from running due to the CPU resources of the first physical machine being occupied by other virtual machines, and the first physical machine is the host of the candidate virtual machine; determine a second virtual machine score corresponding to the candidate virtual machine based on the memory usage rate of the candidate virtual machine, where the memory usage rate is used to indicate the ratio between the memory resources used by the candidate virtual machine and the total memory resources of the first physical machine; determine a third virtual machine score corresponding to the candidate virtual machine based on the quantity of the first service resources stored in the first disk of the first physical machine, where the first service resources are the service resources managed by the candidate virtual machine;
[0126] A second determination unit 504, configured to use the first virtual machine score, the second virtual machine score, and the third virtual machine score to determine the target virtual machine score corresponding to the candidate virtual machine, and when the target virtual machine score reaches a first threshold and the candidate virtual machine meets the migration conditions of the virtual machine, determine the candidate virtual machine as the target virtual machine to be migrated;
[0127] A third determination unit 506, configured to determine a first physical machine score corresponding to a candidate physical machine based on the CPU idle time of the candidate physical machine. The CPU idle time is the time when the CPU of the candidate physical machine is in an idle state within a first time period; determine a second physical machine score corresponding to the candidate physical machine based on the available memory amount of the candidate physical machine, where the available memory amount is the remaining memory amount of the candidate physical machine; determine the third physical machine score corresponding to the candidate physical machine based on the quantity of the service resources of the virtual machine stored in the second disk of the candidate physical machine;
[0128] A fourth determination unit 508, configured to determine a target physical machine score corresponding to a candidate physical machine by using the first physical machine score, the second physical machine score, and the third physical machine score, and determine the candidate physical machine as the target physical machine when the target physical machine score reaches a second threshold;
[0129] A migration unit 510, configured to migrate the target virtual machine to the target physical machine for running.
[0130] As an alternative solution, the second determination unit includes: a first determination module, configured to determine a first target virtual machine score based on the first virtual machine score and a first weight; a second determination module, configured to determine a second target virtual machine score based on the second virtual machine score and a second weight, where the second weight is less than the first weight; a third determination module, configured to determine a third target virtual machine score based on the third virtual machine score and a third weight, where the third weight is equal to the second weight; a fourth determination module, configured to determine a target virtual machine score by using the first target virtual machine score, the second target virtual machine score, and the third target virtual machine score.
[0131] As an alternative solution, the fourth determination unit includes: a fifth determination module, configured to determine a first target physical machine score based on the first physical machine score and a fourth weight; a sixth determination module, configured to determine a second target physical machine score based on the second physical machine score and a fifth weight, where the fifth weight is less than the fourth weight; a seventh determination module, configured to determine a third target physical machine score based on the third physical machine score and a sixth weight, where the sixth weight is equal to the fifth weight; an eighth determination module, configured to determine a target physical machine score by using the first target physical machine score, the second target physical machine score, and the third target physical machine score.
[0132] As an alternative solution, the apparatus further includes: a fifth determination unit, configured to determine a memory resource occupancy of the candidate virtual machine for occupying the memory resources of the first physical machine; a sixth determination unit, configured to determine that the candidate virtual machine meets the migration condition when the memory resource occupancy is less than a third threshold.
[0133] Specific examples in this embodiment may refer to the examples described in the above embodiments and exemplary embodiments, and will not be elaborated herein.
[0134] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such an understanding, the technical solution of the present application, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to enable a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present application.
[0135] It should be noted that the above-mentioned various modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above modules are all located in the same processor; or, the above-mentioned various modules are respectively located in different processors in any combination form.
[0136] The embodiments of the present application also provide a computer-readable storage medium, in which a computer program is stored. Among them, the computer program is set to execute the steps in any one of the above method embodiments when running.
[0137] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: USB flash drive, read-only memory (abbreviated as ROM), random access memory (abbreviated as RAM), mobile hard disk, magnetic disk, or optical disk and other various media that can store computer programs.
[0138] The embodiments of the present application also provide an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is set to run the computer program to execute the steps in any one of the above method embodiments.
[0139] In an exemplary embodiment, the above electronic device may further include a transmission device and an input / output device. Among them, the transmission device is connected to the above processor, and the input / output device is connected to the above processor.
[0140] The embodiments of the present application also provide a computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program product, and the computer program, when executed by a processor, implements the steps of the methods described in various embodiments of the present application.
[0141] The specific examples in this embodiment can refer to the examples described in the above embodiments and exemplary embodiments, and will not be repeated here.
[0142] Obviously, those skilled in the art should understand that the various modules or steps of the present application described above can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module for implementation. In this way, the present application is not limited to any specific combination of hardware and software.
[0143] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the principle of the present application shall be included within the protection scope of the present application.
Claims
1. A method for managing a virtual machine, characterized in that: include: Based on the CPU waiting time of the candidate virtual machine, a first virtual machine score corresponding to the candidate virtual machine is determined, wherein the CPU waiting time is the time when the candidate virtual machine is stopped because the CPU resources of the first physical machine are occupied by other virtual machines, and the first physical machine is the host machine of the candidate virtual machine; based on the memory usage rate of the candidate virtual machine, a second virtual machine score corresponding to the candidate virtual machine is determined, wherein the memory usage rate is used to indicate the ratio between the memory resources used by the candidate virtual machine and the total memory resources of the first physical machine; based on the number of first business resources stored in the first disk of the first physical machine, a third virtual machine score corresponding to the candidate virtual machine is determined, wherein the first business resources are business resources managed by the candidate virtual machine; Determine a target virtual machine score corresponding to the candidate virtual machine by using the first virtual machine score, the second virtual machine score, and the third virtual machine score, and determine the candidate virtual machine as a target virtual machine to be migrated if the target virtual machine score reaches a first threshold and the candidate virtual machine meets a migration condition of the virtual machine; Based on the CPU idle time of the candidate physical machine, determine the first physical machine score corresponding to the candidate physical machine, wherein the CPU idle time is the time during which the CPU of the candidate physical machine is in an idle state within a first time period; based on the available memory of the candidate physical machine, determine the second physical machine score corresponding to the candidate physical machine, wherein the available memory is the remaining memory of the candidate physical machine; based on the number of business resources of the virtual machine stored in the second disk of the candidate physical machine, determine the third physical machine score corresponding to the candidate physical machine; Determine a target physical machine score corresponding to the candidate physical machine by using the first physical machine score, the second physical machine score, and the third physical machine score, and determine the candidate physical machine as the target physical machine if the target physical machine score reaches a second threshold; The target virtual machine is migrated to the target physical machine for operation.
2. The virtual machine management method according to claim 1, characterized in that: The determining the target virtual machine score corresponding to the candidate virtual machine by using the first virtual machine score, the second virtual machine score, and the third virtual machine score includes: Determine a first target virtual machine score based on the first virtual machine score and a first weight; determining a second target virtual machine score based on the second virtual machine score and a second weight, wherein the second weight is less than the first weight; determining a third target virtual machine score based on the third virtual machine score and a third weight, wherein the third weight is equal to the second weight; The target virtual machine score is determined by using the first target virtual machine score, the second target virtual machine score, and the third target virtual machine score.
3. The virtual machine management method according to claim 1, characterized in that: The determining the target physical machine score corresponding to the candidate physical machine by using the first physical machine score, the second physical machine score, and the third physical machine score comprises: Determine a first target physical machine score based on the first physical machine score and a fourth weight; determining a second target physical machine score based on the second physical machine score and a fifth weight, wherein the fifth weight is less than the fourth weight; determining a third target physical machine score based on the third physical machine score and a sixth weight, wherein the sixth weight is equal to the fifth weight; The target physical machine score is determined by using the first target physical machine score, the second target physical machine score, and the third target physical machine score.
4. The method for managing a virtual machine according to any one of claims 1 to 3, characterized in that: In the case where the score of the target virtual machine reaches a first threshold and the candidate virtual machine meets the migration condition of the virtual machine, before determining the candidate virtual machine as the target virtual machine to be migrated, the method further includes: Determine the memory resource occupation amount of the memory resource of the first physical machine occupied by the candidate virtual machine; When the memory resource usage is less than a third threshold, it is determined that the candidate virtual machine meets the migration condition.
5. The method for managing a virtual machine according to any one of claims 1 to 3, characterized in that: The first virtual machine score is inversely proportional to the CPU waiting time; the second virtual machine score is inversely proportional to the memory usage rate; and the third virtual machine score is directly proportional to the number of the first business resources.
6. The method for managing a virtual machine according to any one of claims 1 to 3, characterized in that: The first physical machine score is proportional to the CPU idle time; the second physical machine score is proportional to the available memory; and the third physical machine score is proportional to the number of business resources of the virtual machine stored in the second disk.
7. A virtual machine management device, characterized in that: include: A first determination unit is used to determine a first virtual machine score corresponding to the candidate virtual machine based on a central processing unit (CPU) waiting time of the candidate virtual machine, wherein the CPU waiting time is the time during which the candidate virtual machine is stopped because the CPU resources of a first physical machine are occupied by other virtual machines, and the first physical machine is a host machine of the candidate virtual machine; based on a memory usage rate of the candidate virtual machine, determine a second virtual machine score corresponding to the candidate virtual machine, wherein the memory usage rate is used to indicate a ratio between memory resources used by the candidate virtual machine and total memory resources of the first physical machine; based on the number of first business resources stored in a first disk of the first physical machine, determine a third virtual machine score corresponding to the candidate virtual machine, wherein the first business resources are business resources managed by the candidate virtual machine; a second determining unit, configured to determine a target virtual machine score corresponding to the candidate virtual machine by using the first virtual machine score, the second virtual machine score, and the third virtual machine score, and determine the candidate virtual machine as a target virtual machine to be migrated if the target virtual machine score reaches a first threshold and the candidate virtual machine meets a migration condition of the virtual machine; A third determination unit is used to determine a first physical machine score corresponding to the candidate physical machine based on the CPU idle time of the candidate physical machine, wherein the CPU idle time is the time during which the CPU of the candidate physical machine is in an idle state within a first time period; determine a second physical machine score corresponding to the candidate physical machine based on the available memory of the candidate physical machine, wherein the available memory is the remaining memory of the candidate physical machine; determine a third physical machine score corresponding to the candidate physical machine based on the number of business resources of the virtual machine stored in the second disk of the candidate physical machine; a fourth determining unit, configured to determine a target physical machine score corresponding to the candidate physical machine by using the first physical machine score, the second physical machine score, and the third physical machine score, and determine the candidate physical machine as the target physical machine if the target physical machine score reaches a second threshold; The migration unit is used to migrate the target virtual machine to the target physical machine for operation.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method according to any one of claims 1 to 6 when executed by a processor.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Virtual machine migration method in cloud computing environment
CN115794314A
Virtual machine migration method and related device
WO2021078256A1