Virtual machine migration method and device, equipment, storage medium and program product

By dynamically adjusting the host mode of the virtual machine in the host cluster, the low-utilization virtual machine is migrated to the power-saving mode host, and the normal virtual machine is migrated to the normal mode host, the high energy consumption problem caused by frequent power-offs in the existing technology is solved, and energy saving and emission reduction of the computing resource pool is achieved.

CN120335934APending Publication Date: 2025-07-18CHINA MOBILE GROUP ANHUI +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510472531.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

The prior art realizes energy saving by frequently turning on and off the server, resulting in high energy consumption and is not conducive to energy conservation and emission reduction, and cannot effectively reduce the energy consumption of the computing resource pool.

Method used

By obtaining the CPU and memory utilization in the host cluster, calculating the minimum and maximum number of hosts, and migrating the low-utilization virtual machines to the power-saving mode host, migrating the normal virtual machines to the normal mode host, dynamically adjusting the host where the virtual machine is located to achieve energy saving.

Benefits of technology

There is no need to turn on and off the server frequently, which realizes energy saving in the computing resource pool, reduces operation and maintenance costs and carbon emissions, and improves resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120335934A_ABST
    Figure CN120335934A_ABST
Patent Text Reader

Abstract

The invention discloses a virtual machine migration method and device, equipment, a storage medium and a program product. According to the total CPU amount of the single host machine, the total memory amount of the single host machine, the total CPU utilization amount sum of the first virtual machine, the total CPU utilization amount sum of the second virtual machine, the total memory utilization amount sum of the first virtual machine and the total memory utilization amount sum of the second virtual machine, the minimum number and the maximum number of the first host machines are obtained through calculation; the first virtual machine is a virtual machine with the utilization rate smaller than or equal to a preset first threshold value, the second virtual machine is a virtual machine with the utilization rate larger than the first threshold value, and the first host machine is a host machine in a power-saving mode; according to the minimum number and the maximum number, a first target number of the first host machines and a second target number of second host machines are determined, and the second host machines are host machines in a normal mode; migrating the first virtual machine to the first target number of first host machines, and migrating the second virtual machine to the second target number of second host machines.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of cloud computing technology, and particularly relates to a virtual machine migration method, device, equipment, storage medium and program product. Background Art

[0002] In recent years, with the explosive growth of data volume, the scale and quantity of computing resource pools have been continuously increasing, and the energy consumption of computing resource pools has been growing rapidly. This trend has two aspects of impacts: on the one hand, it continuously increases the operation and maintenance costs of computing resource pools, consuming a large amount of social resources and natural resources; on the other hand, the continuously increasing energy consumption also has a certain impact on the natural environment. The increase in power consumption leads to an increase in carbon emissions, which is not conducive to energy conservation and emission reduction. Therefore, reducing the energy consumption of computing resource pools is of great significance. The existing technology realizes energy conservation by directly shutting down servers with low utilization rates. However, the frequent startup and shutdown of servers consume more energy than the standby state. Summary of the Invention

[0003] Embodiments of this application provide a virtual machine migration method, device, equipment, storage medium and program product, which can achieve energy conservation without frequently starting and stopping servers.

[0004] In a first aspect, embodiments of this application provide a virtual machine migration method, which is applied to a first host cluster. The first host cluster includes N hosts, and each host runs at least one virtual machine. The method includes:

[0005] Obtain the total CPU of a single host in the first host cluster, the total memory of a single host, and the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total memory utilization of the first virtual machine, and the total memory utilization of the second virtual machine at a first moment. The first virtual machine is a virtual machine with a utilization rate less than or equal to a preset first threshold, and the second virtual machine is a virtual machine with a utilization rate greater than the first threshold;

[0006] Based on the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host, calculate the minimum number and the maximum number of the first host in the first host cluster at the first moment. The first host is the host in the N hosts in the power-saving mode;

[0007] Based on the minimum number and the maximum number, determine the first target number of the first host and the second target number of the second host. The second host is the host in the N hosts in the normal mode;

[0008] Set the number of the first host and the second host in the first host cluster according to the first target quantity and the second target quantity, and migrate the first virtual machines running in the first host cluster to the first target quantity of the first hosts, and migrate the second virtual machines running in the first host cluster to the second target quantity of the second hosts.

[0009] In a second aspect, an embodiment of the present application provides a virtual machine migration device, which is applied to a first host cluster. The first host cluster includes N hosts, and each host runs at least one virtual machine. The device includes:

[0010] A first acquisition module, configured to acquire the total CPU of a single host in the first host cluster, the total memory of a single host, and the total CPU utilization of the first virtual machines, the total CPU utilization of the second virtual machines, the total memory utilization of the first virtual machines, and the total memory utilization of the second virtual machines at a first moment. The first virtual machine is a virtual machine with a utilization rate less than or equal to a preset first threshold, and the second virtual machine is a virtual machine with a utilization rate greater than the first threshold;

[0011] A first calculation module, configured to calculate the minimum number and the maximum number of the first hosts in the first host cluster at the first moment according to the total CPU utilization of the first virtual machines, the total CPU utilization of the second virtual machines, the total CPU of a single host, the total memory utilization of the first virtual machines, the total memory utilization of the second virtual machines, and the total memory of a single host. The first host is a host in the N hosts in a power-saving mode;

[0012] A first determination module, configured to determine a first target quantity of the first host and a second target quantity of the second host according to the minimum number and the maximum number. The second host is a host in the N hosts in a normal mode;

[0013] A first migration module, configured to set the number of the first host and the second host in the first host cluster according to the first target quantity and the second target quantity, and migrate the first virtual machines running in the first host cluster to the first target quantity of the first hosts, and migrate the second virtual machines running in the first host cluster to the second target quantity of the second hosts.

[0014] In a third aspect, an embodiment of the present application provides an electronic device, which includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the virtual machine migration method described in any one of the above is implemented.

[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the virtual machine migration method described in any one of the above is implemented.

[0016] In a fifth aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device is caused to execute the virtual machine migration method described in any one of the above.

[0017] The virtual machine migration method, device, equipment, storage medium and program product of the embodiments of the present application are applied to a first host cluster. The first host cluster includes N hosts, and each host runs at least one virtual machine. It is possible to calculate the minimum number and the maximum number of the first hosts in the first host cluster at the first moment according to the total CPU utilization of the first virtual machines, the total CPU utilization of the second virtual machines, the total CPU of a single host, the total memory utilization of the first virtual machines, the total memory utilization of the second virtual machines, and the total memory of a single host. The first virtual machines are virtual machines with a utilization rate less than or equal to a preset first threshold, the second virtual machines are virtual machines with a utilization rate greater than the first threshold, and the first hosts are the hosts in the power-saving mode among the N hosts. Determine the first target number of the first hosts and the second target number of the second hosts according to the minimum number and the maximum number. The second hosts are the hosts in the normal mode among the N hosts. Set the number of the first hosts and the second hosts in the first host cluster according to the first target number and the second target number, and migrate the first virtual machines running in the first host cluster to the first target number of the first hosts, and migrate the second virtual machines running in the first host cluster to the second target number of the second hosts. In this way, in the embodiments of the present application, the virtual machines with low utilization rates are migrated to the hosts in the power-saving mode, and the normal virtual machines are migrated to the hosts in the normal mode, so that energy conservation can be achieved without frequently turning on and off the servers. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.

[0019] Figure 1 is a schematic flowchart of the virtual machine migration method provided by the embodiment of the present application;

[0020] Figure 2 is a schematic diagram of traversing the optimal number of hosts in the power-saving mode provided by the embodiment of the present application;

[0021] Figure 3 It is a schematic flowchart of an energy-saving function scenario embodiment provided by an embodiment of the present application;

[0022] Figure 4 It is a schematic diagram of cross-mode virtual machine migration provided by an embodiment of the present application;

[0023] Figure 5 It is a schematic diagram of a trigger migration condition instance provided by an embodiment of the present application;

[0024] Figure 6 It is a schematic diagram of cross-mode virtual machine migration provided by an embodiment of the present application;

[0025] Figure 7 It is a schematic diagram of cross-cluster virtual machine migration provided by an embodiment of the present application;

[0026] Figure 8 It is a schematic diagram of host type binding provided by an embodiment of the present application;

[0027] Figure 9 It is a schematic diagram of host resource collection provided by an embodiment of the present application;

[0028] Figure 10 It is a schematic diagram of risk diagnosis condition configuration provided by an embodiment of the present application;

[0029] Figure 11 It is a schematic diagram of risk diagnosis configuration provided by an embodiment of the present application;

[0030] Figure 12 It is a schematic diagram of solution execution provided by an embodiment of the present application;

[0031] Figure 13 It is a schematic diagram of virtual machine pre-migration report evaluation provided by an embodiment of the present application;

[0032] Figure 14 It is a schematic diagram of migration report details provided by an embodiment of the present application;

[0033] Figure 15 It is a real-time monitoring chart of the power of a power-saving mode server provided by an embodiment of the present application;

[0034] Figure 16 It is a real-time monitoring chart of the power of a normal mode server provided by an embodiment of the present application;

[0035] Figure 17 It is a schematic diagram of scheduling scheme recommendation 1 provided by an embodiment of the present application;

[0036] Figure 18 It is a schematic diagram of scheduling scheme recommendation 2 provided by an embodiment of the present application;

[0037] Figure 19 It is a schematic structural diagram of a virtual machine migration device provided by an embodiment of the present application;

[0038] Figure 20 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0039] The features and exemplary embodiments of various aspects of the present application will be described in detail below. For the purpose of making the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by showing examples of the present application.

[0040] It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, such that a process, method, article or device including a series of elements includes not only those elements, but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, the elements defined by the statement "comprising..." do not exclude the presence of additional identical elements in the process, method, article or device including the said elements.

[0041] In recent years, with the explosive growth of data volume, the scale and quantity of computing resource pools have been increasing continuously, and the energy consumption of computing resource pools has been growing rapidly. This trend has two aspects of impact: on the one hand, it continuously increases the operation and maintenance costs of computing resource pools, consuming a large amount of social resources and natural resources; on the other hand, the continuously increasing energy consumption also has a certain impact on the natural environment. The increase in power consumption leads to an increase in carbon emissions, which is not conducive to energy conservation and emission reduction. Therefore, reducing the energy consumption of computing resource pools is of great significance. The prior art realizes energy conservation by directly shutting down servers with low utilization rates. However, the frequent startup and shutdown of servers consume more energy than the standby state.

[0042] Central Processing Unit, CPU.

[0043] A host machine cluster can be formed by connecting multiple host machines (HMs) through a network to form a uniformly managed computing resource pool, such as a cloud service cluster.

[0044] A host machine can refer to a physical server that can host and run virtual machines or containers.

