Resource scheduling method, device, equipment, and storage medium
By identifying the alarm physical machine with unbalanced resource utilization in the OpenStack platform and migrating mismatched virtual machines, the problem of unbalanced resource utilization is solved, and the stability of the platform and the operation stability of the virtual machine are improved.
Patent Information
- Application Number
- CN202010754548.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-30
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2040-07-30
AI Technical Summary
The resource utilization of physical machines in the OpenStack platform is unbalanced, and the existing dynamic resource scheduling methods cannot effectively solve this problem.
By determining the alarm physical machine, obtain the relationship between its total CPU and total memory, and compare the relationship between the CPU usage and memory usage of each virtual machine, identify the mismatched virtual machines, and migrate them to improve resource utilization balance.
It realizes the balance of physical machine resource utilization in the OpenStack platform, and improves the stability of the platform and the operation stability of the virtual machine.
Smart Images

Figure CN114064191B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to electronic technology, and relate to but are not limited to resource scheduling methods and devices, equipment, and storage media. Background Art
[0002] OpenStack is an open source cloud computing management platform project. As a public and private cloud construction and management platform, many enterprises and organizations use OpenStack to build their own cloud platforms. With the large-scale deployment of the OpenStack platform, tens of thousands of physical machines are often deployed in the platform. As the system is continuously used, higher requirements are placed on the stability of the cloud platform. Dynamic resource scheduling plays a critical role in the stability of the platform. Through dynamic resource scheduling, the utilization rate of platform resources can be optimized.
[0003] The main principle of the existing OpenStack dynamic resource scheduling method is that when the load of the physical machine is high, the upper limit threshold is triggered and some of the virtual machines are migrated to avoid excessive load on the physical machine; however, even if some virtual machines in the physical machine are migrated out, reducing the load of the physical machine, the physical machine still has the problem of uneven resource utilization. Summary of the invention
[0004] In view of this, embodiments of the present application provide a resource scheduling method and apparatus, a device, and a storage medium.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides a resource scheduling method, the method comprising: determining at least one alarm physical machine from a cluster; obtaining a first numerical relationship between the total CPU usage and the total memory usage of each of the alarm physical machines; determining a second numerical relationship between the CPU usage and the memory usage of each virtual machine in each of the alarm physical machines; for each of the alarm physical machines, determining a second numerical relationship that does not match the corresponding first numerical relationship; determining the virtual machine corresponding to the mismatched second numerical relationship as a virtual machine to be migrated; and migrating each of the virtual machines to be migrated.
[0007] In the second aspect, an embodiment of the present application provides a resource scheduling device, including: a determination module, used to determine at least one alarm physical machine from a cluster; an acquisition module, used to obtain a first numerical relationship between the total CPU and the total memory of each of the alarm physical machines; the determination module is also used to determine the second numerical relationship between the CPU usage and the memory usage of each virtual machine in each of the alarm physical machines; the determination module is also used to determine, for each of the alarm physical machines, a second numerical relationship that does not match the corresponding first numerical relationship; determine the virtual machine corresponding to the unmatched second numerical relationship as a virtual machine to be migrated; and a migration module is used to migrate each of the virtual machines to be migrated.
[0008] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the program, the steps of the resource scheduling method described in any one of the embodiments of the present application are implemented.
[0009] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any resource scheduling method described in the embodiments of the present application.
[0010] In an embodiment of the present application, a first numerical relationship between the total CPU and total memory of each alarm physical machine in the cluster is obtained, and a second numerical relationship between the CPU usage and memory usage of each virtual machine in each of the alarm physical machines is determined; then, the virtual machines in the alarm physical machine corresponding to the second numerical relationship that does not match its first numerical relationship are migrated out; in this way, the resource utilization of the migrated alarm physical machines can be made more balanced. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 This is a schematic diagram of the implementation process of the resource scheduling method of the embodiment of the present application;
[0012] Figure 2 This is a schematic diagram of the implementation process of another resource scheduling method according to an embodiment of the present application;
[0013] Figure 3 A schematic diagram of a flow chart of a method for determining an alarm queue according to an embodiment of the present application;
[0014] Figure 4 A schematic diagram of a method for implementing a flow chart of selecting a virtual machine to be migrated according to an embodiment of the present application;
[0015] Figure 5 A schematic diagram of a method for selecting a target physical server according to an embodiment of the present application;
[0016] Figure 6This is a schematic diagram of the structure of the resource scheduling device according to an embodiment of the present application;
[0017] Figure 7 A hardware entity schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the present application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.
[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0020] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0021] It should be pointed out that the terms "first\second\third" involved in the embodiments of the present application are merely to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0022] In order to facilitate the understanding of the embodiments of the present application, the relevant technical terms involved in the embodiments of the present application are explained below.
[0023] The attribute values of the physical machines in the cluster include standard weight, usage weight, resource deviation value, CPU utilization, and memory utilization;
[0024] The standard weight can be k1 or k2 as shown in the following formula (1), that is, the total CPU capacity of the physical machine T cpu and the total memory T mem Ratio of:
[0025] or,
[0026] The usage weight can be p1 or p2 as shown in the following formula (2), that is, the CPU usage U of the physical machine cpu and memory usage U mem Ratio of:
[0027] or,
[0028] The resource deviation value may be f1 or f2 as shown in the following formula (3):
[0029] or,
[0030] The CPU utilization of the physical machine is given by the following formula (4): cpu :
[0031]
[0032] The memory utilization of the physical machine is given by the following formula (5): mem :
[0033]
[0034] The embodiment of the present application provides a resource scheduling method, which can be applied to an electronic device in a cluster, and the electronic device can be any physical machine in the cluster that carries a virtual machine, or can be other computing devices independent of the physical machine that carries the virtual machine. The functions implemented by the resource scheduling method can be implemented by calling program codes by a processor in the electronic device, and of course the program codes can be stored in a computer storage medium. It can be seen that the electronic device at least includes a processor and a storage medium.
[0035] Figure 1 Schematic diagram of the implementation process of the resource scheduling method of the embodiment of the present application, such as Figure 1 As shown, the method may include the following steps 101 to 106:
[0036] Step 101: determine at least one alarm physical machine from the cluster.
[0037] In some embodiments, the alarm physical machine is divided into two categories, namely, a first-category alarm physical machine and a second-category alarm physical machine. The first-category alarm physical machine refers to a physical machine in the cluster whose CPU utilization is greater than a first threshold or a physical machine whose memory utilization is greater than a second threshold. The second-category alarm physical machine refers to a physical machine in the cluster whose sum of CPU utilization and memory utilization is greater than a third threshold, and whose first resource deviation value is less than a fourth threshold or greater than a fifth threshold.
[0038] Step 102: Obtain a first numerical relationship between the total CPU amount and the total memory amount of each of the alarm physical machines.
[0039] In the embodiment of the present application, the first numerical relationship can be various, and the first numerical relationship can be a ratio relationship or a difference relationship, etc. For example, the first numerical relationship is the standard weight mentioned above, that is, the ratio of the total CPU amount to the total memory amount.
[0040] Step 103: determine a second numerical relationship between the CPU usage and the memory usage of each virtual machine in each of the alarm physical machines.
[0041] It should be noted that the calculation criteria of the second numerical relationship are consistent with those of the first numerical relationship. For example, when the first numerical relationship is the total CPU divided by the total memory, the second numerical relationship is the CPU usage of the virtual machine divided by the memory usage of the virtual machine. The first numerical relationship is the total memory divided by the total CPU, and the second numerical relationship is the memory usage of the virtual machine divided by the CPU usage of the virtual machine. When the second numerical relationship is a ratio relationship, the second numerical relationship can also be called load balancing.
[0042] In an embodiment of the present application, the CPU usage and memory usage of the virtual machine may be peak values or average values within a specific time period.
[0043] Step 104, for each of the alarm physical machines, determining a second numerical relationship that does not match the corresponding first numerical relationship;
[0044] Step 105: determine the virtual machine corresponding to the unmatched second numerical relationship as the virtual machine to be migrated.
[0045] It can be understood that based on the first numerical relationship of the alarm physical machine and the second numerical relationship of each virtual machine in the alarm physical machine, the virtual machines corresponding to the second numerical relationship that does not match its first numerical relationship can be screened out from the alarm physical machine, and these mismatched virtual machines can be migrated out, thereby making the resource utilization of the alarm physical machine more balanced.
[0046] For example, assuming that a physical machine has 8 CPU cores (C) and 64 GB of memory, the first numerical relationship of the physical machine is If the second numerical relationship (i.e., load balancing degree) of the first virtual machine hosted on the physical machine is The load balancing degree of the second virtual machine is So, compared to The second virtual machine, The first virtual machine for The physical machine is not friendly, that is, it does not match. In other words, The first virtual machine runs on The physical machine cannot fully utilize the resources of the physical machine, resulting in an unbalanced resource utilization of the physical machine. Therefore, if the first virtual machine is migrated out of the physical machine, the resource utilization of the physical machine can be more balanced.
[0047] Step 106: Migrate each of the virtual machines to be migrated.
[0048] During implementation, the electronic device prioritizes processing of the first type of alarm physical machine, and after completing the migration of the virtual machines in the first type of alarm physical machine, migrates the virtual machines on the second type of alarm physical machine.
[0049] The electronic device can implement the above step 106 through steps 306 to 309 of the following embodiment.
[0050] In an embodiment of the present application, the electronic device obtains a first numerical relationship between the total CPU and total memory of each alarm physical machine in the cluster, and determines a second numerical relationship between the CPU usage and memory usage of each virtual machine in each of the alarm physical machines; then, the virtual machines corresponding to the second numerical relationships in the alarm physical machines that do not match their first numerical relationships are migrated out; in this way, the resource utilization of the migrated alarm physical machines can be made more balanced.
[0051] The present application further provides a resource scheduling method, which may include the following steps 201 to 211:
[0052] Step 201, determining the CPU utilization and memory utilization of each physical machine in the cluster.
[0053] It can be understood that the CPU utilization refers to the CPU usage of the physical machine divided by the total CPU of the physical machine. The CPU usage can be a peak value or an average value within a specific time period. Similarly, the memory utilization of the physical machine refers to the memory usage of the physical machine divided by the total memory of the physical machine. The memory usage of the physical machine can be a peak value or an average value within a specific time period.
[0054] Step 202: A physical machine whose CPU utilization is greater than a first threshold or a physical machine whose memory utilization is greater than a second threshold is determined as a first-class alarm physical machine;
[0055] Step 203, determining the ratio of the total CPU amount to the total memory amount of each of the physical machines as a first numerical relationship corresponding to the physical machine;
[0056] Step 204: determine the ratio of the CPU usage to the memory usage of each of the physical machines as a third numerical relationship corresponding to the physical machine.
[0057] It should be noted that the calculation criteria of the first numerical relationship and the third numerical relationship are consistent. For example, when the first numerical relationship is the total CPU divided by the total memory, the third numerical relationship is the CPU usage divided by the memory usage; conversely, when the first numerical relationship is the total memory divided by the total CPU, the third numerical relationship is the memory usage divided by the CPU usage.
[0058] Step 205, determining the ratio of the first numerical relationship to the third numerical relationship of each of the physical machines as the first resource deviation value of the corresponding physical machine;
[0059] Step 206: determine the physical machine whose sum of CPU utilization and memory utilization is greater than the third threshold and whose first resource deviation value is less than the fourth threshold or greater than the fifth threshold as the second-type alarm physical machine.
[0060] It can be understood that when the first resource deviation value is too large or too small, it indicates that the resource utilization of the corresponding physical machine is unbalanced. For example, the calculation formula of the first resource deviation value is the calculation formula of f1 shown in the above formula (3). When f1 < 0.8, or f1 > 1.2, it indicates that the resource utilization of the physical machine is not balanced enough. However, errors may occur when only this condition is used to determine the alarm physical machine. In other words, when the CPU usage and memory usage of the physical machine are both small, the corresponding first resource deviation value may also be greater than the fifth threshold. For example, the CPU utilization of a physical machine is 1%, and the converted CPU usage is 1%*8C, and the memory utilization is 25%, and the converted memory usage is 25%*64GB. The first resource deviation value obtained in this way is very large, but the load of the physical machine is not high, and even if the virtual machine is not migrated, it will not affect the stability of the physical machine.
[0061] Therefore, in an embodiment of the present application, a restriction condition of "the sum of CPU utilization and memory utilization is greater than the third threshold" is added, so as to avoid including physical machines with low load and high first resource deviation value in the second category of alarm physical machines, thereby avoiding the migration of virtual machines to physical machines with low load and high first resource deviation value.
[0062] Step 207, obtaining a first numerical relationship between the total CPU amount and the total memory amount of each of the alarm physical machines;
[0063] Step 208, determining a second numerical relationship between the CPU usage and the memory usage of each virtual machine in each of the alarm physical machines;
[0064] Step 209, for each of the alarm physical machines, determining a second numerical relationship that does not match the corresponding first numerical relationship;
[0065] Step 210, determining the virtual machine corresponding to the unmatched second numerical relationship as the virtual machine to be migrated;
[0066] Step 211: Migrate each virtual machine to be migrated.
[0067] It should be noted that for both the first type of alarm physical machine and the second type of alarm physical machine, the electronic device implements the migration of the virtual machine through steps 207 to 211. That is, the electronic device handles each alarm physical machine in the same way. In some embodiments, the electronic device preferentially migrates the virtual machines to be migrated in the first type of alarm physical machine. That is, the priority of the first type of alarm physical machine is higher than that of the second type of alarm physical machine.
[0068] It can be understood that the first type of alarm physical machine is a physical machine whose CPU utilization is greater than the first threshold, or a physical machine whose memory utilization is greater than the second threshold. The second type of alarm physical machine is a physical machine whose sum of CPU utilization and memory utilization is greater than the third threshold, and whose first resource deviation value is less than the fourth threshold or greater than the fifth threshold; it can be seen that compared with the second type of alarm physical machine, the first type of alarm physical machine has a larger load, so it is necessary to process this type of physical machine first to migrate out the virtual machines that meet the conditions, so as to ensure the operation stability of this type of physical machine.
[0069] The so-called stability refers to the long-term normal operation of each virtual machine in the physical machine, and while ensuring the operational stability of the physical machine, it also indirectly reduces the loss of the CPU. This is because the higher the CPU utilization, the greater the loss of the CPU.
[0070] The embodiment of the present application further provides a resource scheduling method, which may include the following steps 301 to 309:
[0071] Step 301, determining at least one alarm physical machine from the cluster;
[0072] Step 302, obtaining a first numerical relationship between the total CPU amount and the total memory amount of each of the alarm physical machines; the first numerical relationship is a ratio;
[0073] Step 303: Determine the ratio of the CPU usage to the memory usage of each virtual machine in the jth alarm physical machine as a second numerical relationship of the corresponding virtual machine; wherein j is an integer greater than 0 and less than or equal to the total number of the alarm physical machines;
[0074] Step 304: When the absolute value of the difference between the second numerical relationship and the first numerical relationship is greater than a sixth threshold, determine that the second numerical relationship does not match the first numerical relationship.
[0075] It can be understood that when the gap between the second numerical relationship and the first numerical relationship is large, it means that the virtual machine corresponding to the second numerical relationship matches the current physical machine, and when the virtual machine runs on the physical machine, the resources of the physical machine cannot be fully utilized.
[0076] For example, if the total CPU capacity of a physical machine is 8C and the total memory capacity is 64GB, then the first numerical relationship of the physical machine is If the second numerical relationship (i.e., load balancing degree) of the first virtual machine hosted on the physical machine is The load balancing degree of the second virtual machine is So, compared to The second virtual machine, The first virtual machine for The physical machine is not friendly, that is, it does not match. In other words, The first virtual machine runs on When the first virtual machine is on a physical machine, the resources of the physical machine cannot be fully utilized, resulting in an unbalanced resource utilization of the physical machine. Therefore, if the first virtual machine is migrated out of the physical machine, the resource utilization of the physical machine can be more balanced.
[0077] In some embodiments, the electronic device may further determine that a second numerical relationship corresponding to the first N largest absolute values does not match the first numerical relationship, where N is an integer greater than 0.
[0078] It can be understood that the larger the absolute value of the difference between the second numerical relationship and the first numerical relationship is, the more mismatched the virtual machine corresponding to the second numerical relationship is with the current physical machine.
[0079] Step 305, determining the virtual machine corresponding to the second numerical relationship that does not match the first numerical relationship in the alarm physical machine as the virtual machine to be migrated;
[0080] Step 306, determine the second resource deviation value of the corresponding other physical machine assuming that after the virtual machine to be migrated is migrated to at least one other physical machine in the cluster; wherein the other physical machine is a non-idle physical machine in the cluster except the physical machine where the virtual machine to be migrated was located before being migrated.
[0081] It should be noted that the at least one other physical machine may be one physical machine or multiple physical machines. When multiple physical machines are present, they may be part of or each of the other physical machines in the cluster.
[0082] It can be understood that the CPU usage and memory usage of the virtual machine to be migrated are known, and before migrating the virtual machine, the total CPU, CPU usage, total memory and memory usage of each physical machine are also known; therefore, based on these known quantities, it is easy to determine the resource deviation value of a physical machine after migrating the virtual machine to be migrated.
[0083] Step 307: Determine the other physical machines whose absolute value of the difference between the second resource deviation value and the specific value is smaller than the corresponding seventh threshold as candidate physical machines.
[0084] In one example, the specific value may be set to 1. The seventh threshold corresponding to each second resource deviation value may be the same or different; when the seventh threshold is the same, for example, when the specific value is 1, the seventh threshold is 0.2. When the seventh threshold is different, the seventh threshold may be the difference between the third resource deviation value and the specific value, wherein the third resource deviation value refers to the resource deviation value of the physical machine corresponding to the second resource deviation value before the virtual machine to be migrated is migrated.
[0085] Step 308: determine a target physical machine from the determined candidate physical machines.
[0086] In some embodiments, the electronic device can first obtain the third resource deviation value of each candidate physical machine before migrating into the virtual machine to be migrated; then, select the candidate physical machine with the largest absolute value of the difference between the third resource deviation value and the corresponding second resource deviation value as the target physical machine.
[0087] In fact, step 306 to step 307 is to find multiple physical machines that are relatively matched with the virtual machine to be migrated. The reason why the candidate physical machine with the largest absolute value of the difference between the third resource deviation value and the corresponding second resource deviation value is selected as the target physical machine is to maximize the utilization of the resources in the target physical machine. That is, after the virtual machine to be migrated is migrated to the target physical machine, the resources of the target physical machine can be fully utilized, and the resource utilization rate is higher and more balanced.
[0088] Step 309: Migrate the virtual machine to be migrated to the target physical machine.
[0089] It should be noted that the electronic device processes each alarm physical machine according to the above steps 303 to 309 to migrate the virtual machines to be migrated in each alarm physical machine, thereby making the resource utilization in the entire cluster more balanced and enhancing the operating stability of each virtual machine in the cluster.
[0090] In some embodiments, when the target physical machine does not exist in the cluster, the virtual machine to be migrated is migrated to an idle physical machine, so as to ensure that the resource utilization of the physical machines in the entire cluster is more balanced.
[0091] In the related art, a dynamic resource scheduling method is provided, which sets a weight coefficient according to the average value of the CPU, memory, and disk of the physical server in the entire scheduling area, and then calculates the target node for virtual machine migration through the coefficient. However, this method only considers the consumption rate of the CPU, memory, and disk of the physical server, and does not consider the reasonable allocation of multiple resources, so there is a situation where one type of resource is occupied too much and the utilization rate of other resources is low, and the resource scheduling method is not comprehensive;
[0092] In another related technology, two resource scheduling algorithms are provided, including a hotspot removal algorithm and an energy-saving integration algorithm. Among them, the hotspot removal algorithm mainly migrates all virtual machines on physical servers with loads less than a threshold. The energy-saving integration algorithm mainly migrates all virtual machines on physical servers with the highest load. However, how to calculate the load balance of the physical servers that have been migrated is not clearly given. Moreover, when performing resource scheduling, this method only selects virtual machines on physical servers with the highest or lowest loads for migration, and only considers reducing the load, without considering the multi-dimensional loads of the physical servers after migration, such as CPU and memory.
[0093] The CPU and memory of each physical server in the resource pool are not necessarily the same. When performing dynamic resource scheduling, related technologies only consider resource utilization. There is a situation where the utilization of one indicator is high, but the utilization of other resources is low, resulting in unreasonable resource distribution. When the memory utilization of a physical server is high, it needs to be migrated, but its CPU utilization is relatively low. There is no distinction between computing virtual machines and memory virtual machines, resulting in unbalanced resource utilization.
[0094] In other words, in the relevant dynamic resource scheduling methods, there is often a situation where a certain indicator of the physical server is too high, and multi-dimensional indicators such as CPU and memory are not fully considered. In order to make full use of the resource utilization of the physical server and avoid the situation where a single indicator is too high and other indicators are low, a new type of dynamic resource scheduling method is provided in the embodiment of the present application, so that the CPU and memory utilization in the resource pool are evenly distributed.
[0095] Based on this, an exemplary application of an embodiment of the present application in a practical application scenario will be described below.
[0096] In the OpenStack resource pool, virtual machines rarely use the local disks of physical servers, so in the embodiments of the present application, the hard disk usage of the physical server is not considered.
[0097] In some embodiments, relevant information of physical servers in a resource pool (i.e., a cluster) is collected through an information collection module in OpenStack, and the collected data includes the total CPU amount, CPU usage, total memory and memory usage of the physical server, as well as the CPU usage and memory usage of the virtual machines therein.
[0098] In some embodiments, according to the total CPU amount T of the i-th physical server collected by the information collection module cpu 、CPU usage U cpu 、Total memory T mem and memory usage U mem , calculate multiple attribute values of the physical server; the multiple attribute values include standard weight k i , using weight p i and resource deviation f i ;in,
[0099] In some embodiments, an upper limit alarm queue is set, and when the CPU utilization or memory utilization of a physical server exceeds the corresponding set value, the physical server is added to the upper limit alarm queue. The physical server in the upper limit alarm queue is the first type of alarm physical machine.
[0100] In some embodiments, a resource balancing alarm queue is set. When the sum of the CPU utilization and memory utilization of the physical server exceeds the set coefficient q and satisfies f i <0.8 or f i >1.2 (the coefficients 0.8 and 1.2 can be adjusted appropriately according to the situation), the physical server is added to the resource balancing alarm queue. The physical servers in the resource balancing alarm queue are the second type of alarm physical machines.
[0101] In some embodiments, the upper limit alarm queue has a higher priority than the resource balancing alarm queue. When the upper limit alarm queue has data, the upper limit alarm queue is processed first. When the upper limit alarm queue is empty, the resource balancing alarm queue is processed.
[0102] The virtual machine migration methods in the two alarm queues are the same, as follows:
[0103] First, calculate the load balance of each virtual machine in the physical server in the alarm queue (hereinafter referred to as the alarm physical server) That is, the second numerical relationship, where vmcpu m 、vmmem mThey respectively represent the CPU usage and memory usage of the mth virtual machine in the physical server; m is an integer greater than 0 and less than or equal to the total number of virtual machines in the physical server.
[0104] Then, select the virtual machine to be migrated from the alarm physical server, wherein vmp m and the standard weight k of the alarm server i One or more virtual machines whose absolute value of the difference is greater than the sixth threshold are used as virtual machines to be migrated. After the virtual machines are migrated, the load of the alarm physical server will be reduced. At the same time, the CPU utilization and memory utilization of the alarm physical server will be more balanced, and there will be no situation where one resource is overused and the other resource is underused.
[0105] Finally, the resource deviation value f of the virtual machine to be migrated is calculated respectively after migrating the virtual machine to other physical servers, and a physical server with a better resource deviation value f (f is closer to 1) is selected as the target server, and the virtual machine is migrated to the target server; wherein, the method for determining whether f is closer to 1 is, for example, determining whether the absolute value of the difference between f and 1 is less than the seventh threshold; if so, it is determined that f is closer to 1. If there is no better physical server, a new idle physical server is selected as the target server.
[0106] When the migration is complete, the resource utilization of the physical servers in the entire resource pool will be more balanced.
[0107] In an embodiment of the present application, a new dynamic resource scheduling method is provided, which can ensure that the resource utilization of the physical servers in the platform is more balanced, thereby increasing the stability of the platform and virtual machines.
[0108] The present application embodiment further provides a resource scheduling method, Figure 2 FIG. 1 is a schematic diagram of another implementation flow of a resource scheduling method according to an embodiment of the present application. Figure 2 As shown, the steps include steps 401 to 414:
[0109] Step 401, the management platform determines whether the upper limit alarm queue is empty; if so, execute step 402; otherwise, execute step 409;
[0110] Step 402, the management platform determines whether the resource balancing alarm queue is empty; if so, the process ends; otherwise, the process proceeds to step 403;
[0111] Step 403, the management platform determines whether the alarm nodes in the resource balancing alarm queue have been traversed; if yes, the process ends; otherwise, the process proceeds to step 404;
[0112] Step 404, the management platform confirms any alarm node to be processed in the resource balancing alarm queue, that is, the second type of alarm physical machine;
[0113] Step 405, the management platform selects a virtual machine to be migrated from the alarm nodes to be processed;
[0114] Step 406, the management platform determines whether there is a better migration node, that is, the target physical machine, in the resource pool; if yes, execute step 407; otherwise, execute step 408;
[0115] Step 407: the management platform migrates the virtual machine to be migrated to the better migration node; then, the process returns to step 403;
[0116] Here, it should be noted that the method for selecting a better migration node can be implemented through steps 701 to 712 of the following embodiment.
[0117] Step 408: The management platform migrates the virtual machine to be migrated to an idle node; then, the process returns to step 403;
[0118] Step 409, the management platform determines whether the upper limit alarm queue has been traversed; if so, execute step 402; otherwise, execute step 410;
[0119] Step 410, the management platform determines any alarm node to be processed in the upper limit alarm queue, that is, the first type of alarm physical machine;
[0120] Step 411, the management platform selects a virtual machine to be migrated from the alarm nodes to be processed;
[0121] Step 412, the management platform determines whether there is a better migration node in the resource pool; if yes, execute step 413; otherwise, execute step 414;
[0122] Step 413: the management platform migrates the virtual machine to be migrated to the better migration node; then, the process returns to step 409;
[0123] In step 414 , the management platform migrates the virtual machine to be migrated to an idle node; then, the process returns to step 409 .
[0124] The present application embodiment provides a method for determining an alarm queue. Figure 3 The following is a flow chart of the method for determining the alarm queue according to the embodiment of the present application. Figure 3 As shown, the method may include the following steps 501 to 509:
[0125] Step 501, the management platform determines whether all physical nodes in the resource pool have been traversed; if yes, the process ends; otherwise, the process proceeds to step 502;
[0126] Step 502, the management platform confirms the running node;
[0127] Step 503, the management platform obtains the total CPU amount a, total memory amount b, CPU usage x, and memory usage y of the running node;
[0128] Step 504, the management platform determines whether the usage x or the usage y exceeds the corresponding upper limit; if yes, execute step 505; otherwise, execute step 506;
[0129] Step 505: the management platform adds the running node to the upper limit alarm queue; then, the process returns to step 501;
[0130] Step 506, the management platform calculates k=a / b, p=x / y;
[0131] Step 507, the management platform calculates f=k / p;
[0132] Step 508, the management platform determines whether f is less than 0.8 or greater than 1.2; if yes, execute step 509; otherwise, return to execute step 501;
[0133] Step 509: The management platform adds the running node to the resource balancing alarm queue; then, returns to execute step 501.
[0134] The present invention provides a method for selecting a virtual machine to be migrated. Figure 4 A schematic diagram of a method for implementing a flow chart of selecting a virtual machine to be migrated according to an embodiment of the present application is shown in FIG. Figure 4 As shown, the method may include the following steps 601 to 605:
[0135] Step 601, the management platform confirms the running node;
[0136] Step 602: The management platform obtains the total CPU amount a and the total memory amount b of the running node, and calculates k=a / b;
[0137] Step 603: The management platform obtains the CPU usage m and memory usage n of all virtual machines in the running node, and calculates p=m / n;
[0138] Step 604: The management platform sorts the virtual machines according to the absolute value of the difference between p and k, with the virtual machines with larger difference being ranked first.
[0139] Step 605: The management platform selects one or more virtual machines that are arranged at the front to migrate.
[0140] The present application embodiment provides a method for selecting a target physical server. Figure 5 The following is a flow chart of a method for selecting a target physical server according to an embodiment of the present application. Figure 5 As shown, the method may include the following steps 701 to 712:
[0141] Step 701, the management platform confirms the running node;
[0142] Step 702, the management platform determines the virtual machine to be migrated;
[0143] Step 703, the management platform obtains the CPU usage m and memory usage n of each virtual machine to be migrated;
[0144] Step 704, the management platform determines whether each remaining node has been traversed; if not, execute step 705; if yes, execute step 710;
[0145] The remaining nodes refer to nodes in the resource pool except the running nodes.
[0146] Step 705, the management platform obtains the total CPU amount, total memory amount, CPU usage and memory usage of the running node;
[0147] Step 706, the management platform determines the resource deviation value f1 of the running node according to the data obtained in step 705;
[0148] Step 707, the management platform adds the CPU usage and memory usage of the virtual machine to be migrated to the load of the running node, and determines the resource deviation value f2 of the running node;
[0149] Step 708, the management platform determines whether |f2-1| is less than |f1-1|; if so, execute step 709; otherwise, return to execute step 704;
[0150] Step 709, calculate the value of |f2-f1|, and put the running node into the optimization node queue; then, return to execute step 704;
[0151] Step 710, the management platform determines whether the optimization node queue is empty; if so, execute step 711; otherwise, execute step 712;
[0152] Step 711, the management platform selects an idle node as a target physical server;
[0153] Step 712: The management platform selects the node corresponding to the maximum |f2-f1| in the optimization node queue as the target physical server.
[0154] Based on the foregoing embodiments, an embodiment of the present application provides a resource scheduling device, which includes the modules included and the units included in the modules, and can be implemented by a processor in an electronic device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.
[0155] Figure 6 Schematic diagram of the structure of the resource scheduling device of the embodiment of the present application, such as Figure 6 As shown, the device 600 includes a determination module 601, an acquisition module 602 and a migration module 603; wherein,
[0156] A determination module 601 is used to determine at least one alarm physical machine from the cluster;
[0157] The acquisition module 602 is used to obtain a first numerical relationship between the total CPU amount and the total memory amount of each of the alarm physical machines;
[0158] The determination module 601 is further used to determine a second numerical relationship between the CPU usage and the memory usage of each virtual machine in each of the alarm physical machines;
[0159] The determination module 601 is further configured to determine, for each of the alarm physical machines, a second numerical relationship that does not match the corresponding first numerical relationship; and determine a virtual machine corresponding to the second numerical relationship that does not match as a virtual machine to be migrated;
[0160] The migration module 603 is used to migrate each virtual machine to be migrated.
[0161] In some embodiments, the alarm physical machine includes a first type of alarm physical machine and a second type of alarm physical machine; wherein, the priority of the first type of alarm physical machine is higher than that of the second type of alarm physical machine, and when performing virtual machine migration, the virtual machines to be migrated in the first type of alarm physical machine are migrated first; the determination module 601 is used to: determine the CPU utilization and memory utilization of each physical machine in the cluster; and determine a physical machine whose CPU utilization is greater than a first threshold or a physical machine whose memory utilization is greater than a second threshold as the first type of alarm physical machine.
[0162] In some embodiments, determination module 601 is used to: determine the ratio of the total CPU amount to the total memory amount of each of the physical machines as the first numerical relationship of the corresponding physical machine; determine the ratio of the CPU usage to the memory usage of each of the physical machines as the third numerical relationship of the corresponding physical machine; determine the ratio of the first numerical relationship to the third numerical relationship of each of the physical machines as the first resource deviation value of the corresponding physical machine; determine a physical machine whose sum of CPU utilization and memory utilization is greater than the third threshold and whose first resource deviation value is less than the fourth threshold or greater than the fifth threshold as the second type of alarm physical machine.
[0163] In some embodiments, determination module 601 is used to: determine the ratio of CPU usage to memory usage of each virtual machine in the jth alarm physical machine as a second numerical relationship of the corresponding virtual machine; wherein j is an integer greater than 0 and less than or equal to the total number of the alarm physical machines; accordingly, determination module 601 is used to: determine that the second numerical relationship does not match the first numerical relationship when the absolute value of the difference between the second numerical relationship and the first numerical relationship is greater than a sixth threshold; or, determine the second numerical relationship corresponding to the first N largest absolute values as not matching the first numerical relationship, wherein N is an integer greater than 0.
[0164] In some embodiments, the migration module 603 is used to: determine the second resource deviation value of the corresponding virtual machine to be migrated after migrating the virtual machine to be migrated to at least one other physical machine in the cluster; wherein the other physical machine is a non-idle physical machine in the cluster except the physical machine where the virtual machine to be migrated was located before being migrated; determine the other physical machine whose absolute value of the difference between the second resource deviation value and the specific value is less than the corresponding seventh threshold as a candidate physical machine; determine a target physical machine from the determined candidate physical machines; and migrate the virtual machine to be migrated to the target physical machine.
[0165] In some embodiments, determination module 601 is used to: obtain the third resource deviation value of each candidate physical machine before migrating the virtual machine to be migrated; select the candidate physical machine with the largest absolute value of the difference between the third resource deviation value and the corresponding second resource deviation value as the target physical machine.
[0166] In some embodiments, the migration module 603 is further used to: when the target physical machine does not exist in the cluster, migrate the virtual machine to be migrated to an idle physical machine.
[0167] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0168] It should be noted that in the embodiment of the present application, if the above-mentioned resource scheduling method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including a number of instructions to enable an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0169] Correspondingly, an embodiment of the present application provides an electronic device, Figure 7 A hardware entity diagram of an electronic device according to an embodiment of the present application is shown in FIG. Figure 7 As shown, the hardware entity of the electronic device 700 includes: a memory 701 and a processor 702, wherein the memory 701 stores a computer program that can be run on the processor 702, and the processor 702 implements the steps in the resource scheduling method provided in the above embodiment when executing the program.
[0170] The memory 701 is configured to store instructions and applications executable by the processor 702, and can also cache data to be processed or processed by the processor 702 and various modules in the electronic device 700 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0171] Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the resource scheduling method provided in the above embodiment are implemented.
[0172] It should be noted here that the description of the above storage medium, chip and terminal device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium, chip and terminal device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0173] It should be understood that "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" or "in some embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.
[0174] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0175] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments of the touch screen system described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be electrical, mechanical or other forms.
[0176] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed on multiple network units; some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0177] In addition, all functional modules in the embodiments of the present application may be integrated into one processing unit, or each module may be a separate unit, or two or more modules may be integrated into one unit; the above-mentioned integrated modules may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0178] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0179] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0180] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0181] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0182] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0183] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A resource scheduling method, characterized in that: The method comprises: Determine at least one alarm physical machine from the cluster; Obtaining a first numerical relationship between the total CPU amount and the total memory amount of each of the alarm physical machines; Determine a second numerical relationship between the CPU usage and the memory usage of each virtual machine in each of the alarm physical machines; wherein the calculation criteria of the second numerical relationship and the first numerical relationship are consistent; For each of the alarming physical machines, determining a second numerical relationship that does not match the corresponding first numerical relationship; Determine the virtual machine corresponding to the unmatched second numerical relationship as the virtual machine to be migrated; Migrating each of the virtual machines to be migrated; The alarm physical machine includes a first type of alarm physical machine and a second type of alarm physical machine; wherein the priority of the first type of alarm physical machine is higher than that of the second type of alarm physical machine, and when performing virtual machine migration, the virtual machine to be migrated in the first type of alarm physical machine is migrated first; The step of determining at least one alarm physical machine from the cluster includes: Determine the CPU utilization and memory utilization of each physical machine in the cluster; Determine a physical machine whose CPU utilization is greater than a first threshold or a physical machine whose memory utilization is greater than a second threshold as the first type of alarm physical machine; The step of determining at least one alarm physical machine from the cluster further includes: Determine the ratio of the total CPU amount to the total memory amount of each of the physical machines as a first numerical relationship corresponding to the physical machine; Determine the ratio of the CPU usage to the memory usage of each of the physical machines as a third numerical relationship corresponding to the physical machine; Determine a ratio of the first numerical relationship to the third numerical relationship of each of the physical machines as a first resource deviation value of the corresponding physical machine; A physical machine whose sum of CPU utilization and memory utilization is greater than the third threshold and whose first resource deviation value is less than the fourth threshold or greater than the fifth threshold is determined as the second-type alarm physical machine.
2. The method according to claim 1, characterized in that The determining of a second numerical relationship between the CPU usage and the memory usage of each virtual machine in each of the alarm physical machines includes: Determine the ratio of the CPU usage to the memory usage of each virtual machine in the jth alarm physical machine as the second numerical relationship of the corresponding virtual machine; wherein j is an integer greater than 0 and less than or equal to the total number of the alarm physical machines; Accordingly, the determining of a second numerical relationship that does not match the corresponding first numerical relationship includes: When the absolute value of the difference between the second numerical relationship and the first numerical relationship is greater than a sixth threshold, it is determined that the second numerical relationship does not match the first numerical relationship; or, The second numerical relationship corresponding to the first N largest absolute values is determined to be mismatched with the first numerical relationship, where N is an integer greater than 0.
3. The method according to claim 1, characterized in that The migrating each of the virtual machines to be migrated includes: Determine a second resource deviation value of the corresponding at least one other physical machine in the cluster after the virtual machine to be migrated is migrated to the other physical machine; wherein the other physical machine is a non-idle physical machine in the cluster except the physical machine where the virtual machine to be migrated is located before being migrated; Determine the other physical machines whose absolute value of the difference between the second resource deviation value and the specific value is smaller than the corresponding seventh threshold as candidate physical machines; Determine a target physical machine from the determined candidate physical machines; Migrate the virtual machine to be migrated to the target physical machine.
4. The method according to claim 3, characterized in that The step of determining a target physical machine from the determined candidate physical machines includes: Obtaining a third resource deviation value of each candidate physical machine before migrating the virtual machine to be migrated; A candidate physical machine having a maximum absolute value of a difference between the third resource deviation value and the corresponding second resource deviation value is selected as the target physical machine.
5. The method according to claim 3, characterized in that: The method further comprises: When the target physical machine does not exist in the cluster, the virtual machine to be migrated is migrated to an idle physical machine.
6. A resource scheduling device, characterized in that: include: A determination module, used to determine at least one alarm physical machine from the cluster; An acquisition module, used to acquire a first numerical relationship between the total CPU amount and the total memory amount of each of the alarm physical machines; The determination module is further used to determine a second numerical relationship between the CPU usage and the memory usage of each virtual machine in each of the alarm physical machines; wherein the calculation criteria of the second numerical relationship are consistent with the calculation criteria of the first numerical relationship; The determination module is further configured to determine, for each of the alarming physical machines, a second numerical relationship that does not match the corresponding first numerical relationship; and determine a virtual machine corresponding to the second numerical relationship that does not match as a virtual machine to be migrated; A migration module, used to migrate each virtual machine to be migrated; The alarm physical machines include first-class alarm physical machines and second-class alarm physical machines; wherein, the priority of the first-class alarm physical machines is higher than that of the second-class alarm physical machines, and when performing virtual machine migration, the virtual machines to be migrated in the first-class alarm physical machines are migrated first; the determination module is used to determine the CPU utilization and memory utilization of each physical machine in the cluster; a physical machine whose CPU utilization is greater than a first threshold or a physical machine whose memory utilization is greater than a second threshold is determined as the first-class alarm physical machine; The determination module is also used to determine the ratio of the total CPU amount to the total memory amount of each of the physical machines as the first numerical relationship of the corresponding physical machine; determine the ratio of the CPU usage to the memory usage of each of the physical machines as the third numerical relationship of the corresponding physical machine; determine the ratio of the first numerical relationship to the third numerical relationship of each of the physical machines as the first resource deviation value of the corresponding physical machine; and determine a physical machine whose sum of CPU utilization and memory utilization is greater than the third threshold and whose first resource deviation value is less than the fourth threshold or greater than the fifth threshold as the second type of alarm physical machine.
7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the program, the steps in the resource scheduling method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the resource scheduling method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Load balancing method and device
CN106445629A
Method and device for achieving resource scheduling
CN108667859A