A load balancing method based on improved genetic algorithm
Through the combination of improved genetic algorithms and the MIN-Min algorithm, the problem of imbalanced load and local optimal solution in the cluster achieves the effect of shortest task processing and load balancing.
Patent Information
- Application Number
- CN202411572322.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-11-06
AI Technical Summary
In the prior art, Min-Min algorithms consider few factors and cannot ensure the load balancing of network resources. Genetic algorithms are prone to fall into local minimum values and it is difficult to obtain an overall optimal solution.
Adopting improved genetic algorithms, combined with the MIN-Min algorithm, through regular collection of load indicators of cluster nodes, the weight of the load index is calculated using the hierarchical analysis method to construct the functional value of the adaptation to ensure the load balancing and the global optimal solution.
The shortest production scheduling problem with the shortest total task processing is realized. The generated load distribution scheme can effectively balance the load of cluster nodes and improve the computing speed and reliability of the system.
Smart Images

Figure CN119088572B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of cluster servers, and in particular relates to a load balancing method based on an improved genetic algorithm. Background Art
[0002] The emergence of clusters allows people to complete large-scale scientific computing with cheap computing resources, improving the computing speed and reliability of the system. Clusters have great potential in parallel computing and distributed computing, and task scheduling is the key technology to tap this potential.
[0003] In previous studies, many task scheduling algorithms have been produced, such as Min-Min algorithm, Max-Min algorithm, genetic algorithm, simulated annealing algorithm and so on.
[0004] Among them, Min-Min is one of the classic algorithms in heuristic algorithms. It is simple and easy to implement, and has a good time span. The Min-Min algorithm always executes the job with the shortest completion time first. It has the characteristics of simple algorithm ideas and short total completion time.
[0005] However, this algorithm takes fewer factors into consideration and cannot ensure load balancing of network resources.
[0006] Genetic algorithm is also a well-known meta-heuristic algorithm that simulates the principles of evolution and inheritance. Genetic algorithm searches for the optimal solution from the global solution space and usually obtains a better solution;
[0007] However, the legacy algorithm is prone to fall into the dilemma of only being able to obtain local minima, making it difficult to obtain the overall optimal solution. Summary of the invention
[0008] In order to solve the problems raised in the above background technology, the present invention provides a method for load balancing based on an improved genetic algorithm to solve the problem that the Min-Min algorithm considers fewer factors and cannot ensure the load balancing of network resources, and the genetic algorithm is prone to fall into the dilemma of only being able to obtain local minimum values, making it difficult to obtain the overall optimal solution.
[0009] To achieve the above object, the present invention provides the following technical solutions:
[0010] A load balancing method based on an improved genetic algorithm comprises the following steps:
[0011] S1: regularly collect the load indicators of each edge node in the appropriate load queue in the cluster according to the preset time period, and move the edge nodes whose load indicators exceed the preset cross-boundary threshold into the heavy load queue;
[0012] S2: According to the genetic algorithm, based on the load-appropriate queue, the problem to be solved is encoded, that is, each task request allocation scheme is encoded as an individual of a chromosome structure;
[0013] S3: Confirm the population size ksize, the number of stop iterations Tm, the crossover probability Pc, the mutation probability Pm, the selection probability Ps of each individual and the fitness function value f of each individual;
[0014] S4: According to the Min-Min algorithm, select ksize solutions as the initial population P0, P0={P1…P ksize}, take the initial population P0 as the current population and proceed to the next step;
[0015] S5: Perform weight analysis on the load index of the current group through the hierarchical analysis method, and further calculate and evaluate the fitness function value f of each individual in the current group. The fitness function value f of the i-th individual is specifically expressed as:
[0016] ;
[0017] Among them, makespan(i) represents the time span for all tasks of the i-th individual to be completed;
[0018] ;
[0019] Min is the task completion time matrix. Min is an m*n matrix. Each row represents the completion time of the same task request on n different service nodes in the cluster. Each column represents the completion time of m different task requests on the same service node in the cluster. represents the completion time of the jth task on the i-th service node;
[0020] Expressed as the standard deviation of the service node cluster load:
[0021] ;
[0022] Where S i Represents the i-th node in the cluster, and sets four evaluation indicators, including the service node's CPU utilization Cu, disk utilization Mu, memory utilization Bu, bandwidth utilization Tu, and load indicators ,in, , Cu i 、Mu i 、Bu i , Tu iThey represent the CPU utilization, disk utilization, memory utilization and bandwidth utilization of the i-th node respectively, ɑ2 represents the CPU utilization weight, β2 represents the disk utilization weight, γ2 represents the memory utilization weight, and δ2 represents the bandwidth utilization weight;
[0023] The weights are calculated according to the analytic hierarchy process:
[0024] The constructed judgment matrix is a 4×4 judgment matrix;
[0025] By comparing the evaluation indicators pairwise, the judgment matrix can be obtained as follows:
[0026] ;
[0027] Calculate the weight coefficient of each judgment index and find the eigenvector corresponding to the maximum eigenvalue of matrix A:
[0028] (-0.35088504,-0.35088504,-0.11223483,-0.86090808)T;
[0029] Normalizing the feature vector, we get:
[0030] (0.21,0.21,0.07,0.51)T;
[0031] It can be seen that the indicator weight ɑ2 of CPU utilization Cu is 0.21, the weight β2 of disk utilization Mu is 0.21, the weight γ2 of memory utilization Bu is 0.07, and the indicator weight δ2 of bandwidth utilization Tu is 0.51;
[0032] The final load index is ;
[0033] S6: Calculate the selection probability Ps of each individual in the current group through the fitness function value f of each individual. The specific calculation method of the selection probability Ps is:
[0034] ;
[0035] Among them, Ps(i) represents the selection probability of the i-th individual in the current group, and f(i) represents the fitness function value of the i-th individual in the current group;
[0036] S7: Perform iterative operations; generate a new group, which is an empty set, generate a random number m, m=random[0,1], take each individual in the current group as a parent, and perform the following conditional judgments:
[0037] Condition 1: The parent's selection probability Ps ≥ m;
[0038] Condition 2: The parent's selection probability Ps < m, and m ≥ Pc + Pm;
[0039] Condition 3: The probability of selecting the parent is Ps<m, and m<Pc+Pm;
[0040] Insert the parents that meet condition 1 directly into the new population, perform crossover operations on the parents that meet condition 2, and insert the offspring generated after the crossover operation into the new population, perform mutation operations on the parents that meet condition 3, and insert the offspring generated after the mutation operation into the new population;
[0041] S8: Set the iteration termination condition. If the iteration termination condition is met, the iteration operation is stopped and the final task request allocation solution set is obtained. If the iteration termination condition is not met, the new group is used as the current group and returns to S4.
[0042] Preferably, the cross-boundary thresholds preset in S1 include a CPU load threshold Fc, a disk load threshold Fd, a memory load threshold Fm, and a bandwidth load threshold Fb of the edge node.
[0043] Preferably, the length of the chromosome corresponds to the number of task requests, and the value of each gene position in the chromosome represents the task request number.
[0044] Preferably, in S3, 10≤ksize≤300, 200≤Tm≤1000, 0.4≤Pc≤0.99, 0.001≤Pm≤0.1.
[0045] Preferably, in S7, the calculation method of the crossover probability Pc is:
[0046] ;
[0047] in, Represents the maximum value of the fitness function in the current population, represents the average value of the fitness function in the current population, Indicates the fitness function value of the parent participating in the crossover with the larger fitness function value, k1, k2 are constants, where k1 <k2;
[0048] The calculation method of mutation probability Pm is:
[0049] ;
[0050] in, Indicates the fitness function value of the parent participating in the mutation, k3, k4 are constants, where k3 <k4。
[0051] Preferably, in S8, the termination condition is as follows:
[0052] When the number of iterations reaches the stop iteration number Tm, the iteration is terminated, or when the fitness function value f of all individuals reaches the threshold, the iteration is terminated.
[0053] Compared with the prior art, the present invention has the following beneficial effects:
[0054] The present invention optimizes the Min-Min algorithm through weight analysis of preset indicators, and combines the Min-Min algorithm with a genetic algorithm to obtain the optimal allocation method, which can generate a production scheduling problem with the shortest total task processing time, and uses a genetic algorithm with the characteristics of high efficiency, parallelism, and global search to find the optimal solution to this production scheduling problem. This optimal solution is the load distribution solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 This is a flowchart of the application;
[0056] Figure 2 The task-service node coding diagram for this application;
[0057] Figure 3 This is a schematic diagram of the hierarchical structure of this application;
[0058] Figure 4 This is the genetic algorithm flow chart of this application. DETAILED DESCRIPTION
[0059] In order to facilitate those skilled in the art to understand the technical content of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific examples. It should be understood that the specific examples described herein are only used to explain the present invention and are not used to limit the present invention.
[0060] Example 1
[0061] like Figure 1 , Figure 2 As shown, a load balancing method based on an improved genetic algorithm comprises the following steps:
[0062] S1: Initialize parameters, collect the load indicators of each edge node in the cluster regularly according to the preset time period, and move the edge nodes whose load indicators exceed the preset cross-border thresholds into the overload queue. The preset cross-border thresholds include the CPU load threshold Fc, disk load threshold Fd, memory load threshold Fm, and bandwidth load threshold Fb of the edge node;
[0063] When any resource load of an edge node exceeds the set cross-boundary threshold, it means that the working status of the edge node is not healthy. Moving the edge node into the overload queue can ensure the health of the current population and improve the utilization efficiency of the population.
[0064] S2: According to the genetic algorithm, the problem to be solved is encoded based on the load-adaptive queue, that is, each task request allocation scheme is encoded as an individual of a chromosome structure, the chromosome length corresponds to the number of task requests, the value of each gene position represents the task request number, and the service node number is represented by the value in each gene position. Assume that m task requests (J1.....Jm) are allocated to n (R1,....Rn) service nodes. Figure 4 shown.
[0065] Using matrix structure to explain chromosome structure is represented as task allocation matrix Min_S m*n , whose element Min_S ji =1, indicating that task Jj is assigned to server node Ri, otherwise, Min_S ji =0;
[0066] The following is an example of chromosome encoding for a scheme of allocating 5 requests to 3 server nodes. 5 requests are allocated to 3 server nodes, request 1 is allocated to edge node 2, request 2 is allocated to edge node 3, request 3 is allocated to edge node 1, request 4 is allocated to edge node 2, and request 5 is allocated to edge node 1. Each chromosome in the genetic algorithm represents an allocation scheme, and the chromosome encoding is shown in the following matrix:
[0067] .
[0068] S3: Confirm the population size ksize, the number of stop iterations Tm, the crossover probability Pc, and the mutation probability Pm, where 10≤ksize≤300, 200≤Tm≤1000, 0.4≤Pc≤0.99, and 0.001≤Pm≤0.1.
[0069] S4: According to the Min-Min algorithm, the set of individuals is set as the initial population Po, Po={P1...P ksize}, take the initial population Po as the current population and proceed to the next step.
[0070] S5: Calculate the fitness function value f of each individual in the current group through weight analysis of preset indicators;
[0071] The fitness function value f of the i-th individual is specifically expressed as:
[0072] ;
[0073] Among them, makespan(i) represents the time span for all tasks of the i-th individual to be completed;
[0074] ;
[0075] Min is the task completion time matrix. Min is an m*n matrix. Each row represents the completion time of the same task request on n different service nodes in the cluster. Each column represents the completion time of m different task requests on the same service node in the cluster. Indicates the completion time of the j-th task on the i-th service node.
[0076] in, Expressed as the standard deviation of the service node cluster load, ;
[0077] The optimal span is to minimize the total execution time of the task (makespan). Therefore, the total execution time function of the task combined with the load of the server node is selected as the fitness function of the genetic algorithm.
[0078] Let S i Represents the i-th node in the cluster, and sets four evaluation indicators, including the CPU utilization Cu, disk utilization Mu, memory utilization Bu, bandwidth utilization Tu, and load indicators of edge nodes. ,in, , Cu i 、Mu i 、Bu i , Tu i They represent the CPU utilization, disk utilization, memory utilization and bandwidth utilization of the i-th node respectively, ɑ2 represents the CPU utilization weight, β2 represents the disk utilization weight, γ2 represents the memory utilization weight, and δ2 represents the bandwidth utilization weight;
[0079] The weight setting is determined by the hierarchical analysis method, such as Figure 3 As shown in the figure, a hierarchical structure is established, which is divided into the target layer, the criterion layer, and the program layer;
[0080] (1) Construct a judgment matrix. There are 4 evaluation indicators at the criterion level, so the constructed judgment matrix is 4*4;
[0081] (2) By comparing the evaluation indicators of the criterion layer pairwise, we can get the judgment matrix:
[0082] ;
[0083] (3) Perform consistency check on the obtained judgment matrix, and verify that CR < 0.1 by calculating the consistency ratio CR. This judgment matrix is reasonable.
[0084] (4) Calculate the weight coefficient of each indicator. The eigenvector corresponding to the maximum eigenvalue of the matrix T is (-0.35088504,-0.35088504,-0.11223483,-0.86090808)T, and normalizes it to (0.21,0.21,0.07,0.51)T. It can be seen that the indicator weight ɑ2 of CPU utilization Cu is 0.21, the weight β2 of disk utilization Mu is 0.21, the weight γ2 of memory utilization Bu is 0.07, and the indicator weight δ2 of bandwidth utilization Tu is 0.51;
[0085] The final load index is .
[0086] S6: Calculate the selection probability Ps of each individual in the current group through the fitness function value f of each individual;
[0087] The specific calculation method of the selection probability Ps is:
[0088] ;
[0089] Among them, Ps(i) represents the selection probability of the i-th individual in the current population, and f(i) represents the fitness function value of the i-th individual in the current population.
[0090] S7: Perform iterative operations; generate a new group, which is an empty set, generate a random number m, m=random[0,1], take each individual in the current group as a parent, and perform the following conditional judgments:
[0091] Condition 1: The parent's selection probability Ps(i) ≥ m;
[0092] Condition 2: The parent's selection probability Ps(i) < m, and m ≥ Pc + Pm;
[0093] Condition 3: The probability of selecting the parent is Ps(i) < m, and m < Pc + Pm;
[0094] Insert the parents that meet condition 1 directly into the new population, perform crossover operations on the parents that meet condition 2, and insert the offspring generated after the crossover operation into the new population, perform mutation operations on the parents that meet condition 3, and insert the offspring generated after the mutation operation into the new population;
[0095] Among them, the calculation method of the crossover probability Pc is:
[0096] ;
[0097] in, Represents the maximum value of the fitness function in the current population, represents the average value of the fitness function in the current population, Indicates the fitness function value of the parent participating in the crossover with the larger fitness function value, k1, k2 are constants, where k1 <k2;
[0098] The calculation method of mutation probability Pm is:
[0099] ;
[0100] in, Indicates the fitness function value of the parent participating in the mutation, k3, k4 are constants, where k3 <k4。
[0101] S8: The genetic algorithm cannot be allowed to iterate continuously, because this will waste the performance of edge nodes and fail to allocate edge nodes to requests in time. Therefore, we need to set the iteration termination condition, which is as follows:
[0102] When the number of iterations reaches the stop iteration number Tm, the iteration is terminated, or when the fitness function value f of all individuals reaches the threshold, the iteration is terminated.
[0103] S9: Finally, in order to evaluate the performance of the MMGA algorithm, the average load of the entire cluster is used to measure the cluster resource utilization. The larger the average load, the higher the cluster resource utilization. Assuming that the cluster is n, S i The average load calculation formula for the i-th node is as follows:
[0104] ;
[0105] The standard deviation of the entire cluster load is used to measure the load balancing degree of the entire cluster. The smaller the standard deviation, the smaller the load difference between each server node, and the higher the load balancing degree of the entire cluster. The calculation method of is as follows:
[0106] ;
[0107] The higher the average load, the higher the cluster resource utilization. The smaller the standard deviation, the more evenly the load distribution of each server node is, and the higher the load balancing degree of the entire cluster is.
[0108] In this embodiment, compared with the Min-Min algorithm, the present application only considers the response time between the load balancing device and the server instead of the response time between the client and the server, and more only reflects the network status but not the device performance. The present invention proposes to perform weighted summation of the service node's CPU utilization, disk utilization, bandwidth utilization and other indicators with memory utilization to calculate a comprehensive index, and then use this comprehensive index to measure the load of each node to optimize the Min-Min algorithm; and combine the Min-Min algorithm with a genetic algorithm.
[0109] This application regards the load balancing scheduling problem as a production scheduling problem in which m request tasks of different complexity are randomly assigned to n service nodes with different performances to obtain the optimal allocation method so that the total processing time of the tasks is the shortest. The optimal solution of this production scheduling problem is obtained by using a genetic algorithm with the characteristics of high efficiency, parallelism, and global search. This optimal solution is our load distribution solution.
[0110] Compared with ordinary weights, this application is artificially assigned, which is too subjective, and the comprehensive load obtained cannot objectively and accurately measure the load pressure of each node. The present invention selects the hierarchical analysis method to hierarchize the problem to be analyzed, decompose the problem into different components, and according to the mutual relationship and affiliation between the factors, the factors are clustered and combined at different levels to form a multi-layer analysis structure model.
[0111] This application uses the average value and standard deviation of the cluster load to evaluate the performance of the MMGA algorithm.
Claims
1. A load balancing method based on an improved genetic algorithm, characterized in that: The following steps are involved: S1: regularly collect the load indicators of each edge node in the appropriate load queue in the cluster according to the preset time period, and move the edge nodes whose load indicators exceed the preset cross-boundary threshold into the heavy load queue; S2: According to the genetic algorithm, based on the load-appropriate queue, the problem to be solved is encoded, that is, each task request allocation scheme is encoded as an individual of a chromosome structure; S3: Confirm the population size ksize, the number of stop iterations Tm, the crossover probability Pc, the mutation probability Pm, the selection probability Ps of each individual and the fitness function value f of each individual; S4: According to the Min-Min algorithm, select ksize solutions as the initial population P0, P0={P1…P ksize }, take the initial population P0 as the current population and proceed to the next step; S5: Perform weight analysis on the load index of the current group through the hierarchical analysis method, and further calculate and evaluate the fitness function value f of each individual in the current group. The fitness function value f of the i-th individual is specifically expressed as: ; Among them, makespan(i) represents the time span for all tasks of the i-th individual to be completed; ; Min is the task completion time matrix. Min is an m*n matrix. Each row represents the completion time of the same task request on n different service nodes in the cluster. Each column represents the completion time of m different task requests on the same service node in the cluster. Indicates the completion time of the jth task on the i-th service node; Expressed as the standard deviation of the service node cluster load: ; Where S i Represents the i-th node in the cluster, and sets four evaluation indicators, including the service node's CPU utilization Cu, disk utilization Mu, memory utilization Bu, bandwidth utilization Tu, and load indicators ,in, , Cu i 、Mu i 、Bu i , Tu i They represent the CPU utilization, disk utilization, memory utilization and bandwidth utilization of the i-th node respectively, ɑ2 represents the CPU utilization weight, β2 represents the disk utilization weight, γ2 represents the memory utilization weight, and δ2 represents the bandwidth utilization weight; The weights are calculated according to the analytic hierarchy process: The constructed judgment matrix is a 4×4 judgment matrix; By comparing the evaluation indicators pairwise, the judgment matrix can be obtained as follows: ; Calculate the weight coefficient of each judgment index and find the eigenvector corresponding to the maximum eigenvalue of matrix A: (-0.35088504,-0.35088504,-0.11223483,-0.86090808)T; Normalizing the feature vector, we get: (0.21,0.21,0.07,0.51)T; It can be seen that the indicator weight ɑ2 of CPU utilization Cu is 0.21, the weight β2 of disk utilization Mu is 0.21, the weight γ2 of memory utilization Bu is 0.07, and the indicator weight δ2 of bandwidth utilization Tu is 0.51; The final load index is ; S6: Calculate the selection probability Ps of each individual in the current group through the fitness function value f of each individual. The specific calculation method of the selection probability Ps is: ; Among them, Ps(i) represents the selection probability of the i-th individual in the current group, and f(i) represents the fitness function value of the i-th individual in the current group; S7: Perform iterative operations; generate a new group, which is an empty set, generate a random number m, m=random[0,1], take each individual in the current group as a parent, and perform the following conditional judgments: Condition 1: The parent's selection probability Ps ≥ m; Condition 2: The probability of selecting the parent is Ps < m, and m ≥ Pc + Pm; Condition 3: The probability of selecting the parent is Ps<m, and m<Pc+Pm; Insert the parents that meet condition 1 directly into the new population, perform crossover operations on the parents that meet condition 2, and insert the offspring generated after the crossover operation into the new population, perform mutation operations on the parents that meet condition 3, and insert the offspring generated after the mutation operation into the new population; S8: Set the iteration termination condition. If the iteration termination condition is met, the iteration operation is stopped and the final task request allocation solution set is obtained. If the iteration termination condition is not met, the new group is used as the current group and returns to S4.
2. The load balancing method based on an improved genetic algorithm according to claim 1, characterized in that: The preset out-of-bounds thresholds in S1 include the CPU load threshold Fc, disk load threshold Fd, memory load threshold Fm, and bandwidth load threshold Fb of the edge node.
3. The load balancing method based on an improved genetic algorithm according to claim 1, characterized in that: The length of the chromosome corresponds to the number of task requests, and the value of each gene position in the chromosome represents the task request number.
4. The load balancing method based on an improved genetic algorithm according to claim 1, characterized in that: In S3, 10≤ksize≤300, 200≤Tm≤1000, 0.4≤Pc≤0.99, 0.001≤Pm≤0.
1.
5. The load balancing method based on improved genetic algorithm according to claim 1, characterized in that: In S7, the calculation method of the crossover probability Pc is: ; in, Represents the maximum value of the fitness function in the current population, represents the average value of the fitness function in the current population, Indicates the fitness function value of the parent participating in the crossover with the larger fitness function value, k1, k2 are constants, where k1 <k2; The calculation method of mutation probability Pm is: ; in, Indicates the fitness function value of the parent participating in the mutation, k3, k4 are constants, where k3 <k4。 6. The load balancing method based on improved genetic algorithm according to claim 1, characterized in that: In S8, the termination conditions are as follows: When the number of iterations reaches the stop iteration number Tm, the iteration is terminated, or when the fitness function value f of all individuals reaches the threshold, the iteration is terminated.