[0045] A virtual machine (VM) is a virtual computing environment created through virtualization technology and can run an operating system and applications like a physical computer.

[0046] To solve the problems of the prior art, embodiments of the present application provide a virtual machine migration method, apparatus, device, storage medium, and program product. First, the virtual machine migration method provided by the embodiments of the present application will be introduced below.

[0047] Figure 1 The flowchart of the virtual machine migration method provided by an embodiment of the present application is shown. As Figure 1 shown, a virtual machine migration method is applied to a first host machine cluster. The first host machine cluster includes N host machines, and each host machine runs at least one virtual machine. The above method may include the following steps S101 to S104:

[0048] S101. Obtain the total CPU of a single host machine in the first host machine cluster, the total memory of a single host machine, and the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total memory utilization of the first virtual machine, and the total memory utilization of the second virtual machine at the first moment. The first virtual machine is a virtual machine with a utilization rate less than or equal to a preset first threshold, and the second virtual machine is a virtual machine with a utilization rate greater than the first threshold;

[0049] S102. Calculate the minimum number and the maximum number of the first host machine in the first host machine cluster at the first moment according to the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host machine, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host machine. The first host machine is the host machine in the power-saving mode among the N host machines;

[0050] S103. Determine the first target number of the first host machine and the second target number of the second host machine according to the minimum number and the maximum number. The second host machine is the host machine in the normal mode among the N host machines;

[0051] S104. Set the number of the first host and the second host in the first host cluster according to the first target quantity and the second target quantity, and migrate the first virtual machines running in the first host cluster to the first target quantity of the first hosts, and migrate the second virtual machines running in the first host cluster to the second target quantity of the second hosts.

[0052] The virtual machine migration method according to the embodiment of the present application is applied to a first host cluster. The first host cluster includes N hosts, and each host runs at least one virtual machine. It is possible to calculate the minimum number and the maximum number of the first hosts in the first host cluster at the first moment according to the total CPU utilization of the first virtual machines, the total CPU utilization of the second virtual machines, the total CPU of a single host, the total memory utilization of the first virtual machines, the total memory utilization of the second virtual machines, and the total memory of a single host. The first virtual machines are virtual machines with a utilization rate less than or equal to a preset first threshold, the second virtual machines are virtual machines with a utilization rate greater than the first threshold, and the first hosts are the hosts in the power-saving mode among the N hosts; determine the first target quantity of the first hosts and the second target quantity of the second hosts according to the minimum quantity and the maximum quantity, where the second hosts are the hosts in the normal mode among the N hosts; set the number of the first hosts and the second hosts in the first host cluster according to the first target quantity and the second target quantity, and migrate the first virtual machines running in the first host cluster to the first target quantity of the first hosts, and migrate the second virtual machines running in the first host cluster to the second target quantity of the second hosts. In this way, in the embodiment of the present application, the virtual machines with low utilization rate are migrated to the hosts in the power-saving mode, and the normal virtual machines are migrated to the hosts in the normal mode, so that energy saving can be achieved without frequently turning on and off the servers.

[0053] In S101, the above-mentioned first host cluster may include N hosts, and N is a positive integer. Among them, each host runs at least one virtual machine.

[0054] The above-mentioned first virtual machines may be virtual machines with a utilization rate less than or equal to a preset first threshold. Exemplarily, they may be low-utilization virtual machines with a CPU utilization rate less than or equal to 1%. Of course, the first threshold is not limited to 1%, and can also be set according to actual needs, and no specific limitation is made here.

[0055] The above-mentioned second virtual machines may be virtual machines with a utilization rate greater than the first threshold. Exemplarily, a CPU usage rate higher than 1% is defined as a normal virtual machine.

[0056] The total CPU of a single host, that is, host.cpu, refers to the total computing power of the physical CPU of a single host.

[0057] The total memory of the above single host, i.e., host.ram, refers to the total physical memory available for a single host.

[0058] The total CPU utilization of the above first virtual machines can be the total CPU resources actually used by all the first virtual machines at the first moment. Exemplarily, it can be expressed as (vmS.cpu = vmS1.cpu +... + vmSn.cpu), where vmSn.cpu represents the CPU utilization of the nth low-utilization virtual machine.

[0059] The total CPU utilization of the above second virtual machines can be the total CPU resources actually used by all the second virtual machines at the first moment. Exemplarily, it can be expressed as (vmH.cpu = vmH1.cpu +... + vmHn.cpu), where vmHn.cpu represents the CPU utilization of the nth normal virtual machine.

[0060] The total memory utilization of the above first virtual machines can be the total memory actually used by all the first virtual machines at the first moment. Exemplarily, it can be expressed as (vmS.ram = vmS1.ram +... + vmSn.ram), where vmSn.ram represents the memory utilization of the nth low-utilization virtual machine.

[0061] The total memory utilization of the above second virtual machines can be the total memory actually used by all the second virtual machines at the first moment. Exemplarily, it can be expressed as (vmH.ram = vmH1.ram +... + vmHn.ram), where vmHn.ram represents the memory utilization of the nth normal virtual machine.

[0062] The above operations of obtaining the total CPU of a single host in the first host cluster, the total memory of a single host, and the total CPU utilization of the first virtual machines, the total CPU utilization of the second virtual machines, the total memory utilization of the first virtual machines, and the total memory utilization of the second virtual machines at the first moment can obtain estimated values based on the historical data before the first moment in the first host cluster. For example, data from the previous month before the first moment can be obtained, or data from the previous year before the first moment can be obtained in a weighted manner, giving higher weights to the data closer to the current time, so as to obtain data that is more stable and closer to the actual future operating conditions.

[0063] In S102, the above first host can be the host in the power-saving mode among the N hosts.

[0064] The minimum and maximum numbers of the first host in the first host cluster at the first moment are calculated based on the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host. Exemplarily, the minimum number of the first host in the first host cluster at the first moment can be calculated based on the total CPU utilization of the first virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, and the total memory of a single host. The minimum number is the maximum value of a first number and a second number. The first number is the smallest integer not less than the ratio of the total CPU utilization of the first virtual machine to the total CPU of a single host. The second number is the smallest integer not less than the ratio of the total memory utilization of the first virtual machine to the total memory of a single host. The maximum number of the first host in the first host cluster at the first moment is calculated based on the total CPU utilization of the second virtual machine, the total CPU of a single host, the total memory utilization of the second virtual machine, and the total memory of a single host. The maximum number is the difference between N and the maximum value of a third number and a fourth number. The third number is the smallest integer not less than the ratio of the total CPU utilization of the second virtual machine to the total CPU of a single host. The fourth number is the smallest integer not less than the ratio of the total memory utilization of the second virtual machine to the total memory of a single host.

[0065] In S103, the above-mentioned second host can be the host in the normal mode among the N hosts.

[0066] The first target number of the first host and the second target number of the second host are determined based on the minimum number and the maximum number. Exemplarily, the initial number of the first host can be determined based on the minimum number and the maximum number. The initial number is any value from the minimum number to the maximum number. When the second virtual machine runs on the second hosts with the difference between N and the initial number, the initial number is adjusted according to the CPU utilization rate and memory utilization rate of each second host to obtain the first candidate number. When the first virtual machine runs on the initial number of the first hosts, the initial number is adjusted according to the CPU utilization rate and memory utilization rate of each first host to obtain the second candidate number. The first target number of the first host is determined based on the first candidate number and the second candidate number. The first target number is the larger value of the first candidate number and the second candidate number. The second target number of the second host is determined based on the first target number. The second target number is the difference between N and the first target number.

[0067] In S104, the migration of the first virtual machine running in the first host cluster to the first target number of first hosts and the migration of the second virtual machine running in the first host cluster to the second target number of second hosts can, for example, be to traverse the first target number of first hosts and the second target number of second hosts in the first host cluster; when it is recognized that the utilization rate of the second host to be migrated out is higher than the preset second threshold, migrate at least one of the second virtual machines to be migrated out in the second host to be migrated out to the second host to be migrated in. The second host to be migrated out is any one of the second target number of second hosts, and the second host to be migrated in is a second host among the second target number of second hosts other than the second host to be migrated out, where the sum of the CPU utilization rate of the second host and the CPU utilization rate of at least one of the second virtual machines to be migrated out is less than the preset first safety threshold, and the sum of the memory utilization rate of the second host and the memory utilization rate of at least one of the second virtual machines to be migrated out is less than the preset second safety threshold; when it is recognized that the utilization rate of the first host to be migrated out is higher than the second threshold, migrate at least one of the first virtual machines to be migrated out in the first host to be migrated out to the first host to be migrated in. The first host to be migrated out is any one of the first target number of first hosts, and the first host to be migrated in is a first host among the first target number of first hosts other than the first host to be migrated out, where the sum of the CPU utilization rate of the first host and the CPU utilization rate of at least one of the first virtual machines to be migrated out is less than the first safety threshold, and the sum of the memory utilization rate of the first host and the memory utilization rate of at least one of the first virtual machines to be migrated out is less than the second safety threshold. Or, it can be that when it is recognized that there is at least one first virtual machine in the second host to be migrated out, migrate the first virtual machine in the second host to be migrated out to the target first host. The target first host is a first host among the first target number of first hosts, where the sum of the CPU utilization rate of the first host and the CPU utilization rate of at least one first virtual machine is less than the first safety threshold, and the sum of the memory utilization rate of the first host and the memory utilization rate of at least one first virtual machine is less than the second safety threshold; when it is recognized that there is at least one second virtual machine in the first host to be migrated out, migrate the second virtual machine in the first host to be migrated out to the target second host. The target second host is a second host among the second target number of second hosts, where the sum of the CPU utilization rate of the second host and the CPU utilization rate of at least one second virtual machine is less than the first safety threshold, and the sum of the memory utilization rate of the second host and the memory utilization rate of at least one second virtual machine is less than the second safety threshold.It can also be that, in the case where there is no migration to the second host, migration to the first host, the target first host, or the target second host in the first host cluster, a migration request is sent to the second host cluster, so that the second host cluster responds to the migration request and migrates the first virtual machine and / or the second virtual machine migrated out of the first host and / or the second host in the first host cluster to the target host, where the target host is a host in the multiple hosts of the second host cluster whose CPU utilization rate and memory utilization rate meet the preset rules.

[0068] In some embodiments, the above S102 may specifically include:

[0069] According to the total CPU utilization of the first virtual machines, the total CPU of a single host, the total memory utilization of the first virtual machines, and the total memory of a single host, calculate the minimum number of first hosts in the first host cluster at the first moment. The minimum number is the maximum value of the first quantity and the second quantity. The first quantity is the smallest integer not less than the ratio of the total CPU utilization of the first virtual machines to the total CPU of a single host, and the second quantity is the smallest integer not less than the ratio of the total memory utilization of the first virtual machines to the total memory of a single host.

