Virtual machine scheduling method and device, nonvolatile storage medium and electronic equipment
By calculating the average absolute error of the anti-affinity and adjusting the index, the optimal balanced distribution of virtual machines among hosts is achieved, and the problem of inaccurate virtual machine scheduling in the existing technology is solved, and resource utilization is optimized and business interruption risks are reduced.
Patent Information
- Application Number
- CN202510520631.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-07-29
AI Technical Summary
The prior art cannot quickly and accurately schedule virtual machines that may have affinity risks, resulting in uneven resource utilization and increased risk of business interruption, and lack of intelligent scheduling strategies.
By obtaining the virtual machine and host information in the customer relationship management system, calculate the anti-affinity average absolute error and adjustment index, and perform virtual machine scheduling in the order of adjustment index from large to small, ensuring the balanced distribution of virtual machines among hosts.
It realizes rapid and accurate scheduling of virtual machines that may have affinity potential, optimize resource utilization, reduce business interruption risks, and ensures the optimal balanced distribution of virtual machines among hosts.
Smart Images

Figure CN120389949A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of operation and maintenance, and in particular, to a virtual machine scheduling method and apparatus, a non-volatile storage medium, and an electronic device. Background Art
[0002] In the telecommunications industry, as the core business support system, the Customer Relationship Management (CRM) system has a more complex and dynamic IT resource structure with the application of cloud computing technology. With the continuous expansion of business and the in-depth application of cloud technology, the management and deployment of virtual machines (VMs) under the CRM system have become increasingly complex. Especially in the face of a multi-cluster virtual machine environment, ensuring the dispersed deployment of VMs in different clusters and avoiding concentration on the same physical server or host is of great significance for reducing the business impact caused by a single host failure. This strategy is called anti-affinity deployment, and its purpose is to optimize resource utilization and reduce the potential risk of business interruption on the basis of ensuring high availability.
[0003] However, the related anti-affinity management and virtual machine scheduling methods have obvious deficiencies: when an affinity hidden danger is discovered, the operation and maintenance personnel need to manually identify the affected virtual machine clusters and determine the migration target host for each virtual machine. In a large CRM system, this process is extremely time-consuming and it is difficult to consider the optimal allocation of resources from a global perspective, often resulting in uneven resource utilization and even deteriorating the anti-affinity situation. In addition, when dealing with anti-affinity problems, the related technologies cannot automatically quantify the importance of clusters and the severity of affinity hidden dangers, thus lacking an intelligent scheduling strategy based on business impact and resource status. This means that even under limited resource conditions, it is impossible to ensure that the clusters with the greatest impact on the business are adjusted first, lacking an effective judgment on the adjustment priority.
[0004] To address the above problems, no effective solution has been proposed yet. Summary of the Invention
[0005] This application provides a virtual machine scheduling method and apparatus, a non-volatile storage medium, and an electronic device, so as to at least solve the technical problem that the related technologies cannot schedule virtual machines with possible affinity hidden dangers quickly and accurately.
[0006] According to one aspect of the present application, a virtual machine scheduling method is provided, including: obtaining target data related to virtual machines in a customer relationship management system, where the customer relationship management system includes multiple virtual machine clusters, and the target data at least includes: information of virtual machines in the virtual machine cluster and information of the host machines on which the virtual machines run; for any virtual machine cluster, determining the anti-affinity mean absolute error of the virtual machine cluster according to the first quantity of virtual machines actually carried by each host machine in the target data, the total quantity of virtual machines, and the second quantity of virtual machines that each host machine can theoretically carry, where the anti-affinity mean absolute error is used to characterize whether the virtual machines are deployed on different host machines according to the anti-affinity rule; determining whether the virtual machine cluster meets the anti-affinity index according to the anti-affinity mean absolute error, and determining the anti-affinity adjustment index of each target virtual machine cluster according to the anti-affinity mean absolute error and different preset importance indexes corresponding to different target virtual machine clusters, where the target virtual machine cluster is a virtual machine cluster that does not meet the anti-affinity index; scheduling the quantity of virtual machines carried by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
[0007] Optionally, determining the anti-affinity mean absolute error of the virtual machine cluster according to the first quantity of virtual machines actually carried by each host machine in the target data, the total quantity of virtual machines, and the second quantity of virtual machines that each host machine can theoretically carry includes: obtaining the first quantity of virtual machines actually carried by each host machine to obtain multiple first quantities; determining the second quantity of virtual machines that each host machine can theoretically carry according to the total quantity of virtual machines and the total quantity of host machines to obtain multiple second quantities; arranging the multiple first quantities in descending order to obtain a first array, and arranging the multiple second quantities in descending order to obtain a second array; determining the anti-affinity mean absolute error of the virtual machine cluster according to the first array and the second array.
[0008] Optionally, determining the anti-affinity mean absolute error of the virtual machine cluster according to the first array and the second array includes: calculating the difference between the elements at the same position in the first array and the second array to obtain multiple differences; calculating the absolute value of each difference to obtain multiple absolute errors, and adding the multiple absolute errors to obtain a total error; calculating the target ratio between the total error and the quantity of virtual machines, and determining the target ratio as the anti-affinity mean absolute error.
[0009] Optionally, based on the total number of virtual machines and the total number of host machines, the second number of virtual machines that each host machine can theoretically carry is determined, including: dividing the total number of virtual machines by the total number of host machines to obtain a first calculation result, wherein the first calculation result includes: a quotient and a remainder; when the remainder is zero, determining the quotient as the second number of virtual machines that each host machine can theoretically carry; when the remainder is not zero, determining to use r host machines to carry (a+1) virtual machines, and determining to use (xr) host machines to carry a virtual machines, wherein r is the remainder, a is the quotient, x is the total number of host machines, and x is a positive integer greater than 1.
[0010] Optionally, after arranging multiple first quantities in descending order to obtain a first array, and arranging multiple second quantities in descending order to obtain a second array, the method further includes: in the first array and the second array, determining the identification information of different host machines as index information of elements at different positions.
[0011] Optionally, the number of virtual machines carried by the host machines in the target virtual machine cluster is scheduled in descending order of the anti-affinity adjustment index, including: determining one or more first elements with the largest element value and one or more second elements with the smallest element value in the first array corresponding to the target virtual machine cluster; determining one or more first host machines corresponding to the one or more first elements according to the index information of the one or more first elements, and determining one or more second host machines corresponding to the one or more second elements according to the index information of the one or more second elements; when there are multiple first host machines, obtaining a first indicator of each first host machine, and determining a first target host machine with the smallest first indicator among the multiple first host machines, wherein the first indicator is used to characterize the busyness of the host machine during business processing, and the first indicator is proportional to the busyness; when there are multiple second host machines, obtaining a second indicator of each second host machine, and determining a second target host machine with the largest second indicator among the multiple second host machines, wherein the second indicator is used to characterize the operating pressure of the host machine during business processing, and the second indicator is proportional to the operating pressure; scheduling some of the virtual machines carried by the first target host machine to the second target host machine.
[0012] Optionally, after scheduling the number of virtual machines hosted by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index, the method further includes: determining the anti-affinity mean absolute error of each virtual machine cluster; determining whether the virtual machine cluster meets the anti-affinity index according to the anti-affinity mean absolute error; for the target virtual machine cluster that does not meet the anti-affinity index, repeatedly execute the following steps until all the virtual machine clusters in the customer relationship management system meet the anti-affinity index: scheduling the number of virtual machines hosted by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
[0013] According to another aspect of the present application, there is also provided a virtual machine scheduling device, including: an acquisition module, configured to acquire target data related to virtual machines in a customer relationship management system, where the customer relationship management system includes multiple virtual machine clusters, and the target data at least includes: information of virtual machines in the virtual machine cluster and information of host machines on which the virtual machines run; a first determination module, configured to, for any virtual machine cluster, determine the anti-affinity mean absolute error of the virtual machine cluster according to the first number of virtual machines actually hosted by each host machine and the total number of virtual machines in the target data, and the second number of virtual machines that each host machine is theoretically capable of hosting, where the anti-affinity mean absolute error is used to characterize whether the virtual machines are deployed on different host machines according to the anti-affinity rule; a second determination module, configured to determine whether the virtual machine cluster meets the anti-affinity index according to the anti-affinity mean absolute error, and determine the anti-affinity adjustment index of each target virtual machine cluster according to the anti-affinity mean absolute error and different preset importance indexes corresponding to different target virtual machine clusters, where the target virtual machine cluster is a virtual machine cluster that does not meet the anti-affinity index; a scheduling module, configured to schedule the number of virtual machines hosted by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
[0014] According to another aspect of the present application, there is also provided a non-volatile storage medium, where the storage medium includes a stored program, and when the program runs, it controls the device where the storage medium is located to execute the above virtual machine scheduling method.
[0015] According to another aspect of the present application, there is also provided an electronic device, including: a memory and a processor, where the processor is configured to run a program stored in the memory, and when the program runs, it executes the above virtual machine scheduling method.
[0016] According to another aspect of the present application, there is also provided a computer program, where when the computer program is executed by a processor, it implements the above virtual machine scheduling method.
[0017] According to another aspect of the present application, a computer program product is further provided. The computer program product includes a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above virtual machine scheduling method is implemented.
[0018] In the present application, target data related to virtual machines in a customer relationship management system is obtained. The customer relationship management system includes multiple virtual machine clusters, and the target data at least includes: information of virtual machines in the virtual machine cluster and information of the host machines on which the virtual machines run. For any virtual machine cluster, according to the first quantity of virtual machines actually borne by each host machine in the target data, the total quantity of virtual machines, and the second quantity of virtual machines that each host machine is theoretically capable of bearing, the anti-affinity mean absolute error of the virtual machine cluster is determined. The anti-affinity mean absolute error is used to characterize whether the virtual machines are deployed on different host machines according to the anti-affinity rule. According to the anti-affinity mean absolute error, it is determined whether the virtual machine cluster meets the anti-affinity index, and according to the anti-affinity mean absolute error and different preset importance indexes corresponding to different target virtual machine clusters, the anti-affinity adjustment index of each target virtual machine cluster is determined, where the target virtual machine cluster is a virtual machine cluster that does not meet the anti-affinity index. By scheduling the quantity of virtual machines borne by the host machines in the target virtual machine cluster in the order from largest to smallest anti-affinity adjustment index, the purpose of quickly and accurately scheduling virtual machines that may have affinity hidden dangers is achieved, thereby realizing the technical effect of the optimal balanced distribution of virtual machines among host machines, and further solving the technical problem that the related technology cannot quickly and accurately schedule virtual machines that may have affinity hidden dangers. Description of the Drawings
[0019] The drawings described herein are used to provide a further understanding of the present application and form a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0020] Figure 1 is a flowchart of a virtual machine scheduling method according to an embodiment of the present application;
[0021] Figure 2 is a schematic architecture diagram of a virtual machine scheduling system according to an embodiment of the present application;
[0022] Figure 3 is a flowchart of another virtual machine scheduling method according to an embodiment of the present application;
[0023] Figure 4 is a structural diagram of a virtual machine scheduling device according to an embodiment of the present application;
[0024] Figure 5 It is a hardware block diagram of a computer terminal for a virtual machine scheduling method according to an embodiment of the present application. Detailed implementation manners
[0025] In order to enable those skilled in the art of the present technology to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data used can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order different from those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily need to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0027] According to an embodiment of the present application, a method embodiment of a virtual machine scheduling method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.
[0028] Figure 1 It is a flowchart of a virtual machine scheduling method according to an embodiment of the present application. As Figure 1 shown, the method includes the following steps:
[0029] Step S102, obtain target data related to virtual machines in the customer relationship management system. Among them, the customer relationship management system includes multiple virtual machine clusters, and the target data at least includes: information of virtual machines in the virtual machine cluster and information of the host machines on which the virtual machines run.
[0030] Specifically, the information of virtual machines in the virtual machine cluster in the customer relationship management system includes: the detailed information of each virtual machine cluster, such as the ID, name, and type of the cluster (e.g., MySQL, Redis cluster, etc.); the configuration information of each virtual machine in the virtual machine cluster, such as the CPU and memory specifications, as well as their current running status and business load, etc. The information of the host machine on which the virtual machine runs includes: the ID of the host machine, the resource usage (such as CPU usage rate, memory usage), the number of virtual machines carried, and the health status of the host machine, etc.
[0031] Step S104, for any virtual machine cluster, determine the anti-affinity mean absolute error of the virtual machine cluster according to the first quantity of virtual machines actually carried by each host machine in the target data, the total quantity of virtual machines, and the second quantity of virtual machines that each host machine is theoretically capable of carrying, where the anti-affinity mean absolute error is used to characterize whether the virtual machines are deployed on different host machines according to the anti-affinity rule.
[0032] The anti-affinity mean absolute error of the virtual machine cluster is a quantitative indicator used to evaluate whether the distribution of virtual machines on host machines follows the anti-affinity principle. Anti-affinity means that in a multi-node environment, specific applications or components are preferably deployed dispersedly on different physical nodes to avoid single-point failures or other local events having an excessive impact on the overall system. Specifically for a virtual machine cluster, anti-affinity means that the virtual machines within the cluster should not be overly concentrated on a few host machines, but should be distributed as evenly as possible among all available host machines. In this way, even if a certain host machine fails, the services of the entire cluster will not be interrupted because the other virtual machines in the cluster can still run normally on other host machines.
[0033] Theoretically, if there are n virtual machines in the cluster and x host machines in the network, then the number of virtual machines that each host machine should carry is the result of rounding down n / x, that is, an ideal distribution array can be obtained. The remainder should be distributed as evenly as possible among the host machines. In this way, most host machines will carry virtual machines, and some host machines will carry virtual machines.
[0034] Collect the number of virtual machines actually hosted on each host to form an array A. Then, calculate the difference (sum of absolute values) between this array and the ideal distribution array, and divide this sum by the number of virtual machines x. The result is the average absolute error of anti-affinity. In step S106, based on the average absolute error of anti-affinity, determine whether the virtual machine cluster meets the anti-affinity index, and determine the anti-affinity adjustment index for each target virtual machine cluster according to the average absolute error of anti-affinity and different preset importance indicators corresponding to different target virtual machine clusters, where the target virtual machine cluster is a virtual machine cluster that does not meet the anti-affinity index.
[0035] In step S106, based on the average absolute error of anti-affinity calculated in step S104, determine whether the virtual machine cluster meets the preset anti-affinity index, and calculate the anti-affinity adjustment index for each target virtual machine cluster in combination with the importance coefficient ∝ of each cluster in the customer relationship management system stored in the information management module.
[0036] Specifically, for different clusters in the customer relationship management system, set different preset importance coefficients ∝ to reflect the impact degree of the cluster on business continuity and system stability. For example, for the MySQL database cluster that directly processes customer orders and bills, its importance coefficient can be set to 0.9; for the Redis cluster that provides caching services, the importance coefficient can be set to 0.7; for the Elasticsearch cluster for log analysis and monitoring, the importance coefficient can be set to 0.5. The setting of these importance coefficients is determined according to the functional positioning and business impact degree of the cluster in the customer relationship management system. For clusters that handle critical businesses, their importance coefficients are higher to ensure that under limited resources, the anti-affinity of these clusters is adjusted first to reduce the risk of business interruption. Multiply the average absolute error of anti-affinity by its corresponding importance coefficient ∝ to obtain the anti-affinity adjustment index of the cluster. This index reflects the priority of cluster adjustment, and the larger the value, the more urgent the adjustment need of the cluster.
[0037] In step S108, schedule the number of virtual machines hosted on the hosts in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
[0038] Specifically, for the cluster with the largest anti-affinity adjustment index, first locate the virtual machine to be migrated. This virtual machine is located on the host with the highest pressure, that is, the host with the largest number of virtual machines and the lowest business processing busyness. Then determine that the virtual machine is migrated to the host with the lowest pressure. The resource utilization rate of this host is lower than that of other hosts and can accommodate more virtual machines in the current environment. By calling the application programming interface or corresponding tools of the cloud management platform, perform the migration operation of the virtual machine, and migrate the selected virtual machine from the host with high load pressure to the host with low load pressure. During the migration process, continuously monitor the status of the host and the virtual machine to ensure that the migration operation will not cause a decline in system performance or business interruption. After completing a virtual machine migration, update the information on the number of virtual machines hosted by the host and the host allocation information of the virtual machine in the configuration management database, and generate a new array of the number of virtual machines hosted by the host. Re-evaluate the anti-affinity status to ensure that the adjustment meets the expectations. If after one adjustment, the anti-affinity evaluation of the target virtual machine cluster still fails, repeat this scheduling process until the anti-affinity indicators of all target clusters reach the preset values.
[0039] According to the above steps, obtain the target data related to the virtual machine in the customer relationship management system. Among them, the customer relationship management system includes multiple virtual machine clusters, and the target data at least includes: the information of the virtual machines in the virtual machine cluster and the information of the hosts on which the virtual machines run; for any virtual machine cluster, according to the first number of virtual machines actually hosted by each host in the target data, the total number of virtual machines, and the second number of virtual machines that each host can theoretically host, determine the anti-affinity mean absolute error of the virtual machine cluster. The anti-affinity mean absolute error is used to characterize whether the virtual machines are deployed on different hosts according to the anti-affinity rules; according to the anti-affinity mean absolute error, determine whether the virtual machine cluster meets the anti-affinity indicators, and according to the anti-affinity mean absolute error and different preset importance indicators corresponding to different target virtual machine clusters, determine the anti-affinity adjustment index of each target virtual machine cluster. The target virtual machine cluster is a virtual machine cluster that does not meet the anti-affinity indicators; by scheduling the number of virtual machines hosted by the hosts in the target virtual machine cluster in descending order of the anti-affinity adjustment index, the purpose of quickly and accurately scheduling the virtual machines that may have affinity hidden dangers is achieved, thus realizing the technical effect of the optimal balanced distribution of virtual machines among hosts.
[0040] The following Figure 1 steps shown are described and explained by way of example.
[0041] According to some alternative embodiments of the present application, the anti-affinity mean absolute error of the virtual machine cluster can be determined based on the first quantity of virtual machines actually hosted by each host in the target data, the total quantity of virtual machines, and the second quantity of virtual machines that each host can theoretically host, and can be achieved through the following steps: Obtain the first quantity of virtual machines actually hosted by each host, obtaining a plurality of first quantities; determine the second quantity of virtual machines that each host can theoretically host according to the total quantity of virtual machines and the total quantity of hosts, obtaining a plurality of second quantities; arrange the plurality of first quantities in descending order to obtain a first array, and arrange the plurality of second quantities in descending order to obtain a second array; determine the anti-affinity mean absolute error of the virtual machine cluster according to the first array and the second array.
[0042] In the above embodiment, first, obtain a list of all hosts in the entire customer relationship management system and the quantity of virtual machines hosted by each of them. Assume that the total number of hosts in the current environment is x, obtain the quantity of virtual machines actually hosted by each host, that is, the first quantity, and arrange the first quantities in descending order to obtain a first array, that is:
[0043] M i =[m i1 ,m i2 ,…,m ix , where m ij ∈{0,1,2,...}, j = 1,2,…,x.
[0044] Obtain the quantity of virtual machines that each host can theoretically host, that is, the second quantity, and arrange the second quantities in descending order to obtain a second array, that is:
[0045] M' i =[m' i1 ,m' i2 ,…,m' ix , where m' ix ∈M' i , i = 1,2,…,x.
[0046] If there are identical values in the first array, that is, the second array, these identical values can be arranged in any order during sorting. Further, according to the first array M i and the second array M' i , the anti-affinity mean absolute error of the virtual machine cluster i can be determined.
[0047] Specifically, according to the first array and the second array, the average absolute error of the anti-affinity of the virtual machine cluster can be determined through the following steps: Calculate the difference between the elements at the same position in the first array and the second array to obtain multiple differences; Calculate the absolute value of each difference to obtain multiple absolute errors, and add up the multiple absolute errors to obtain the total error; Calculate the target ratio between the total error and the number of virtual machines, and determine the target ratio as the average absolute error of the anti-affinity.
[0048] In the above embodiment, based on the first array (i.e., the sorted array of the actual number of virtual machines hosted by the host) and the second array (i.e., the sorted array of the theoretical number of virtual machines hosted), calculate the difference between the elements at the same position in the two. Then convert the obtained difference into an absolute value to ensure that the calculation of the error is not affected by the positive or negative of the elements. Add up all the absolute errors to obtain the total error e total . That is: where x is the total number of hosts.
[0049] Finally, divide the total error e total by the total number of virtual machines v i to calculate the ratio, and use the obtained ratio as the average absolute error of the anti-affinity:
[0050]
[0051] If e i = 0, the anti-affinity evaluation of the virtual machines in this cluster passes, otherwise it fails.
[0052] It should be noted that the above calculation process assumes an ideal state where the hosting pressure of the hosts is evenly distributed. However, in actual operation, considering factors such as resource limitations and changes in business load, the theoretical hosting quantity of the second array can be dynamically adjusted to be closer to the actual resource allocation strategy.
[0053] Through the above steps, the current anti-affinity status of each virtual machine cluster can be accurately quantified and evaluated, providing a data basis for further optimization and adjustment. This method takes into account the balance of resource distribution and the anti-affinity requirements between cluster instances, and can effectively help the operation and maintenance personnel identify the clusters that need to be adjusted, and more precisely guide how to adjust through the calculated average absolute error of the anti-affinity to achieve the best system stability and resource utilization efficiency.
[0054] Specifically, according to the total number of virtual machines and the total number of host machines, the second number of virtual machines that each host machine theoretically bears can be determined through the following steps: Divide the total number of virtual machines by the total number of host machines to obtain a first calculation result, where the first calculation result includes: a quotient and a remainder; in the case where the remainder is zero, determine the quotient as the second number of virtual machines that each host machine theoretically bears; in the case where the remainder is not zero, determine that r host machines bear (a + 1) virtual machines, and determine that (x - r) host machines bear a virtual machines, where r is the remainder, a is the quotient, and x is the total number of host machines, and x is a positive integer greater than 1.
[0055] In the above embodiment, first, divide the total number M of virtual machines by the total number x of host machines to obtain a first calculation result, which includes a quotient a and a remainder r. In the case where the remainder r is zero, all virtual machines can be evenly distributed to each host machine. At this time, determine the quotient a as the number of virtual machines that each host machine theoretically bears, that is, each host machine should bear a virtual machines to maintain the uniform distribution of resources and the high-availability state of the cluster. In the case where the remainder r is not zero, that is, there are r host machines that need to bear one more unit of virtual machines than other host machines. The allocation scheme at this time is: select r host machines to bear (a + 1) virtual machines, which means distributing these r remainder units of virtual machines to the host machines with higher resource utilization efficiency to avoid resource waste. The remaining (x - r) host machines bear a virtual machines, that is, on the premise of ensuring the high availability of the core cluster, maintain the resource bearing balance between host machines as much as possible and reduce the impact on the cluster caused by host machine failures.
[0056] Preferably, the second number of virtual machines that each host machine theoretically bears can also be determined in the following way:
[0057] Calculate the average value of the number of virtual machines that each host machine should theoretically bear when the total number of host machines is x and round down:
[0058]
[0059] After each host machine bears avg i virtual machines, the number of remaining virtual machines in cluster i is:
[0060] r i = v i mod x
[0061] If r i = 0, then the virtual machines can be evenly distributed to the host machines, and each host machine bears avg i virtual machines; otherwise, r i host machines each bear one more virtual machine, that is, ri One host machine hosts (avg i +1) virtual machines, and (x - r i ) host machines host avg i virtual machines. Record this optimal allocation result as the second array M'. i .
[0062] For the second array M' i , it is represented as: M' i = [m' i1 , m' i2 ,..., m' ix , where the values of the first r i elements are (avg i + 1), and the values of the last (x - r i ) elements are avg i .
[0063] Through the above specific implementation manners, the number of virtual machines that each host machine should carry theoretically can be calculated in detail, providing basic data for subsequent anti-affinity evaluation and virtual machine scheduling strategies, and ensuring that the distribution of virtual machines on host machines is as balanced as possible under the condition of limited resources.
[0064] As some alternative embodiments of the present application, after arranging multiple said first quantities in descending order to obtain a first array, and arranging multiple said second quantities in descending order to obtain a second array, the following steps can further be performed: In the first array and the second array, determine the identification information of different host machines as the index information of elements at different positions.
[0065] In the above embodiment, first, obtain the identification information of all host machines, such as host names, IP addresses, or unique IDs, and create a list of host machine identification information. Then, associate the host machine identification information with the host machine load quantity. Specifically, when forming the first array and the second array, record the actual load quantity and the theoretical load quantity of the corresponding host machines respectively. As the arrays are sorted, ensure that the elements in the identification information H of each host machine correspond one-to-one with the position elements in the first array and the second array. For example, the first element of the sorted first array represents the host machine with the largest number of virtual machines carried, and its index position should match the identification information of the host machine with the largest number of virtual machines carried in the list H of host machine identification information.
[0066] Next, generate an index array I, where each element of the array I is the identification information of a host machine, and its position corresponds to the positions of the elements in the first array and the second array. This means that the identification information of the first element in the array I corresponds to the first elements in the first array and the second array, and so on.
[0067] For example, assume there are a total of 5 host machines, and the list of identification information is (H = [Host1, Host2, Host3, Host4, Host5]). After sorting, the first array is [12, 10, 8, 3, 2], and the second array after sorting is [8, 8, 8, 8, 8] (assuming a completely even distribution at this time, that is, each host machine should theoretically carry 8 virtual machines).
[0068] Based on the above arrays, an index array I is generated. First, identify the host machine with the largest number of virtual machines, that is, the host machine carrying 12 virtual machines, and its identification information is Host1. Then, the first element of the index array I is Host1. Next, identify the host machine carrying 10 virtual machines, assume it is Host2, then the second element of I is Host2, and so on, until all host machines are located and recorded in the index array.
[0069] Through the above implementation manners, the present application not only realizes the comparison between the theory and the actual situation of the number of virtual machines carried by the host machine, but also associates the identification information of the host machine with the element positions in the sorted array, so that when the adjustment execution module makes a virtual machine migration decision, it can accurately and quickly locate the host machine, thereby ensuring the efficient implementation of the anti-affinity adjustment strategy.
[0070] Preferably, the indexes corresponding to the elements in the first array and the second array can also be determined through the following index array, where the index array can be expressed as: S i = [s i1 , s i2 ,..., s ix , where s ij is the position of ms ij in the original array M i , that is, according to s ij , it can be known which host machine ms ij corresponds to.
[0071] Furthermore, scheduling the number of virtual machines hosted by the physical hosts in the target virtual machine cluster in the order of decreasing anti-affinity adjustment index can be achieved through the following steps: In the first array corresponding to the target virtual machine cluster, determine one or more first elements with the largest element values and one or more second elements with the smallest element values; According to the index information of the one or more first elements, determine one or more first physical hosts corresponding to the one or more first elements respectively, and according to the index information of the one or more second elements, determine one or more second physical hosts corresponding to the one or more second elements respectively; When there are multiple first physical hosts, obtain the first metric of each first physical host, and determine the first target physical host with the smallest first metric among the multiple first physical hosts, where the first metric is used to represent the busy degree of the physical host during business processing, and the first metric is proportional to the busy degree; When there are multiple second physical hosts, obtain the second metric of each second physical host, and determine the second target physical host with the largest second metric among the multiple second physical hosts, where the second metric is used to represent the running pressure of the physical host during business processing, and the second metric is proportional to the running pressure; Schedule some of the virtual machines hosted by the first target physical host to the second target physical host.
[0072] In the above embodiment, first obtain two sorted arrays for the target virtual machine cluster: The first array represents the sorting of the actual number of virtual machines hosted by the physical hosts from largest to smallest; The second array represents the sorting of the theoretically should-be number of virtual machines hosted by the physical hosts from largest to smallest.
[0073] Then, in the first array, determine one or more first elements with the largest element values, and these elements represent the physical hosts that host the largest number of virtual machines. In the second array, determine one or more second elements with the smallest element values, and these elements represent the physical hosts that theoretically host the smallest number of virtual machines.
[0074] Next, use the index information H of the first and second physical hosts determined in the above steps, and through the index array I, determine the identification information of these physical hosts, where each position in the index array corresponds to the unique identification of the physical host, such as the host name, ID, etc. For the determined multiple first physical hosts, obtain the first metric of each physical host, that is, the business processing busy degree metric.
[0075] The business processing busy degree metric can be CPU utilization rate, memory usage rate, task queue length, etc., and is used to measure the busy degree of the physical host during business processing. Similarly, for the determined multiple second physical hosts, obtain the second metric of each physical host, that is, the business processing running pressure metric. The business processing running pressure metric includes but is not limited to network bandwidth usage, disk I / O load, or the health status score of the physical host, etc., and is used to evaluate the running pressure of the physical host during business processing.
[0076] In the case where there are multiple first hosts, select the first target host with the smallest first metric, that is, select a host with relatively less busy business processing from the hosts with the greatest load pressure as the source host for migration. In the case where there are multiple second hosts, select the second target host with the largest second metric, that is, select a host with the lowest operating pressure from the hosts with the lowest theoretical load pressure as the destination host for migration.
[0077] Finally, schedule some virtual machines on the determined first target host to the second target host to achieve the purpose of balanced resource allocation and anti-affinity adjustment. The number of scheduled virtual machines and which specific virtual machines will be based on the anti-affinity status of the cluster and the current resource status of the host to make a decision, ensuring that the adjusted state is closer to the theoretical optimal state.
[0078] Preferably, the number of virtual machines carried by the hosts in the target virtual machine cluster can also be scheduled by the following method:
[0079] Locate the virtual machine to be migrated, and take out the maximum value element in MS i Assume that the first element in MS i is the maximum value. If the values of the second and third elements are the same as the maximum value, take them out as well. Then query the array S i to obtain the positions of these elements in the original array M i , that is, obtain the corresponding several hosts.
[0080] Obtain the virtual machines of cluster i carried on these several hosts, and obtain the business processing busy degree of these virtual machines. Locate a virtual machine with the lowest business processing busy degree to perform migration, thereby minimizing the impact of virtual machine migration on the business system.
[0081] Locate to which host the virtual machine is to be migrated, and take out the minimum value element in MS i Assume that the last element in MS i is the minimum value. If the values of the second last and third last elements are the same as the minimum value, take them out as well, and query the array S i to obtain the positions of these elements in the original array M i , that is, obtain the corresponding several hosts. Obtain the pressure of these several hosts, and locate a host with the lowest pressure as the destination for virtual machine migration, thereby balancing the pressure of each host to the greatest extent.
[0082] After completing the migration of one virtual machine, regenerate the array M i of the number of virtual machines carried by each host, and perform anti-affinity evaluation of the virtual machine cluster. During the evaluation process, generate the latest MSi and S i If the evaluation passes, the adjustment is complete. Otherwise, this step is repeated until cluster i passes the anti-affinity evaluation. Through the above steps, virtual machines can be intelligently identified and scheduled to optimize the anti-affinity of the virtual machine cluster, while ensuring business processing continuity and balanced utilization of host resources, improving the overall stability and efficiency of the system. For example, the first and second indicators can be calculated using real-time monitoring data, ensuring that scheduling decisions are based on the latest system status, thereby more accurately responding to dynamic changes in resource demand.
[0083] As other optional embodiments of the present application, after scheduling the number of virtual machines carried by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index, it can also be implemented through the following steps: determining the anti-affinity mean absolute error of each virtual machine cluster; determining whether the virtual machine cluster meets the anti-affinity index based on the anti-affinity mean absolute error; for the target virtual machine cluster that does not meet the anti-affinity index, repeating the following steps until all virtual machine clusters in the customer relationship management system meet the anti-affinity index: scheduling the number of virtual machines carried by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
[0084] In the above embodiment, the mean absolute error of anti-affinity is first calculated for each virtual machine cluster in the customer relationship management system. This can be achieved by constructing a first array based on the actual number of virtual machines supported and a second array based on the theoretical number of virtual machines supported. Then, based on the anti-affinity mean absolute error, it is determined whether the virtual machine cluster meets the anti-affinity indicator.
[0085] For all target virtual machine clusters that do not meet the anti-affinity indicators, they are sorted according to their anti-affinity adjustment index to form an adjustment priority list. Specifically, clusters with high adjustment indexes are given priority for adjustment to quickly optimize the anti-affinity status of the core business cluster. For each target virtual machine cluster in the adjustment list, scheduling adjustments are performed one by one in descending order of anti-affinity adjustment index. The scheduling strategy includes: identifying the host machines carrying the largest number of virtual machines and selecting the virtual machines with the lowest business processing busyness from these host machines for migration; at the same time, identifying the host machines carrying the least number of virtual machines and selecting the host machines with the least pressure as the migration target to balance resource allocation and pressure between hosts.
[0086] It should be noted that the above scheduling process continues until all target virtual machine clusters meet the anti-affinity metrics. Specifically, after adjusting a target virtual machine cluster, the mean absolute error of anti-affinity is recalculated to evaluate whether the anti-affinity metrics are met. The above scheduling steps are repeatedly executed for all virtual machine clusters that do not meet the anti-affinity metrics until all virtual machine clusters in the customer relationship management system reach the requirements of the anti-affinity metrics, ensuring the stability and high availability of the system.
[0087] Through the above specific implementation steps, it is possible to effectively identify and adjust the anti-affinity status of virtual machine clusters in the customer relationship management system, ensure the optimal cluster distribution under limited resources, reduce the impact of host failures on services, and improve the overall operation and maintenance efficiency and customer satisfaction.
[0088] Figure 2 is a schematic architecture diagram of a virtual machine scheduling system according to an embodiment of the present application, as Figure 2 shown, the system includes: a CMDB system, a client, a target device, and each virtual machine cluster under the CRM system. Among them,
[0089] The CMDB system is a data system for storing the association relationships between various resource instances (including clusters, virtual machines, and hosts) under the CRM system, and is the data source of this embodiment.
[0090] Client: The interface for operation and maintenance personnel or automated operation and maintenance scripts. Through the client, users can request anti-affinity adjustment or obtain adjustment results.
[0091] The virtual machine scheduling method is deployed in the target device, which includes: an information management module, a detection and evaluation module, a priority scheduling module, a monitoring docking module, and an adjustment execution module. Among them,
[0092] The information management module is used to obtain resource information from the CMDB system and store the importance coefficient of the cluster.
[0093] The detection and evaluation module is used to evaluate the anti-affinity status of the virtual machine based on the collected information and calculate key metrics such as the mean absolute error.
[0094] The priority scheduling module is used to calculate the anti-affinity adjustment index according to the evaluation results and the importance of the cluster, and sort them by priority.
[0095] The monitoring docking module is used to dock with the monitoring system to obtain the real-time running status of the host and virtual machine, such as the busy degree and running pressure.
[0096] The adjustment execution module is used to automatically or semi-automatically perform virtual machine migration based on the priority and resource status to optimize the anti-affinity.
[0097] The virtual machine clusters under the CRM system include: Mysql, Redis, etc.
[0098] Figure 3 This is a flowchart of another virtual machine scheduling method according to an embodiment of the present application, which can be applied to Figure 2 The system shown, Figure 3 As shown, the method includes the following processes:
[0099] In step S301, the information management module connects to the CMDB system to obtain the relationship data between each cluster virtual machine and the host machine, and stores the cluster importance coefficient ∝.
[0100] The information management module communicates with the CMDB system through API calls or other data interfaces to obtain information stored in the CMDB regarding virtual machine clusters, the virtual machines within the clusters, and the hosts on which the virtual machines run. After receiving data returned by the CMDB system, the information management module parses the data, extracting the specific host information for each virtual machine and the importance coefficient assigned to each cluster based on business importance. This coefficient, which can be set manually or automatically generated through an algorithm, is used to measure the business impact of a cluster failure. The processed data, including the virtual machine-host mapping relationship and the cluster importance coefficient, is persistently stored in the information management module's internal data storage structure, providing real-time data support for subsequent evaluation and adjustments.
[0101] Step S302: The detection and evaluation module evaluates whether each cluster virtual machine meets anti-affinity.
[0102] The detection and evaluation module reads the relationship data between each cluster virtual machine and the host machine, as well as the cluster's important coefficients, from the information management module. Based on the data provided by the CMDB system, the number of virtual machines actually carried by each host machine is calculated, and compared with the theoretical number of virtual machines that each host machine should carry, and the mean absolute error of anti-affinity is calculated. If the calculated mean absolute error of anti-affinity is equal to 0, then the cluster meets the anti-affinity requirements; if it is not equal to 0, it is considered that there is an affinity risk and the requirements are not met. In step S303, the priority ranking module analyzes the anti-affinity adjustment index of the cluster virtual machines and sorts them.
[0103] The prioritization module calculates an anti-affinity adjustment index for each cluster based on the anti-affinity mean absolute error calculated in step S302 and the cluster importance coefficient obtained in step S301. After calculating the anti-affinity adjustment index values for all clusters, the prioritization module sorts the clusters from high to low based on their anti-affinity adjustment index values. A higher anti-affinity adjustment index value indicates a higher anti-affinity adjustment priority for that cluster.
[0104] Step S304: The adjustment execution module preferentially adjusts clusters with high anti-affinity adjustment indexes.
[0105] Based on the sorting results, the adjustment execution module prioritizes the cluster with the highest anti-affinity adjustment index value to start the adjustment. Strategically, the virtual machine that needs to be migrated is first determined. Usually, the virtual machine with the lowest business processing busyness is selected to minimize the impact of the migration on the business. After selecting the virtual machine to be migrated, find the host machine with the least pressure as the migration target. The adjustment execution module executes the virtual machine migration and re-evaluates the anti-affinity of the cluster after the migration. If the evaluation result still does not meet the standard, the migration is repeated until the cluster meets the anti-affinity requirements. For the migration process, it should be ensured that the interference with the CRM system and its dependent services is minimized. After completing the adjustment of a cluster, the adjustment execution module will continue to adjust the cluster with the next highest priority according to the sorting until all clusters that do not meet the anti-affinity requirements are adjusted to meet the requirements.
[0106] Figure 4 is a structural diagram of a virtual machine scheduling device according to an embodiment of the present application, such as Figure 4 As shown, the device includes:
[0107] The acquisition module 40 is used to acquire target data related to virtual machines in the customer relationship management system, wherein the customer relationship management system includes multiple virtual machine clusters, and the target data at least includes: information about the virtual machines in the virtual machine cluster and information about the host machine on which the virtual machines run.
[0108] The first determination module 42 is used to determine, for any virtual machine cluster, the anti-affinity mean absolute error of the virtual machine cluster based on the first number of virtual machines actually carried by each host machine and the total number of virtual machines in the target data, and the second number of virtual machines theoretically carried by each host machine, wherein the anti-affinity mean absolute error is used to indicate whether the virtual machines are deployed on different host machines according to the anti-affinity rules.
[0109] The second determination module 44 is configured to determine whether the virtual machine cluster satisfies the anti-affinity index based on the anti-affinity mean absolute error, and to determine the anti-affinity adjustment index of each target virtual machine cluster based on the anti-affinity mean absolute error and different preset importance indicators corresponding to different target virtual machine clusters, wherein the target virtual machine cluster is a virtual machine cluster that does not satisfy the anti-affinity index.
[0110] The scheduling module 46 is configured to schedule the number of virtual machines carried by the host machines in the target virtual machine cluster according to the order of the anti-affinity adjustment index from large to small.
[0111] Optionally, the first determination module 42 is also used to perform the following steps: obtain a first number of virtual machines actually carried by each host machine to obtain multiple first numbers; determine a second number of virtual machines theoretically carried by each host machine based on the total number of virtual machines and the total number of host machines to obtain multiple second numbers; arrange the multiple first numbers in order from large to small to obtain a first array, and arrange the multiple second numbers in order from large to small to obtain a second array; determine the mean absolute error of anti-affinity of the virtual machine cluster based on the first array and the second array.
[0112] Optionally, the first determination module 42 is further used to perform the following steps: calculating the difference between the elements at the same position in the first array and the second array to obtain multiple differences; calculating the absolute value of each difference to obtain multiple absolute errors, and adding the multiple absolute errors to obtain a total error; calculating a target ratio between the total error and the number of virtual machines, and determining the target ratio as the anti-affinity mean absolute error.
[0113] Optionally, the first determination module 42 is also used to perform the following steps: divide the total number of virtual machines by the total number of host machines to obtain a first calculation result, wherein the first calculation result includes: a quotient and a remainder; when the remainder is zero, determine the quotient as the second number of virtual machines that each host machine can theoretically carry; when the remainder is not zero, determine to use r host machines to carry (a+1) virtual machines, and determine to use (xr) host machines to carry a virtual machines, wherein r is the remainder, a is the quotient, x is the total number of host machines, and x is a positive integer greater than 1.
[0114] Optionally, the first determination module 42 is also used to perform the following steps: divide the total number of virtual machines by the total number of host machines to obtain a first calculation result, wherein the first calculation result includes: a quotient and a remainder; when the remainder is zero, determine the quotient as the second number of virtual machines that each host machine can theoretically carry; when the remainder is not zero, determine to use r host machines to carry (a+1) virtual machines, and determine to use (xr) host machines to carry a virtual machines, wherein r is the remainder, a is the quotient, x is the total number of host machines, and x is a positive integer greater than 1.
[0115] Optionally, the scheduling module 46 is also used to perform the following steps: in the first array corresponding to the target virtual machine cluster, determine one or more first elements with the largest element value, and determine one or more second elements with the smallest element value; determine one or more first host machines corresponding to the one or more first elements respectively based on the index information of the one or more first elements, and determine one or more second host machines corresponding to the one or more second elements respectively based on the index information of the one or more second elements; in the case where there are multiple first host machines, obtain the first indicator of each first host machine, and determine the first target host machine with the smallest first indicator among the multiple first host machines, wherein the first indicator is used to characterize the busyness of the host machine during business processing, and the first indicator is proportional to the busyness; in the case where there are multiple second host machines, obtain the second indicator of each second host machine, and determine the second target host machine with the largest second indicator among the multiple second host machines, wherein the second indicator is used to characterize the operating pressure of the host machine during business processing, and the second indicator is proportional to the operating pressure; schedule some of the virtual machines carried by the first target host machine to the second target host machine.
[0116] Optionally, after scheduling the number of virtual machines carried by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index, the virtual machine scheduling device is further used to perform the following steps: determining the anti-affinity mean absolute error of each virtual machine cluster; determining whether the virtual machine cluster meets the anti-affinity index based on the anti-affinity mean absolute error; for the target virtual machine cluster that does not meet the anti-affinity index, repeatedly performing the following steps until all virtual machine clusters in the customer relationship management system meet the anti-affinity index: scheduling the number of virtual machines carried by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
[0117] It should be noted that the above Figure 4 Each module in the embodiment can be a program module (for example, a set of program instructions that implement a specific function) or a hardware module. For the latter, it can be expressed in the following forms, but is not limited to this: each of the above modules is expressed in the form of a processor, or the functions of each of the above modules are implemented by a processor.
[0118] It should be noted that Figure 4 The preferred implementation of the embodiment shown can be found in Figure 1 The relevant description of the illustrated embodiment will not be repeated here.
[0119] Figure 5 FIG1 shows a hardware structure block diagram of a computer terminal for implementing a virtual machine scheduling method. Figure 5As shown, the computer terminal 50 may include one or more processors 502 (shown as 502a, 502b, ……, 502n in the figure) (the processor 502 may include, but is not limited to, a processing device such as a microprocessor MCU or a field-programmable gate array FPGA), a memory 504 for storing data, and a transmission module 506 for communication functions. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 5 the structure shown is only schematic and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 50 may further include more or fewer components than Figure 5 shown in the figure, or have a different configuration from Figure 5 that shown in the figure.
[0120] It should be noted that the above one or more processors 502 and / or other data processing circuits are generally referred to as "data processing circuits" in this article. The data processing circuit may be embodied in whole or in part as software, hardware, firmware, or any combination thereof. In addition, the data processing circuit may be a single independent processing module, or be incorporated in whole or in part into any one of the other elements in the computer terminal 50. As involved in the embodiments of the present application, the data processing circuit is a kind of processor control (such as the selection of a variable resistor terminal path connected to an interface).
[0121] The memory 504 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the virtual machine scheduling method in the embodiments of the present application. The processor 502 executes various functional applications and data processing by running the software programs and modules stored in the memory 504, that is, implements the above-mentioned virtual machine scheduling method. The memory 504 may include a high-speed random access memory, and may further include a non-volatile memory, such as one or more magnetic storage devices, a flash memory, or other non-volatile solid-state memories. In some instances, the memory 504 may further include a memory remotely set relative to the processor 502, and these remote memories may be connected to the computer terminal 50 through a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0122] The transmission module 506 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of the computer terminal 50. In one embodiment, the transmission module 506 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission module 506 may be a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0123] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 50 .
[0124] It should be noted that, in some optional embodiments, the above Figure 5 The computer terminal shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of hardware elements and software elements. Figure 5 This is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the computer terminal described above.
[0125] It should be noted that Figure 5 The computer terminal shown is used to execute Figure 1 The virtual machine scheduling method shown, therefore the relevant explanations in the execution method of the above command are also applicable to the electronic device and will not be repeated here.
[0126] An embodiment of the present application further provides a non-volatile storage medium, which includes a stored program, wherein when the program runs, the device where the storage medium is located is controlled to execute the above virtual machine scheduling method.
[0127] A program for a non-volatile storage medium that performs the following functions: obtaining target data related to virtual machines in a customer relationship management system, wherein the customer relationship management system includes multiple virtual machine clusters, and the target data includes at least information about virtual machines in the virtual machine cluster and information about hosts on which the virtual machines run; determining, for any virtual machine cluster, an anti-affinity mean absolute error for the virtual machine cluster based on a first number of virtual machines actually hosted by each host and a total number of virtual machines, and a second number of virtual machines theoretically hosted by each host in the target data, wherein the anti-affinity mean absolute error is used to indicate whether virtual machines are deployed on different hosts in accordance with anti-affinity rules; determining whether the virtual machine cluster meets an anti-affinity index based on the anti-affinity mean absolute error, and determining an anti-affinity adjustment index for each target virtual machine cluster based on the anti-affinity mean absolute error and different preset importance indicators corresponding to different target virtual machine clusters, wherein the target virtual machine cluster is a virtual machine cluster that does not meet the anti-affinity index; and scheduling the number of virtual machines hosted by the hosts in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
[0128] An embodiment of the present application further provides an electronic device, comprising: a memory and a processor, wherein the processor is configured to run a program stored in the memory, wherein the above virtual machine scheduling method is executed when the program is running.
[0129] The processor is configured to run a program that performs the following functions: obtaining target data related to virtual machines in a customer relationship management system, wherein the customer relationship management system includes multiple virtual machine clusters, and the target data includes at least information about virtual machines in the virtual machine cluster and information about hosts on which the virtual machines run; determining, for any virtual machine cluster, an anti-affinity mean absolute error for the virtual machine cluster based on a first number of virtual machines actually hosted by each host and a total number of virtual machines, and a second number of virtual machines theoretically hosted by each host in the target data, wherein the anti-affinity mean absolute error is used to indicate whether virtual machines are deployed on different hosts in accordance with anti-affinity rules; determining, based on the anti-affinity mean absolute error, whether the virtual machine cluster meets an anti-affinity index, and determining an anti-affinity adjustment index for each target virtual machine cluster based on the anti-affinity mean absolute error and different preset importance indicators corresponding to different target virtual machine clusters, wherein the target virtual machine cluster is a virtual machine cluster that does not meet the anti-affinity index; and scheduling the number of virtual machines hosted by the hosts in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
[0130] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0131] In the above embodiments of the present application, the descriptions of the respective embodiments have their own focuses. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0132] In the above embodiments of the present application, the information collected is information and data authorized by the user or fully authorized by all parties. Moreover, for the processing of the relevant data, such as collection, storage, use, processing, transmission, provision, disclosure, and application, etc., all comply with relevant laws, regulations, and standards, necessary protection measures are taken, it does not violate public order and good customs, and a corresponding operation entry is provided for the user to choose to authorize or refuse.
[0133] In several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the units or modules can be in electrical or other forms.
[0134] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0135] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0136] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0137] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A virtual machine scheduling method, characterized in that, Including: Obtain target data related to virtual machines in a customer relationship management system, where the customer relationship management system includes multiple virtual machine clusters, and the target data at least includes: information of virtual machines in the virtual machine cluster and information of the host machines on which the virtual machines run; For any virtual machine cluster, determine the anti-affinity mean absolute error of the virtual machine cluster according to the first quantity of virtual machines actually carried by each host machine in the target data, the total quantity of virtual machines, and the second quantity of virtual machines that each host machine is theoretically capable of carrying, where the anti-affinity mean absolute error is used to characterize whether virtual machines are deployed on different host machines according to the anti-affinity rule; According to the anti-affinity mean absolute error, determine whether the virtual machine cluster meets the anti-affinity index, and determine the anti-affinity adjustment index of each target virtual machine cluster according to the anti-affinity mean absolute error and different preset importance indexes corresponding to different target virtual machine clusters, where the target virtual machine cluster is a virtual machine cluster that does not meet the anti-affinity index; Schedule the quantity of virtual machines carried by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
2. The method according to claim 1, wherein Determine the anti-affinity mean absolute error of the virtual machine cluster according to the first quantity of virtual machines actually carried by each host machine in the target data, the total quantity of virtual machines, and the second quantity of virtual machines that each host machine is theoretically capable of carrying, including: Obtain the first quantity of virtual machines actually carried by each host machine, obtaining multiple first quantities; According to the total quantity of virtual machines and the total quantity of host machines, determine the second quantity of virtual machines that each host machine is theoretically capable of carrying, obtaining multiple second quantities; Arrange the multiple first quantities in descending order to obtain a first array, and arrange the multiple second quantities in descending order to obtain a second array; Determine the anti-affinity mean absolute error of the virtual machine cluster according to the first array and the second array.
3. The method according to claim 2, wherein Determine the anti-affinity mean absolute error of the virtual machine cluster according to the first array and the second array, including: Calculate the difference between the elements at the same position in the first array and the second array, obtaining multiple differences; Calculate the absolute value of each difference, obtaining multiple absolute errors, and add the multiple absolute errors to obtain a total error; Calculate the target ratio between the total error and the quantity of virtual machines, and determine the target ratio as the anti-affinity mean absolute error.
4. The method according to claim 2, wherein According to the total quantity of virtual machines and the total quantity of host machines, determine the second quantity of virtual machines that each host machine is theoretically capable of carrying, including: Divide the total quantity of virtual machines by the total quantity of host machines to obtain a first calculation result, where the first calculation result includes: a quotient and a remainder; In the case where the remainder is zero, determine the quotient as the second quantity of virtual machines that each host machine is theoretically capable of carrying; In the case where the remainder is not zero, determine to use r host machines to host (a + 1) virtual machines, and determine to use (x - r) host machines to host a virtual machines, where r is the remainder and a is the quotient, x is the total number of the host machines, and x is a positive integer greater than 1.
5. The method according to claim 2, characterized in that, After arranging multiple said first quantities in descending order to obtain a first array, and arranging multiple said second quantities in descending order to obtain a second array, the method further includes: In the first array and the second array, determine the identification information of different host machines as the index information of elements at different positions.
6. The method according to claim 5, characterized in that, Schedule the number of virtual machines hosted by the host machines in the target virtual machine cluster in the order from largest to smallest of the anti-affinity adjustment index, including: In the first array corresponding to the target virtual machine cluster, determine one or more first elements with the largest element values, and determine one or more second elements with the smallest element values; According to the index information of one or more said first elements, determine one or more first host machines corresponding to one or more said first elements respectively, and according to the index information of one or more said second elements, determine one or more second host machines corresponding to one or more said second elements respectively; In the case where there are multiple first host machines, obtain the first index of each said first host machine, and determine the first target host machine with the smallest first index among multiple said first host machines, where the first index is used to represent the busy degree of the host machine during business processing, and the first index is proportional to the busy degree; In the case where there are multiple second host machines, obtain the second index of each said second host machine, and determine the second target host machine with the largest second index among multiple said second host machines, where the second index is used to represent the operating pressure of the host machine during business processing, and the second index is proportional to the operating pressure; Schedule some of the virtual machines hosted by the first target host machine to the second target host machine.
7. The method according to claim 1, characterized in that After scheduling the number of virtual machines hosted by the host machines in the target virtual machine cluster in the order from largest to smallest of the anti-affinity adjustment index, the method further includes: Determine the anti-affinity mean absolute error of each said virtual machine cluster; According to the anti-affinity mean absolute error, determine whether the virtual machine cluster meets the anti-affinity index; For the target virtual machine cluster that does not meet the anti-affinity index, repeat the following steps until all the virtual machine clusters in the customer relationship management system meet the anti-affinity index: Schedule the number of virtual machines hosted by the host machines in the target virtual machine cluster in the order from largest to smallest of the anti-affinity adjustment index.
8. A virtual machine scheduling device, characterized in that, Including: An acquisition module, configured to acquire target data related to virtual machines in a customer relationship management system, where the customer relationship management system includes multiple virtual machine clusters, and the target data at least includes: information of virtual machines in the virtual machine cluster and information of the host machines on which the virtual machines run; A first determination module, configured to, for any virtual machine cluster, determine the anti-affinity mean absolute error of the virtual machine cluster according to the first quantity of virtual machines actually carried by each host machine in the target data, the total quantity of virtual machines, and the second quantity of virtual machines that each host machine is theoretically capable of carrying, where the anti-affinity mean absolute error is used to characterize whether virtual machines are deployed on different host machines according to the anti-affinity rule; A second determination module, configured to determine whether the virtual machine cluster meets the anti-affinity index according to the anti-affinity mean absolute error, and determine the anti-affinity adjustment index of each target virtual machine cluster according to the anti-affinity mean absolute error and different preset importance indexes corresponding to different target virtual machine clusters, where the target virtual machine cluster is a virtual machine cluster that does not meet the anti-affinity index; A scheduling module, configured to schedule the quantity of virtual machines carried by the host machines in the target virtual machine cluster in descending order of the anti-affinity adjustment index.
9. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored program, where when the program runs, it controls the device where the non-volatile storage medium is located to execute the virtual machine scheduling method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, Comprising: A memory and a processor, the processor is configured to run the program stored in the memory, where when the program runs, it executes the virtual machine scheduling method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the virtual machine scheduling method according to any one of claims 1 to 7.