[0070] According to the total CPU utilization of the second virtual machines, the total CPU of a single host, the total memory utilization of the second virtual machines, and the total memory of a single host, calculate the maximum number of first hosts in the first host cluster at the first moment. The maximum number is the difference between N and the maximum value of the third quantity and the fourth quantity. The third quantity is the smallest integer not less than the ratio of the total CPU utilization of the second virtual machines to the total CPU of a single host, and the fourth quantity is the smallest integer not less than the ratio of the total memory utilization of the second virtual machines to the total memory of a single host.

[0071] The above minimum number can be the maximum value of the first quantity and the second quantity, that is, S = Max(Ceil(vmS.cpu / host.cpu), Ceil(vmS.ram / host.ram)), which represents how many hosts' CPU resources and memory resources are required to run all the virtual machines with low utilization rates, and the larger value is taken to be able to run all the virtual machines. Then, S number of hosts can be turned on as power-saving mode hosts to only run the virtual machines with low utilization rates. For a stable cloud platform, the CPU occupancy and memory occupancy of the virtual machines need to be increased during the calculation according to the historical virtual machine situation, and a space is reserved to avoid sudden increase during the initialization of the service. ceil() returns the smallest integer not less than the provided value.

[0072] The above first quantity can be the smallest integer not less than the ratio of the sum of the CPU usages of the first virtual machines to the total CPU of a single host, that is, Ceil(vmS.cpu / host.cpu).

[0073] The above second quantity can be the smallest integer not less than the ratio of the sum of the memory usages of the first virtual machines to the total memory of a single host, that is, Ceil(vmS.ram / host.ram).

[0074] The above maximum quantity can be the difference between N and the maximum of the third quantity and the fourth quantity, that is, H = N - Max(Ceil(vmH.cpu / host.cpu), Ceil(vmH.ram / host.ram)), which represents how many hosts in the normal mode are needed to provide CPU resources and memory resources to run all the normal virtual machines. After deducting the number of hosts required to run the normal virtual machines from the total number of hosts N, the remaining hosts can enable the power-saving mode.

[0075] The above third quantity can be the smallest integer not less than the ratio of the sum of the CPU usages of the second virtual machines to the total CPU of a single host, that is, Ceil(vmH.cpu / host.cpu).

[0076] The above fourth quantity can be the smallest integer not less than the ratio of the sum of the memory usages of the second virtual machines to the total memory of a single host, that is, Ceil(vmH.ram / host.ram).

[0077] In the embodiments of the present application, calculate how many hosts are needed to provide CPU resources and memory resources to run all the low-utilization virtual machines, and take the larger value among them to be able to run all the low-utilization virtual machines. Then, the corresponding number of hosts can be enabled as power-saving mode hosts to only run low-utilization virtual machines. Similarly, calculate how many hosts in the normal mode are needed to provide CPU resources and memory resources to run all the normal virtual machines. After deducting the number of hosts required to run the normal virtual machines from the total number of hosts N, the remaining hosts can enable the power-saving mode, so as to ensure the stable operation of all virtual machines in the first host cluster.

[0078] In some embodiments, the above S103 may specifically include:

[0079] Determine the initial number of the first host according to the minimum quantity and the maximum quantity, and the initial number is any value from the minimum quantity to the maximum quantity;

[0080] When the second virtual machines are running on the number of second hosts that is the difference between N and the initial number, adjust the initial number according to the CPU utilization rate and memory utilization rate of each second host to obtain the first candidate number;

[0081] When running the first virtual machine on the initial number of first hosts, adjust the initial number according to the CPU utilization rate and memory utilization rate of each first host to obtain the second candidate number;

[0082] Determine the first target number of the first host according to the first candidate number and the second candidate number, where the first target number is the larger value of the first candidate number and the second candidate number;

[0083] Determine the second target number of the second host according to the first target number, where the second target number is the difference between N and the first target number.

[0084] The above initial number can be any value M from the minimum number S to the maximum number H.

[0085] When running the second virtual machine on the second hosts with the difference between N and the initial number, adjust the initial number according to the CPU utilization rate and memory utilization rate of each second host to obtain the first candidate number. Exemplarily, in the custom mode hosts (N - M), that is, in the normal mode hosts, when the CPU occupancy rate of each host running the normal virtual machine is not less than the preset value (e.g., 50%), and the memory occupancy rate is not less than the preset value (e.g., 70%), record M1 = M - 1 (reduce the number of power-saving mode hosts), indicating that the current custom mode hosts cannot meet the usage requirements and the number of normal mode hosts needs to be increased to give priority to ensuring the service of normal virtual machines by normal mode hosts; otherwise, record the current value of the power-saving mode host M as M1.

[0086] When running the first virtual machine on the initial number of first hosts, adjust the initial number according to the CPU utilization rate and memory utilization rate of each first host to obtain the second candidate number. Exemplarily, in the power-saving mode hosts (M), when the CPU occupancy rate of each host running the low-utilization virtual machine is not less than the preset value (e.g., 30%), and the memory occupancy rate is not less than the preset value (e.g., 50%), record M2 = M + 1, indicating that the current number of power-saving mode hosts cannot meet the usage requirements and the number of power-saving mode hosts needs to be increased; otherwise, record the current value of M as M2.

[0087] Determine the first target number of the first host according to the first candidate number and the second candidate number. Exemplarily, if M1 > M2, take M1 as the final value of M; if M1 < M2, then take M2 as the final value of M.

[0088] In the embodiments of the present application, when it is possible to ensure the service of the normal-mode host to the normal-mode virtual machine, a larger number is taken as the number of power-saving mode hosts to ensure the energy-saving effect. Correspondingly, among the N hosts in the first host cluster, the hosts other than the power-saving mode hosts are normal-mode hosts to ensure the normal operation of the service.

[0089] As an implementation manner of the present application, the prior art is to further adjust the virtual machine migration plan by continuously tracking the power consumption after the server energy-saving adjustment. However, the method of tracking the power consumption and adjusting the migration plan according to the power has hysteresis and cannot adjust the migration of the virtual machine in a timely manner. To adjust the migration of the virtual machines in each host in a timely manner, after the above S104, the method may further include:

[0090] Obtain the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total memory utilization of the first virtual machine, and the total memory utilization of the second virtual machine at the second moment, where the second moment is the moment after a preset duration from the first moment;

[0091] Calculate the minimum number and the maximum number of the first host at the second moment according to the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host;

[0092] Determine the third target number of the first host and the fourth target number of the second host at the second moment according to the minimum number and the maximum number;

[0093] When the third target number is different from the first target number, adjust the number of the first host and the second host in the first host cluster according to the third target number and the fourth target number, and migrate the first virtual machine running in the first host cluster to the first host with the third target number, and migrate the second virtual machine running in the first host cluster to the second host with the fourth target number.

[0094] The above second moment may be the moment after a preset duration from the first moment, where the preset duration may be 1 hour or 6 hours, and the specific duration may be set according to the actual needs of the user and is not specifically limited here.

[0095] The process of calculating the minimum and maximum numbers of the first host at the second moment based on the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host is the same as the process of calculating the minimum and maximum numbers of the first host in the first host cluster at the first moment based on the above, and will not be repeated here.

[0096] The process of determining the third target number of the first host and the fourth target number of the second host at the second moment based on the minimum and maximum numbers is the same as the process of determining the first target number of the first host and the second target number of the second host based on the minimum and maximum numbers, and will not be repeated here.

[0097] In the embodiments of the present application, based on the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host at the second moment, calculate the third target number of the first host and the fourth target number of the second host at the second moment, and in the case where the third target number is different from the first target number, timely detect the change in the energy-saving demand in the first host cluster and timely adjust the migration of virtual machines in each host. In addition, setting a judgment interval of a preset duration to determine whether the M value needs to be changed can avoid frequent switching of the host state and ensure that the instances therein can run in a relatively stable state.

[0098] In some embodiments, the above S104 may specifically include:

[0099] Traverse the first target number of first hosts and the second target number of second hosts in the first host cluster;

[0100] In the case where it is recognized that the utilization rate of the second host to be migrated out is higher than a preset second threshold, migrate at least one of the migrated-out second virtual machines in the second host to be migrated out to the second host to be migrated in. The second host to be migrated out is any one of the second target number of second hosts, and the second host to be migrated in is a second host among the second target number of second hosts other than the second host to be migrated out, and the sum of the CPU utilization rate of the second host and the CPU utilization rate of at least one of the migrated-out second virtual machines is less than a preset first safety threshold, and the sum of the memory utilization rate of the second host and the memory utilization rate of at least one of the migrated-out second virtual machines is less than a preset second safety threshold.

[0101] When it is recognized that the utilization rate of the first source host is higher than the second threshold, migrate at least one of the first virtual machines to be migrated from the first source host to the first target host. The first source host is any one of the first target number of first source hosts. The first target host is a first source host among the first target number of first source hosts other than the first source host, where the sum of the CPU utilization rate of the first source host and the CPU utilization rates of at least one of the first virtual machines to be migrated from the first source host is less than the first safety threshold, and the sum of the memory utilization rate of the first source host and the memory utilization rates of at least one of the first virtual machines to be migrated from the first source host is less than the second safety threshold.

[0102] The above-mentioned second source host can be any one of the second target number of second source hosts.

[0103] The above-mentioned second target host can be a second source host among the second target number of second source hosts other than the second source host, where the sum of the CPU utilization rate of the second source host and the CPU utilization rates of at least one of the second virtual machines to be migrated from the second source host is less than the preset first safety threshold, and the sum of the memory utilization rate of the second source host and the memory utilization rates of at least one of the second virtual machines to be migrated from the second source host is less than the preset second safety threshold.

[0104] The above-mentioned first source host can be any one of the first target number of first source hosts.

[0105] The above-mentioned first target host can be a first source host among the first target number of first source hosts other than the first source host, where the sum of the CPU utilization rate of the first source host and the CPU utilization rates of at least one of the first virtual machines to be migrated from the first source host is less than the first safety threshold, and the sum of the memory utilization rate of the first source host and the memory utilization rates of at least one of the first virtual machines to be migrated from the first source host is less than the second safety threshold.

[0106] The above-mentioned migrating the at-least-one second virtual machine to be migrated out of the second host to the second host to be migrated in. Exemplarily, it may be to determine a migration order list of the at-least-one second virtual machine to be migrated out of the second host according to the CPU utilization rate of the at-least-one second virtual machine to be migrated out of the second host. The higher the CPU utilization rate, the higher the migration priority of the corresponding second virtual machine. Simulate the migration of each second virtual machine according to each migration priority in the migration order list, and when the CPU utilization rate of the second host to be migrated out is less than a preset first security threshold, determine the at-least-one second virtual machine to be migrated out of the second host. The number of the at-least-one second virtual machines to be migrated out is the minimum migration number in the migration order list. When the sum of the CPU utilization rates of the second hosts other than the second host to be migrated out among the second target number of second hosts and the CPU utilization rate of the at-least-one second virtual machine to be migrated out is less than the first security threshold, and the sum of the memory utilization rates of the second host and the at-least-one second virtual machine to be migrated out is less than a preset second security threshold, determine the second host as the second host to be migrated in. Migrate the at-least-one second virtual machine to be migrated out to the second host to be migrated in. Or it may be to determine a migration order list of the at-least-one second virtual machine to be migrated out of the second host according to the CPU utilization rate of the at-least-one second virtual machine to be migrated out of the second host. The higher the CPU utilization rate, the higher the migration priority of the corresponding second virtual machine. Simulate the migration of each second virtual machine according to each migration priority in the migration order list. When the CPU utilization rate of the second host to be migrated out is less than a preset first security threshold, determine the at-least-one second virtual machine to be migrated out of the second host. When the sum of the CPU utilization rates of the second hosts other than the second host to be migrated out among the second target number of second hosts and the CPU utilization rate of the at-least-one second virtual machine to be migrated out is less than the first security threshold, and the sum of the memory utilization rates of the second host and the at-least-one second virtual machine to be migrated out is less than a preset second security threshold, determine the second host as the second host to be migrated in. Migrate the at-least-one second virtual machine to be migrated out to the second host to be migrated in.

[0107] The above-mentioned migrating the at-least-one first virtual machine to be migrated out of the first host to the first host to be migrated in. The specific migration method is the same as the migration method of migrating the at-least-one second virtual machine to be migrated out of the second host to the second host to be migrated in above, and will not be repeated here.

[0108] In the embodiments of the present application, taking the host utilization rate as the judgment basis, when it is recognized that the utilization rate of the second host to be migrated out is higher than the preset second threshold, at least one of the second virtual machines to be migrated out on the second host to be migrated out is migrated to the second host to be migrated in. Or, when it is recognized that the utilization rate of the first host to be migrated out is higher than the second threshold, at least one of the first virtual machines to be migrated out on the first host to be migrated out is migrated to the first host to be migrated in. In this way, the same-mode migration scheduling of the virtual machines carried on the host can be realized, and the utilization rate of the host can be maintained within the safety threshold.

[0109] In some embodiments, the above-mentioned migrating at least one of the second virtual machines to be migrated out on the second host to be migrated out to the second host to be migrated in may specifically include:

[0110] According to the CPU utilization rate of at least one second virtual machine on the second host to be migrated out, determine the migration order list of at least one second virtual machine on the second host to be migrated out. The higher the CPU utilization rate, the higher the migration priority of the corresponding second virtual machine;

[0111] Simulate the migration of each second virtual machine according to the migration priorities in the migration order list, and when the CPU utilization rate of the second host to be migrated out is less than the preset first safety threshold, determine at least one of the second virtual machines to be migrated out on the second host to be migrated out. The number of at least one second virtual machine to be migrated out is the minimum migration number in the migration order list;

[0112] When the sum of the CPU utilization rates of the second hosts other than the second host to be migrated out among the second target number of second hosts and the CPU utilization rate of at least one second virtual machine to be migrated out is less than the first safety threshold, and the sum of the memory utilization rate of the second host to be migrated out and the memory utilization rate of at least one second virtual machine to be migrated out is less than the preset second safety threshold, determine the second host to be migrated in as the second host to be migrated in;

[0113] Migrate at least one of the second virtual machines to be migrated out to the second host to be migrated in.

[0114] The above-mentioned determining the migration order list of at least one second virtual machine on the second host to be migrated out according to the CPU utilization rate of at least one second virtual machine on the second host to be migrated out. Exemplarily, if the host host1 to be migrated out of the virtual machine carries vm1, vm2......vmn, and the risk index is the cpu utilization rate, then the virtual machines are sorted in the migration order according to the cpu utilization rate vm1.cpu>vm2.cpu>vm3.cpu.

[0115] In the above-mentioned migration order list, the higher the CPU utilization rate, the higher the migration priority of the corresponding second virtual machine.

[0116] The quantity of the at least one second virtual machine to be migrated out may be the minimum migration-out quantity when the CPU utilization rate of the second host to be migrated out in the migration sequence list is less than a preset first safety threshold.

[0117] Migrate each second virtual machine according to each migration priority in the migration sequence list, and when the CPU utilization rate of the second host to be migrated out is less than the preset first safety threshold, determine at least one second virtual machine to be migrated out of the second host. Exemplarily, it may be to calculate host1.cpu - vm1.cpu, host1.cpu - vm1.cpu - vm2.cpu, etc., until it is less than the host.cpu safety threshold (i.e., the first safety threshold), and find out the least number of vms to be migrated out, so as to reduce the quantity of virtual machines to be migrated out.

[0118] When the sum of the CPU utilization rates of the second hosts other than the second host to be migrated out and the CPU utilization rates of at least one second virtual machine to be migrated out among the second target quantity of second hosts is less than the first safety threshold, and the sum of the memory utilization rates of the second host and the memory utilization rates of at least one second virtual machine to be migrated out is less than a preset second safety threshold, determine the second host as the second host to be migrated in. Exemplarily, it may be:

[0119] hostx.cpu + vm1.cpu + vm2.cpu +... + vmn.cpu < hostcpu safety threshold;

[0120] hostx.ram + vm1.ram + vm2.ram +... + vmn.ram < hostram safety threshold (i.e., the second safety threshold);

[0121] hostx represents the host to be migrated in, and hostx can be migrated in only when the above two inequalities are satisfied.

[0122] The second host to be migrated in may be one or more. That is, when no single host meets the requirements, the virtual machines to be migrated out can be split and migrated into multiple hosts. Arrange the other hosts in ascending order of utilization rate, and preferentially try to migrate the virtual machines to the hosts with low utilization rate. If one host cannot meet the migration requirements, obtain the next host. That is, if the host with the lowest utilization rate can meet all the migration requirements, only one migration is needed, which can improve the processing efficiency.

[0123] In the embodiment of the present application, the virtual machines hosted in the host machine that need to migrate out the virtual machine are sorted according to the risk indicators from high to low, the list of virtual machines to be migrated out is calculated, and the virtual machines are simulated to be migrated out in the order of the virtual machine list until the risk indicator of the host machine meets the safety threshold, which can not only improve the processing efficiency, but also achieve the optimization effect of the maximum index with the minimum action.

[0124] As another implementation manner of the present application, in order to achieve the safe operation goal that the service performance meeting the energy-saving requirements of the host machine is not affected, the above S104 may further include:

[0125] In the case where at least one first virtual machine exists in the second host machine to be migrated out, the first virtual machine in the second host machine to be migrated out is migrated to the target first host machine, and the target first host machine is the first host machine among the first target number of first host machines, where the sum of the CPU utilization rate of the first host machine and the CPU utilization rate of at least one first virtual machine is less than the first safety threshold, and the sum of the memory utilization rate of the first host machine and the memory utilization rate of at least one first virtual machine is less than the second safety threshold;

[0126] In the case where at least one second virtual machine exists in the first host machine to be migrated out, the second virtual machine in the first host machine to be migrated out is migrated to the target second host machine, and the target second host machine is the second host machine among the second target number of second host machines, where the sum of the CPU utilization rate of the second host machine and the CPU utilization rate of at least one second virtual machine is less than the first safety threshold, and the sum of the memory utilization rate of the second host machine and the memory utilization rate of at least one second virtual machine is less than the second safety threshold.

[0127] The above target first host machine may be the first host machine among the first target number of first host machines, where the sum of the CPU utilization rate of the first host machine and the CPU utilization rate of at least one first virtual machine is less than the first safety threshold, and the sum of the memory utilization rate of the first host machine and the memory utilization rate of at least one first virtual machine is less than the second safety threshold.

[0128] The above target second host machine may be the second host machine among the second target number of second host machines, where the sum of the CPU utilization rate of the second host machine and the CPU utilization rate of at least one second virtual machine is less than the first safety threshold, and the sum of the memory utilization rate of the second host machine and the memory utilization rate of at least one second virtual machine is less than the second safety threshold.

[0129] In the embodiments of the present application, if the CPU utilization rate of the virtual machine in the power-saving mode exceeds a large value of the threshold (for example, exceeds the threshold by 43%) or the CPU utilization rate of the virtual machine in the normal mode is lower than the large value of the threshold (for example, lower than the threshold by 43%), cross-mode migration is triggered. Based on the CPU utilization rate index of the virtual machine in the power-saving mode, by scheduling sensitive virtual machines, the virtual machines can be freely scheduled between the power-saving mode and the normal mode, so as to achieve the safe operation goal that the service performance meeting the energy-saving requirements of the host is not affected. If there is a virtual machine with too high CPU utilization rate in the host in the power-saving mode, it means that it no longer belongs to the virtual machine with low utilization rate, and it is cross-mode migrated to the host in the normal mode to avoid excessive occupation of the resources of the host in the power-saving mode; similarly, if there is a virtual machine with too low CPU utilization rate in the host in the normal mode, it means that it no longer belongs to the normal virtual machine and the performance requirement is reduced, and it can be cross-mode migrated to the host in the power-saving mode to run, so as to leave running space for the normal virtual machines.

[0130] As another implementation manner of the present application, in order to achieve the safe operation goal that the service performance meeting the energy-saving requirements of the host is not affected, the above S104 may further include:

[0131] In the case that there is no virtual machine migrating into the second host, migrating into the first host, the target first host or the target second host in the first host cluster, a migration request is sent to the second host cluster, so that the second host cluster responds to the migration request and migrates the first virtual machine and / or the second virtual machine migrated out of the first host and / or the second host in the first host cluster to the target host, and the target host is the host in the multiple hosts of the second host cluster whose CPU utilization rate and memory utilization rate meet the preset rules.

[0132] The above migration request is used to instruct the second host cluster to migrate the first virtual machine and / or the second virtual machine migrated out of the first host and / or the second host in the first host cluster to the target host.

[0133] Among them, the target host may be the host in the multiple hosts of the second host cluster whose CPU utilization rate and memory utilization rate meet the preset rules. The preset rules may be:

[0134] hostx.cpu + vm1.cpu + vm2.cpu +... + vmn.cpu < hostcpu security threshold;

[0135] hostx.ram + vm1.ram + vm2.ram +... + vmn.ram < hostram security threshold.

[0136] hostx represents the target host to which the virtual machine is migrated. Only when the above two inequalities are satisfied can the virtual machine be migrated to hostx.

[0137] In the embodiments of the present application, when the utilization rate of the host reaches the critical value, or the CPU utilization rate of the sensitive virtual machine reaches the critical value, but there is no host in the cluster that meets the migration conditions, a migration request is sent to other cloud service clusters. The host that meets the conditions is preferably selected across the clusters to host the migrated virtual machine. The virtual machine can be freely scheduled between the power-saving mode and the normal mode across the clusters, so as to achieve the safe operation goal that the business performance meeting the energy-saving requirements of the host is not affected.

[0138] To facilitate the understanding of the virtual machine migration method in the embodiments of the present application, the actual application process of this virtual machine migration method is described as follows:

[0139] Step 1: To ensure the operation effect of the system, plan the number M (equivalent to the above first target number) of the hosts in the power-saving mode (equivalent to the above first host) and the number N - M (equivalent to the above second target number) of the hosts in the normal mode (custom mode); N represents the total number of hosts in the cloud service cluster (equivalent to the above first host cluster).

[0140] The device energy consumption of the computing resource pool mainly comes from the server energy consumption, accounting for about 60% of the total energy consumption. A monitoring experiment with a sample size of up to 5,000 Google hosts shows that the average CPU utilization rate of most hosts is between 10% and 50%. The energy consumption of a server in the power-saving mode is lower than 30% of that of a normal server. Without violating the SLA (Service Level Agreement), aggregating low-utilization virtual machines to the servers in the power-saving mode can greatly reduce the basic energy consumption of the servers. Therefore, according to the energy-saving requirements, Algorithm 1 is designed: calculate the proportion of servers in different modes in the cluster to maximize the number of servers in the power-saving mode in the cluster on the premise of business security; Algorithm 2, the virtual machine scheduling algorithm, is designed to analyze and calculate to adjust the distribution position of the virtual machines according to the collected host and virtual machine utilization data, and maintain the low-utilization virtual machines running on the hosts in the power-saving mode and the normal virtual machines running on the hosts in the normal mode.

[0141] Step 1.1: Mark the virtual machines and hosts by tagging to facilitate the execution of calculations and migrations according to the tags; for example, define the virtual machine with a CPU usage rate less than or equal to 1% as a low-utilization virtual machine (equivalent to the above first virtual machine); define the virtual machine with a usage rate higher than 1% as a normal virtual machine (equivalent to the above second virtual machine), and other parameter tags refer to Table 1. Since the specifications of each virtual machine are different, for example, for a virtual machine with a 2-core CPU, 1 GHz has already reached 21% of the CPU utilization rate, so it is necessary to convert to the CPU usage rate to define the virtual machine.

[0142] Index collection function: Host performance metrics, including CPU and memory utilization; virtual machine performance metrics, including CPU and memory utilization.

[0143] Label classification function: Host mode labels, including power-saving mode and normal mode. BIOS low-level configuration cannot be collected, and manual labeling is used. Virtual machine labels, including low-utilization virtual machines (CPU < 43%) and normal virtual machines (CPU > 43%), are automatically detected in the background.

[0144] Table 1 Custom variable table

[0145]

[0146] Step 1.2: Calculate the maximum and minimum allowable numbers of power-saving mode hosts to maximize the platform's energy-saving effect while ensuring business security. The basic rule for overall operation is that power-saving mode hosts carry low-utilization virtual machines, and normal mode hosts carry normal mode virtual machines. Therefore, the calculations are performed accordingly. In this step, the values of vmS.cpu, host.cpu, vmS.ram, and host.ram used in the calculation process are estimated values obtained from historical data. For example, data from the previous month can be obtained, or data from the previous year can be obtained in a weighted manner, giving higher weights to data closer to the current time to obtain more stable and more accurate data closer to the future actual operation situation.

[0147] (1) Minimum number of power-saving mode hosts:

[0148] S = Max(Ceil(vmS.cpu / host.cpu), Ceil(vmS.ram / host.ram));

[0149] That is to say, it represents how many hosts are required to provide CPU resources and memory resources to run all low-utilization virtual machines, and the larger value is taken to run all virtual machines; then S hosts can be enabled as power-saving mode hosts to only run low-utilization virtual machines; it can be seen that for a stable running cloud platform, the amount of business that needs to be executed by virtual machines can be estimated based on the platform's historical data. Here, the CPU occupancy and memory occupancy of virtual machines can be increased during the calculation according to the historical virtual machine situation as needed to reserve space to avoid sudden increases in business during the initialization process.

[0150] (2) Maximum number of power-saving mode hosts:

[0151] H = N - Max(Ceil(vmH.cpu / host.cpu), Ceil(vmH.ram / host.ram)); That is to say, it represents how many physical hosts in normal mode are required to provide CPU resources and memory resources for running all normal virtual machines. After deducting the number of physical hosts required for running normal virtual machines from the total number of physical hosts N, the remaining physical hosts can enable the power-saving mode.

[0152] Among them, ceil() returns the smallest integer not less than the provided value, N is the total number of physical hosts in the platform, and the actual number of physical hosts adjusted to the power-saving mode is M, (where H > M > S).

[0153] Step 1.3: Determine the initial actual number of physical hosts M in the power-saving mode, and the number of physical hosts N - M in the normal mode.

[0154] Among them, the determination method of M refers to the following Figure 2 , including:

[0155] (1) First, determine a random M in the range from S to H (equivalent to the above initial quantity).

[0156] (2) Judge whether the CPU occupancy rate of each physical host running normal virtual machines in the user-defined mode physical hosts (N - M), that is, the normal mode physical hosts, is less than the preset value (for example, 50%) and at the same time satisfies that the memory occupancy rate is less than the preset value (for example, 70%); if not satisfied, record M1 = M - 1 (reduce the number of physical hosts in the power-saving mode), indicating that the current user-defined mode physical hosts cannot meet the usage requirements, and the number of physical hosts in the normal mode needs to be increased to give priority to ensuring the service of normal mode physical hosts to normal virtual machines; if satisfied, record the current value of the physical host M in the power-saving mode as M1.

[0157] (3) While executing (2), calculate whether the CPU occupancy rate of each physical host (M) in the power-saving mode running low-utilization virtual machines is less than the preset value (for example, 30%), and at the same time satisfies that the memory occupancy rate is less than the preset value (for example, 50%); if not satisfied, record M2 = M + 1, indicating that the current number of physical hosts in the power-saving mode cannot meet the usage requirements, and the number of physical hosts in the power-saving mode needs to be increased; if satisfied, record the current value of M as M2.

[0158] (4) If M1 > M2, take M1 as the final value of M; if M1 < M2, take M2 as the final value of M. Under the condition of ensuring the service of normal mode physical hosts to normal mode virtual machines, take the larger number as the number of physical hosts in the power-saving mode to ensure the energy-saving effect.

[0159] Step 1.4. In the actual operating environment of the system, the values of vmH.cpu, vmH.ram, vmS.cpu, and vmS.ram can be obtained, and the M value is updated according to the process in Step 2.3 ( Figure 2 ). Set a certain time interval (equivalent to the second moment of the preset time length after the above first moment) to judge whether the M value needs to be changed, which can avoid frequent switching of the host status and ensure that the instances in it can run in a relatively stable state.

[0160] Step 2. Collect the number M of the current custom-mode hosts and power-saving-mode hosts in the cloud service cluster; and obtain the utilization rate of each host and the utilization rate of each virtual machine one by one. One host is a server in the cloud service cluster.

[0161] Step 3. When the M value changes, the label of the host changes. That is, when the M value needs to be adjusted, if a power-saving-mode host becomes a normal-mode host, the virtual machines in the power-saving-mode host to be changed are migrated to other power-saving-mode hosts; if a normal-mode host becomes a power-saving-mode host, the virtual machines in the normal-mode host to be changed are migrated to other normal-mode hosts.

[0162] Step 4. Refer to Table 2 and Figure 3 and Figure 4 , and migrate the virtual machines according to the preset conditions. During the process of virtual machine migration, the host utilization rate is used as the judgment basis, and the utilization rate in the host is maintained within the safety threshold by scheduling the virtual machines carried in the host.

[0163] Step 4.1. Traverse N - M custom-mode hosts, and judge whether the utilization rate of each custom-mode host is high (for example, referring to Table 2, for a normal-mode host, if the CPU utilization rate exceeds 50% or the memory utilization rate exceeds 70%, it is considered that the utilization rate is high). If it is high, migrate the virtual machines with high utilization rate to other normal-mode hosts (refer to the process in Step 4.3). In addition, it can also be judged whether there are virtual machines with low CPU utilization rate (such as 1%) or low memory utilization rate (such as less than 10%) in the custom-mode host; if so, migrate the virtual machine to the power-saving-mode host; otherwise, end the process.

[0164] Step 4.2: While performing Step 4.1, traverse the M power-saving mode host machines, and for each power-saving mode host machine, determine whether its utilization rate is high. If so, migrate the virtual machines therein to other power-saving mode host machines (refer to the process in Step 4.3). In addition, it is also possible to determine whether there are virtual machines in the power-saving mode host machines with a CPU or memory utilization rate greater than a preset value (such as 1%). If so, migrate the virtual machine to a custom mode host machine; otherwise, end the process.

[0165] Among them, before performing the formal migration operation, a migration evaluation will be carried out on the virtual machines and host machines, including how much the CPU and memory utilization rates of the destination host machine will increase after the virtual machine is migrated into the destination host machine, and how much the utilization rate of the source host machine will decrease. Only after the evaluation is completed will the migration be carried out, so as to avoid the situation where the utilization rate of the destination host machine immediately exceeds the warning after the migration.

[0166] Table 2 Definition of Power-Saving Mode Host Machines and Normal Mode Host Machines

[0167]

[0168] Step 4.3: During the process of virtual machine migration, by optimizing the selected virtual machines and destination host machines, the optimization effect of the maximum index with the minimum action is achieved, including the following steps.

[0169] Step 4.3.1: Sort the virtual machines carried in the host machine from which the virtual machine needs to be migrated out in descending order according to the risk index, and calculate the list of virtual machines to be migrated out:

[0170] For example, if the host machine host1 from which the virtual machine needs to be migrated out carries vm1, vm2......vmn, and the risk index is CPU; then sort the virtual machines in the order of migration out according to the CPU usage rate vm1.cpu > vm2.cpu > vm3.cpu

[0171] Step 4.3.2: Simulate the removal of the virtual machine in the order of the virtual machine list until the risk index of the host machine meets the safety threshold.

[0172] For example, calculate host1.cpu - vm1.cpu, host1.cpu - vm1.cpu - vm2.cpu, etc., until it is less than the host.cpu safety threshold, and find the least number of vms to be migrated out; then the number of virtual machines to be migrated out can be reduced.

[0173] Step 4.3.3, Optimize the target host: Comprehensively consider the CPU and memory metrics of the host, and add the usage after the migrated virtual machines; after the increase in the target host's CPU and memory, it meets the safety threshold requirements and the host metric health is optimal. Note that it is necessary to maintain the corresponding relationship between the host groups in different modes and the corresponding virtual machine groups unchanged. That is, virtual machines with low usage remain on the power-saving mode hosts, and normal virtual machines remain on the normal mode hosts.

[0174] hostx.cpu + vm1.cpu + vm2.cpu +... + vmn.cpu < hostcpu safety threshold (equivalent to the above first safety threshold);

[0175] hostx.ram + vm1.ram + vm2.ram +... + vmn.ram < hostram safety threshold (equivalent to the above second safety threshold);

[0176] hostx represents the host to be migrated. Only when the above two inequality constraints are met can it be migrated to hostx; if no single host meets the requirements, the migrated virtual machines can be split and migrated to multiple hosts.

[0177] For example, arrange other hosts in ascending order of utilization rate, and first try to migrate virtual machines to hosts with low utilization rate. If a single host cannot meet the migration requirements, get the next host. That is, if the host with the lowest utilization rate can meet all the migration requirements, only one migration is needed to improve the processing efficiency.

[0178] Step 5, Refer to Figure 5 If the CPU utilization rate of the virtual machine in the power-saving mode exceeds the larger value of the threshold (for example, exceeds the threshold by 43%) or the CPU utilization rate of the virtual machine in the normal mode drops below the larger value of the threshold (for example, below the threshold by 43%), cross-mode migration is triggered.

[0179] Refer to Figure 6 , taking the CPU utilization rate index of the virtual machine in the power-saving mode as the judgment basis, through scheduling sensitive virtual machines, the virtual machines can be freely scheduled between the power-saving mode and the normal mode to achieve the safe operation goal that the business performance meeting the energy-saving requirements of the host is not affected. If there is a virtual machine with too high CPU utilization rate in the host in the power-saving mode, it means that it no longer belongs to the virtual machine with low utilization rate, and it is cross-mode migrated to the host in the normal mode to avoid excessive occupation of the resources of the host in the power-saving mode; similarly, if there is a virtual machine with too low CPU utilization rate in the host in the normal mode, it means that it no longer belongs to the normal virtual machine and the performance requirement decreases, and it can be cross-mode migrated to the host in the power-saving mode to run, leaving running space for the normal virtual machines.

[0180] Step 5.1: Obtain the virtual machines with vm.cpu growth exceeding the threshold of 43% in the power-saving mode and vm.cpu decrease below the threshold of 43% in the normal mode;

[0181] Step 5.2: Optimize the target host: Considering the CPU and memory metrics of the host comprehensively, and adding the usage of the migrated-out virtual machines, after the CPU and memory of the target host increase, they meet the requirements of the security threshold and the health degree of the host metrics is optimal.

[0182] Switch the corresponding host group relationship of the virtual machine:

[0183] For the case where vm.cpu growth in the power-saving mode exceeds the threshold of 43%: Lock the corresponding target host in the normal-mode host group, that is, execute Step 5.2 within the range of normal-mode hosts;

[0184] For the virtual machines with vm.cpu decrease below the threshold of 43% in the normal mode: Lock the target host in the power-saving-mode host group, that is, execute Step 5.2 within the range of power-saving-mode hosts;

[0185] After conversion, the following conditions need to be met:

[0186] hostx.cpu + vm1.cpu + vm2.cpu +... + vmn.cpu < hostcpu security threshold;

[0187] hostx.ram + vm1.ram + vm2.ram +... + vmn.ram < hostram security threshold.

[0188] Step 6: Refer to Figure 7 , using the virtual machine CPU utilization rate index in the power-saving mode as the judgment basis, through scheduling sensitive virtual machines, the virtual machines can be freely scheduled between the power-saving mode and the normal mode to achieve the safe operation goal of meeting the energy-saving requirements of the host without affecting the business performance.

[0189] Step 6.1: In Step 4.3.3, if no other host that can receive the migrated-out virtual machine can be matched, a request is sent to other cloud service clusters. The host utilization rate reaches the critical value, but there is no host in this cluster that meets the migration-in conditions. Therefore, cross-cluster optimization is carried out to select the cluster host that meets the conditions to carry the migrated-out virtual machine.

[0190] Step 6.2: In Step 5.2, if there is no host that meets the conditions in this cluster, a request is sent to other cloud service clusters. This is an extension of the advanced migration rule. The CPU utilization rate of the sensitive virtual machine reaches the critical value, but there is no host in this cluster that meets the migration-in conditions. Therefore, cross-cluster optimization is carried out to select the cluster host that meets the conditions to carry the migrated-out virtual machine.

[0191] Step 7: After obtaining the migration plan, by connecting to the vc platform, the vc opens the migration permission to multiple clouds, and after the migration plan is output, it is sent for execution. Here, the vc platform refers to the virtualization platform of VMware.

[0192] Step 8: Provide a specific application scenario.

[0193] According to the algorithm, the following effects can be seen on the platform:

[0194] 1) Label resource binding: The energy-saving setting status of the host cannot be collected on the vc, and the corresponding energy-saving type is manually bound to the corresponding host. As Figure 8 shown, the host type is bound.

[0195] 2) New risk diagnosis indicators: Configure the collection sources and diagnosed indicators such as memory and CPU. As Figure 9 shown, the host resources are collected.

[0196] 3) New risk diagnosis items: Configure the risk diagnosis items according to the migration trigger conditions as needed, such as the CPU utilization rate being greater than or equal to 50%. As Figure 10 shown, the risk diagnosis conditions are configured.

[0197] 4) New risk diagnosis plan: Configure the data platform source, such as the business platform cloud; select the diagnosis item and the plan generation time. As Figure 11 shown, the risk diagnosis is configured.

[0198] 5) Execute the plan: Click "Execute Once" in the diagnosis management to execute the risk diagnosis detection. As Figure 12 shown, the plan is executed.

[0199] 6) Migration report generation: A migration recommendation report will be generated after the risk diagnosis conditions are triggered. As Figure 13 shown, the virtual machine pre-migration report is evaluated.

[0200] 7) Migration report details: The corresponding migration index trigger conditions, host, migration execution results, etc. will be shown in the migration report. Clicking on the diagnosis details will have the estimated host utilization rate information before and after migration as the basis for judgment. As Figure 14 shown, the migration report details.

[0201] Experimental effect: Currently, the server of the Inspur 1288hv5 model has been used as the experimental object to complete the energy-saving experiment. Through adjusting the power policy - power-saving mode and CPU P state control - maximum efficiency, an energy-saving effect of about 30% has been verified. The experimental test screenshots are as follows Figures 15 to 16 . Figure 15 It is a real-time monitoring graph of the server power in the power-saving mode (average power 145 - 170w), Figure 16It is a real-time monitoring graph of the server power in the normal mode (average power: 210 - 265w).

[0202] Currently, our unit has developed a virtual machine automated scheduling algorithm that meets the energy-saving requirements based on the provincial multi-cloud management platform. It has been implemented to collect the utilization rates of the host machines and virtual machines, design and apply the virtual machine scheduling algorithm, and recommend virtual machine scheduling solutions. As Figure 17 shown, Scheduling Solution Recommendation 1, as Figure 18 shown, Scheduling Solution Recommendation 2.

[0203] In the embodiment of the present application, the host machines in the cloud service cluster are divided into normal-mode host machines and power-saving-mode host machines, and the virtual machines are divided into low-utilization virtual machines and normal virtual machines according to the usage rates of CPU and memory resources. The low-utilization virtual machines only run on the power-saving-mode host machines, and the normal virtual machines only run on the normal-mode host machines. That is, energy saving is achieved through resource allocation, and the host machines where the virtual machines are located are dynamically adjusted according to the changes in the usage rates. The virtual machines therein are adjusted in a timely manner through the changes in the resource usage rates of the host machines.

[0204] Based on the virtual machine migration method provided in the above embodiment, correspondingly, the present application also provides a specific implementation manner of the virtual machine migration device. Please refer to the following embodiments.

[0205] As Figure 19 shown, the virtual machine migration device 1900 provided in the embodiment of the present application is applied to the first host machine cluster. The first host machine cluster includes N host machines, and each host machine runs at least one virtual machine. The device 1900 may include the following modules: a first acquisition module 1901, a first calculation module 1902, a first determination module 1903, and a first migration module 1904.

[0206] The first acquisition module 1901 is used to acquire the total CPU of a single host machine in the first host machine cluster, the total memory of a single host machine, and the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total memory utilization of the first virtual machine, and the total memory utilization of the second virtual machine at the first moment. The first virtual machine is a virtual machine with a utilization rate less than or equal to a preset first threshold, and the second virtual machine is a virtual machine with a utilization rate greater than the first threshold;

[0207] The first calculation module 1902 is used to calculate the minimum number and the maximum number of the first host machine in the first host machine cluster at the first moment according to the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host machine, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host machine. The first host machine is the power-saving-mode host machine among the N host machines;

[0208] A first determination module 1903, configured to determine a first target quantity of a first host and a second target quantity of a second host according to a minimum quantity and a maximum quantity, where the second host is a host in a normal mode among N hosts;

[0209] A first migration module 1904, configured to set the quantities of the first host and the second host in the first host cluster according to the first target quantity and the second target quantity, and migrate the first virtual machines running in the first host cluster to the first target quantity of first hosts, and migrate the second virtual machines running in the first host cluster to the second target quantity of second hosts.

[0210] The virtual machine migration device according to an embodiment of the present application is applied to a first host cluster. The first host cluster includes N hosts, and each host runs at least one virtual machine. It can calculate, according to the total CPU utilization of the first virtual machines, the total CPU utilization of the second virtual machines, the total CPU of a single host, the total memory utilization of the first virtual machines, the total memory utilization of the second virtual machines, and the total memory of a single host, the minimum quantity and the maximum quantity of the first hosts in the first host cluster at a first moment. The first virtual machines are virtual machines with a utilization rate less than or equal to a preset first threshold, the second virtual machines are virtual machines with a utilization rate greater than the first threshold, and the first hosts are hosts in a power-saving mode among N hosts; determine a first target quantity of the first host and a second target quantity of the second host according to the minimum quantity and the maximum quantity, where the second host is a host in a normal mode among N hosts; set the quantities of the first host and the second host in the first host cluster according to the first target quantity and the second target quantity, and migrate the first virtual machines running in the first host cluster to the first target quantity of first hosts, and migrate the second virtual machines running in the first host cluster to the second target quantity of second hosts. In this way, in the embodiment of the present application, the virtual machines with low utilization rates are migrated to the hosts in the power-saving mode, and the normal virtual machines are migrated to the hosts in the normal mode, so that energy saving can be achieved without frequently turning on and off the servers.

[0211] In some embodiments, the above-mentioned first calculation module 1902 may specifically include:

[0212] A first calculation unit, configured to calculate, according to the total CPU utilization of the first virtual machines, the total CPU of a single host, the total memory utilization of the first virtual machines, and the total memory of a single host, the minimum quantity of the first hosts in the first host cluster at the first moment. The minimum quantity is the maximum value of a first quantity and a second quantity. The first quantity is the smallest integer not less than the ratio of the total CPU utilization of the first virtual machines to the total CPU of a single host, and the second quantity is the smallest integer not less than the ratio of the total memory utilization of the first virtual machines to the total memory of a single host;

[0213] A second computing unit, configured to calculate, according to the total CPU utilization of the second virtual machines, the total CPU amount of a single host machine, the total memory utilization of the second virtual machines, and the total memory amount of a single host machine, the maximum number of the first host machines in the first host machine cluster at the first moment, where the maximum number is the difference between N and the maximum value of a third number and a fourth number, the third number is the smallest integer not less than the ratio of the total CPU utilization of the second virtual machines to the total CPU amount of a single host machine, and the fourth number is the smallest integer not less than the ratio of the total memory utilization of the second virtual machines to the total memory amount of a single host machine.

[0214] In some embodiments, the above-mentioned first determination module 1903 may specifically include:

[0215] A first determination unit, configured to determine the initial number of the first host machines according to the minimum number and the maximum number, where the initial number is any value from the minimum number to the maximum number;

[0216] A first adjustment unit, configured to, when the second virtual machines are running on the second host machines with the difference between N and the initial number, adjust the initial number according to the CPU utilization rate and the memory utilization rate of each second host machine to obtain a first candidate number;

[0217] A second adjustment unit, configured to, when the first virtual machines are running on the initial number of first host machines, adjust the initial number according to the CPU utilization rate and the memory utilization rate of each first host machine to obtain a second candidate number;

[0218] A second determination unit, configured to determine the first target number of the first host machines according to the first candidate number and the second candidate number, where the first target number is the larger value of the first candidate number and the second candidate number;

[0219] A third determination unit, configured to determine the second target number of the second host machines according to the first target number, where the second target number is the difference between N and the first target number.

[0220] As an implementation manner of the present application, in the prior art, after the server energy-saving adjustment, the virtual machine migration plan is further adjusted by continuously tracking the power consumption. However, the method of tracking the power consumption and adjusting the migration plan according to the power has hysteresis and cannot adjust the virtual machine migration in time. To adjust the virtual machine migration in each host machine in time, the above-mentioned apparatus 1900 may further include:

[0221] A second acquisition module, configured to acquire the total CPU utilization of the first virtual machines, the total CPU utilization of the second virtual machines, the total memory utilization of the first virtual machines, and the total memory utilization of the second virtual machines at the second moment, where the second moment is the moment after a preset duration from the first moment;

[0222] A second computing module, configured to calculate the minimum number and the maximum number of the first host at the second moment according to the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host;

[0223] A second determining module, configured to determine a third target number of the first host and a fourth target number of the second host at the second moment according to the minimum number and the maximum number;

[0224] A second migration module, configured to, when the third target number is different from the first target number, adjust the number of the first host and the second host in the first host cluster according to the third target number and the fourth target number, and migrate the first virtual machine running in the first host cluster to the third target number of the first hosts, and migrate the second virtual machine running in the first host cluster to the fourth target number of the second hosts.

[0225] In some embodiments, the above-mentioned first migration module 1904 may specifically include:

[0226] A traversal unit, configured to traverse the first target number of the first hosts and the second target number of the second hosts in the first host cluster;

[0227] A first migration unit, configured to, when it is recognized that the utilization rate of the second host to be migrated out is higher than a preset second threshold, migrate at least one of the second virtual machines to be migrated out in the second host to the second host to be migrated in. The second host to be migrated out is any one of the second target number of the second hosts, and the second host to be migrated in is the second host among the second target number of the second hosts except the second host to be migrated out, where the CPU utilization rate of the second host and the CPU utilization rate of at least one of the second virtual machines to be migrated out is less than a preset first safety threshold, and the memory utilization rate of the second host and the memory utilization rate of at least one of the second virtual machines to be migrated out is less than a preset second safety threshold;

[0228] A second migration unit, configured to, when it is recognized that the utilization rate of the first host to be migrated out is higher than the second threshold, migrate at least one of the first virtual machines to be migrated out in the first host to the first host to be migrated in. The first host to be migrated out is any one of the first target number of the first hosts, and the first host to be migrated in is the first host among the first target number of the first hosts except the first host to be migrated out, where the CPU utilization rate of the first host and the CPU utilization rate of at least one of the first virtual machines to be migrated out is less than the first safety threshold, and the memory utilization rate of the first host and the memory utilization rate of at least one of the first virtual machines to be migrated out is less than the second safety threshold.

[0229] The above-mentioned first migration unit may specifically include:

[0230] A first determination subunit, configured to determine a migration order list of at least one second virtual machine migrated out of the second host according to the CPU utilization rate of at least one second virtual machine migrated out of the second host, where the higher the CPU utilization rate, the higher the migration priority of the corresponding second virtual machine;

[0231] A second determination subunit, configured to simulate the migration of each second virtual machine according to each migration priority in the migration order list, and determine at least one second virtual machine migrated out of the second host when the CPU utilization rate of the second host after migration is less than a preset first security threshold, and the number of at least one second virtual machine migrated out is the minimum migration number in the migration order list;

[0232] A third determination subunit, configured to determine the second host as the second host to be migrated in when the sum of the CPU utilization rates of the second hosts other than the second host to be migrated out among the second target number of second hosts and the CPU utilization rates of at least one second virtual machine migrated out is less than the first security threshold, and the sum of the memory utilization rate of the second host and the memory utilization rates of at least one second virtual machine migrated out is less than a preset second security threshold;

[0233] A migration subunit, configured to migrate at least one second virtual machine migrated out to the second host to be migrated in.

[0234] As another implementation manner of the present application, in order to achieve the security operation goal that the service performance meeting the energy-saving requirements of the host is not affected, the above-mentioned first migration module 1904 may further include:

[0235] A third migration unit, configured to, when it is recognized that there is at least one first virtual machine in the second host to be migrated out, migrate the first virtual machine in the second host to be migrated out to the target first host, where the target first host is the first host among the first target number of first hosts whose sum of the CPU utilization rate of the first host and the CPU utilization rates of at least one first virtual machine is less than the first security threshold, and the sum of the memory utilization rate of the first host and the memory utilization rates of at least one first virtual machine is less than the second security threshold;

[0236] A fourth migration unit, configured to, when it is recognized that there is at least one second virtual machine in the first host to be migrated out, migrate the second virtual machines in the first host to be migrated out to a target second host, where the target second host is a second host among the second target number of second hosts, and the sum of the CPU utilization rate of the second host and the CPU utilization rate of at least one second virtual machine is less than a first security threshold, and the sum of the memory utilization rate of the second host and the memory utilization rate of at least one second virtual machine is less than a second security threshold.

[0237] As another implementation manner of this application, in order to achieve the security operation goal that the service performance meeting the energy-saving requirements of the host is not affected, the above-mentioned first migration module 1904 may further include:

[0238] A sending unit, configured to, when there is no second host to be migrated in, first host to be migrated in, target first host or target second host in the first host cluster, send a migration request to the second host cluster, so that the second host cluster responds to the migration request and migrates the first virtual machines and / or second virtual machines in the first host to be migrated out and / or the second host to be migrated out in the first host cluster to a target host, where the target host is a host in the multiple hosts of the second host cluster whose CPU utilization rate and memory utilization rate meet a preset rule.

[0239] Figure 20 The figure shows a schematic hardware structure diagram of an electronic device provided by an embodiment of this application.

[0240] The electronic device may include a processor 2001 and a memory 2002 storing computer program instructions.

[0241] Specifically, the above-mentioned processor 2001 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0242] The memory 2002 may include a mass storage for data or instructions. By way of example and not limitation, the memory 2002 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disc, a magneto-optical disc, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. In a suitable case, the memory 2002 may include a removable or non-removable (or fixed) medium. In a suitable case, the memory 2002 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 2002 is a non-volatile solid state memory.

[0243] In a particular embodiment, the memory 2002 may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage media device, an optical storage media device, a flash memory device, an electrical, optical, or other physical / tangible memory storage device. Thus, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.

[0244] The processor 2001 realizes any one of the virtual machine migration methods in the above embodiments by reading and executing the computer program instructions stored in the memory 2002.

[0245] In one example, the electronic device may further include a communication interface 2003 and a bus 2010. Among them, as Figure 20 shown, the processor 2001, the memory 2002, and the communication interface 2003 are connected through the bus 2010 and complete communication with each other.

[0246] The communication interface 2003 is mainly used to implement communication between various modules, devices, units, and / or devices in the embodiments of the present application.

[0247] The bus 2010 includes hardware, software, or both, and couples the components of the electronic device to each other. By way of example and not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses or a combination of two or more of these. In a suitable case, the bus 2010 may include one or more buses. Although the embodiments of the present application describe and illustrate specific buses, the present application contemplates any suitable bus or interconnect.

[0248] The electronic device can execute the virtual machine migration method in the embodiments of the present application, thereby implementing the method and apparatus for virtual machine migration described in combination with Figure 1 and Figure 19 described.

[0249] In addition, in combination with the method for virtual machine migration in the above embodiments, an embodiment of the present application can provide a computer-readable storage medium to implement. Computer program instructions are stored on the computer-readable storage medium; when the computer program instructions are executed by a processor, any one of the methods for virtual machine migration in the above embodiments is implemented.

[0250] An embodiment of the present application also provides a computer program product, including a computer program, which implements any one of the methods for virtual machine migration in the above embodiments when executed by a processor.

[0251] It should be clear that the present application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, the detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order between steps after understanding the spirit of the present application.

[0252] The functional blocks shown in the above-described block diagrams can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a functional card, and so on. When implemented in software, the elements of the present application are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium or transmitted via a data signal carried in a carrier wave on a transmission medium or a communication link. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical discs, hard disks, fiber optic media, radio frequency (RF) links, and so on. The code segment can be downloaded via a computer network such as the Internet, an intranet, and so on.

[0253] It should also be noted that the exemplary embodiments mentioned in the present application describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the above steps, that is, the steps can be executed in the order mentioned in the embodiments, or different from the order in the embodiments, or several steps can be executed simultaneously.

[0254] As described above with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block in the flowchart and / or block diagram, and the combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the functions / actions specified in one or more blocks of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It should also be understood that each block in the block diagram and / or flowchart, and the combinations of blocks in the block diagram and / or flowchart, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0255] As described above, the above is only the specific implementation manner of the present application. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be repeated herein. It should be understood that the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present application, and these modifications or replacements should all be covered within the protection scope of the present application.

Claims

1. A virtual machine migration method, characterized in that, Applied to the first host cluster, the first host cluster includes N hosts, and each of the hosts runs at least one of the virtual machines. The method includes: Obtain the total CPU of a single host in the first host cluster, the total memory of a single host, and the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total memory utilization of the first virtual machine, and the total memory utilization of the second virtual machine at the first moment. The first virtual machine is a virtual machine with a utilization rate less than or equal to a preset first threshold, and the second virtual machine is a virtual machine with a utilization rate greater than the first threshold; Calculate the minimum number and the maximum number of the first hosts in the first host cluster at the first moment according to the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host. The first host is a host in the power-saving mode among the N hosts; Determine the first target number of the first hosts and the second target number of the second hosts according to the minimum number and the maximum number. The second host is a host in the normal mode among the N hosts; Set the number of the first hosts and the second hosts in the first host cluster according to the first target number and the second target number, and migrate the first virtual machines running in the first host cluster to the first target number of the first hosts, and migrate the second virtual machines running in the first host cluster to the second target number of the second hosts.

2. The method according to claim 1, wherein The calculating the minimum number and the maximum number of the first hosts in the first host cluster at the first moment according to the total CPU utilization of the first virtual machine, the total CPU utilization of the second virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, the total memory utilization of the second virtual machine, and the total memory of a single host includes: Calculate the minimum number of the first hosts in the first host cluster at the first moment according to the total CPU utilization of the first virtual machine, the total CPU of a single host, the total memory utilization of the first virtual machine, and the total memory of a single host. The minimum number is the maximum value of a first number and a second number. The first number is the smallest integer not less than the ratio of the total CPU utilization of the first virtual machine to the total CPU of a single host, and the second number is the smallest integer not less than the ratio of the total memory utilization of the first virtual machine to the total memory of a single host; Based on the total CPU utilization of the second virtual machines, the total CPU of a single host computer, the total memory utilization of the second virtual machines, and the total memory of a single host computer, calculate the maximum number of the first host computers in the first host computer cluster at the first moment. The maximum number is the difference between N and the maximum value of a third number and a fourth number. The third number is the smallest integer not less than the ratio of the total CPU utilization of the second virtual machines to the total CPU of a single host computer, and the fourth number is the smallest integer not less than the ratio of the total memory utilization of the second virtual machines to the total memory of a single host computer.

3. The method according to claim 1, wherein Determining the first target number of the first host computers and the second target number of the second host computers according to the minimum number and the maximum number includes: Determine the initial number of the first host computers according to the minimum number and the maximum number. The initial number is any value from the minimum number to the maximum number. When the second virtual machines are running on the second host computers with the difference between N and the initial number, adjust the initial number according to the CPU utilization rate and memory utilization rate of each of the second host computers to obtain a first candidate number. When the first virtual machines are running on the initial number of the first host computers, adjust the initial number according to the CPU utilization rate and memory utilization rate of each of the first host computers to obtain a second candidate number. Determine the first target number of the first host computers according to the first candidate number and the second candidate number. The first target number is the larger value of the first candidate number and the second candidate number. Determine the second target number of the second host computers according to the first target number. The second target number is the difference between N and the first target number.

4. The method according to claim 1, characterized in that, After setting the number of the first host computers and the second host computers in the first host computer cluster according to the first target number and the second target number, and migrating the first virtual machines running in the first host computer cluster to the first target number of the first host computers, and migrating the second virtual machines running in the first host computer cluster to the second target number of the second host computers, the method further includes: Obtain the total CPU utilization of the first virtual machines, the total CPU utilization of the second virtual machines, the total memory utilization of the first virtual machines, and the total memory utilization of the second virtual machines at a second moment. The second moment is the moment at a preset time period after the first moment. Based on the total CPU utilization of the first virtual machines, the total CPU utilization of the second virtual machines, the total CPU of a single host computer, the total memory utilization of the first virtual machines, the total memory utilization of the second virtual machines, and the total memory of a single host computer, calculate the minimum number and the maximum number of the first host computers at the second moment. Determine a third target quantity of the first host and a fourth target quantity of the second host at the second moment according to the minimum quantity and the maximum quantity; In the case where the third target quantity is different from the first target quantity, adjust the quantities of the first host and the second host in the first host cluster according to the third target quantity and the fourth target quantity, and migrate the first virtual machines running in the first host cluster to the third target quantity of first hosts, and migrate the second virtual machines running in the first host cluster to the fourth target quantity of second hosts.

5. The method according to claim 1, characterized in that, The migrating the first virtual machines running in the first host cluster to the first target quantity of first hosts, and migrating the second virtual machines running in the first host cluster to the second target quantity of second hosts includes: Traverse the first target quantity of first hosts and the second target quantity of second hosts in the first host cluster; In the case where it is recognized that the utilization rate of a second host to be migrated out is higher than a preset second threshold, migrate at least one of the second virtual machines to be migrated out from the second host to a second host to be migrated in, the second host to be migrated out is any one of the second target quantity of second hosts, and the second host to be migrated in is a second host among the second target quantity of second hosts except the second host to be migrated out, and the sum of the CPU utilization rate of the second host and the CPU utilization rate of at least one of the second virtual machines to be migrated out is less than a preset first safety threshold, and the sum of the memory utilization rate of the second host and the memory utilization rate of at least one of the second virtual machines to be migrated out is less than a preset second safety threshold; In the case where it is recognized that the utilization rate of a first host to be migrated out is higher than the second threshold, migrate at least one of the first virtual machines to be migrated out from the first host to a first host to be migrated in, the first host to be migrated out is any one of the first target quantity of first hosts, and the first host to be migrated in is a first host among the first target quantity of first hosts except the first host to be migrated out, and the sum of the CPU utilization rate of the first host and the CPU utilization rate of at least one of the first virtual machines to be migrated out is less than the first safety threshold, and the sum of the memory utilization rate of the first host and the memory utilization rate of at least one of the first virtual machines to be migrated out is less than the second safety threshold; 6. The method according to claim 5, wherein The migrating at least one of the second virtual machines to be migrated out from the second host to a second host to be migrated in includes: Determine a migration order list of at least one of the second virtual machines in the second host to be migrated out according to the CPU utilization rate of at least one of the second virtual machines in the second host to be migrated out, and the higher the CPU utilization rate, the higher the migration priority of the corresponding second virtual machine; Migrate each of the second virtual machines according to the migration priorities in the migration sequence list, and determine at least one of the second virtual machines to be migrated out of the second host from which it is migrated out when the CPU utilization rate of the second host from which it is migrated out is less than a preset first safety threshold, and the number of the at least one second virtual machines to be migrated out is the minimum migration number in the migration sequence list; Determine the second host as the second host to which migration is to occur when the sum of the CPU utilization rates of the second hosts other than the second host from which it is migrated out among the second target number of second hosts and the CPU utilization rates of the at least one second virtual machines to be migrated out is less than the first safety threshold, and the sum of the memory utilization rates of the second hosts and the memory utilization rates of the at least one second virtual machines to be migrated out is less than a preset second safety threshold; Migrate the at least one second virtual machines to be migrated out to the second host to which migration is to occur; 7. The method according to claim 5, characterized in that The migrating of the first virtual machines running in the first host cluster to the first target number of first hosts and the migrating of the second virtual machines running in the first host cluster to the second target number of second hosts further include: When it is recognized that there is at least one of the first virtual machines in the second host from which it is migrated out, migrate the first virtual machine in the second host from which it is migrated out to a target first host, where the target first host is a first host among the first target number of first hosts such that the sum of the CPU utilization rate of the first host and the CPU utilization rates of at least one of the first virtual machines is less than the first safety threshold, and the sum of the memory utilization rate of the first host and the memory utilization rates of at least one of the first virtual machines is less than the second safety threshold; When it is recognized that there is at least one of the second virtual machines in the first host from which it is migrated out, migrate the second virtual machine in the first host from which it is migrated out to a target second host, where the target second host is a second host among the second target number of second hosts such that the sum of the CPU utilization rate of the second host and the CPU utilization rates of at least one of the second virtual machines is less than the first safety threshold, and the sum of the memory utilization rate of the second host and the memory utilization rates of at least one of the second virtual machines is less than the second safety threshold; 8. The method according to claim 7, wherein The migrating of the first virtual machines running in the first host cluster to the first target number of first hosts and the migrating of the second virtual machines running in the first host cluster to the second target number of second hosts further include: In the case that the second host, the first host to be migrated in, the target first host, or the target second host does not exist in the first host cluster, a migration request is sent to the second host cluster, so that the second host cluster responds to the migration request and migrates the first virtual machine and / or the second virtual machine of the first host to be migrated out and / or the second host to be migrated out in the first host cluster to a target host, where the target host is a host in the multiple hosts of the second host cluster whose CPU utilization rate and memory utilization rate meet a preset rule.

9. A virtual machine migration device, characterized in that Applied to a first host cluster, the first host cluster includes N hosts, and each host runs at least one virtual machine. The device includes: A first acquisition module, configured to acquire the total CPU amount of a single host in the first host cluster, the total memory amount of a single host, and the total CPU utilization amount of the first virtual machine, the total CPU utilization amount of the second virtual machine, the total memory utilization amount of the first virtual machine, and the total memory utilization amount of the second virtual machine at a first moment, where the first virtual machine is a virtual machine with a utilization rate less than or equal to a preset first threshold, and the second virtual machine is a virtual machine with a utilization rate greater than the first threshold; A first calculation module, configured to calculate, according to the total CPU utilization amount of the first virtual machine, the total CPU utilization amount of the second virtual machine, the total CPU amount of the single host, the total memory utilization amount of the first virtual machine, the total memory utilization amount of the second virtual machine, and the total memory amount of the single host, the minimum number and the maximum number of the first hosts in the first host cluster at the first moment, where the first host is a host in the N hosts in a power-saving mode; A first determination module, configured to determine, according to the minimum number and the maximum number, a first target number of the first hosts and a second target number of the second hosts, where the second host is a host in the N hosts in a normal mode; A first migration module, configured to set the number of the first hosts and the second hosts in the first host cluster according to the first target number and the second target number, and migrate the first virtual machines running in the first host cluster to the first target number of first hosts, and migrate the second virtual machines running in the first host cluster to the second target number of second hosts.

10. An electronic device, characterized in that, The device includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the virtual machine migration method according to any one of claims 1-8 is implemented.

11. A computer-readable storage medium, characterized in that, Computer program instructions are stored on a computer-readable storage medium, and when the computer program instructions are executed by a processor, the virtual machine migration method according to any one of claims 1-8 is implemented.

12. A computer program product, characterized in that, When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to execute the virtual machine migration method according to any one of claims 1-8.