A load balancing method, device, equipment and readable storage medium

By creating a backup group for each traffic group in the load balancing scheme and balancing allocation, the problem of node load imbalance after individual service failure is solved, and relative load balancing and service continuity are achieved.

CN113867964BActive Publication Date: 2025-03-14SANGFOR TECH INC
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111166677.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-30
Publication Date
2025-03-14
Estimated Expiration
2041-09-30

AI Technical Summary

Technical Problem

The existing load balancing scheme cannot effectively regulate the node load after individual service failures, resulting in load imbalance.

Method used

By determining multiple nodes that can carry traffic groups and multiple traffic groups to be allocated, after the traffic groups are equalized to the node, a backup group is created for each traffic group, and the backup group is equalized to other nodes to ensure that the node is load-balanced and the traffic group and backup group are not on the same node.

Benefits of technology

Relative balancing of node load after individual service failure is achieved, conflict between traffic groups and corresponding backup groups is avoided, the probability of backup groups and corresponding traffic groups being malfunctioned simultaneously, and the continuity of services is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113867964B_ABST
    Figure CN113867964B_ABST
Patent Text Reader

Abstract

The present application discloses a load balancing method, device, equipment and readable storage medium. The present application first evenly distributes multiple flow groups to be allocated to each node, so that the service pressure actually borne by each node is balanced; then evenly distributes the backup groups of each flow group to each node, so that after a certain flow group or node fails, other nodes or corresponding backup groups can immediately continue the service, so that the service is not interrupted, and the actual load on each node is relatively balanced, any flow group and the backup group corresponding to the flow group are not in the same node, avoiding conflicts between the flow group and the corresponding backup group, and reducing the probability of simultaneous failure of the backup group and the corresponding flow group. Correspondingly, a load balancing device, equipment and readable storage medium provided by the present application also have the above-mentioned technical effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a load balancing method, device, equipment and readable storage medium. Background Art

[0002] Currently, the existing load balancing solutions only balance the services running on each node, and do not consider the load size on different nodes after individual service failures. Therefore, the solution is not flexible and accurate, resulting in unbalanced load on each node after individual service failures.

[0003] Therefore, how to make the load balancing solution more flexible and accurate is a problem that technical personnel in this field need to solve. Summary of the invention

[0004] In view of this, the purpose of this application is to provide a load balancing method, device, equipment and readable storage medium to make the load balancing solution more flexible and accurate. The specific solution is as follows:

[0005] In a first aspect, the present application provides a load balancing method, comprising:

[0006] Determine multiple nodes that can carry traffic groups and multiple traffic groups to be allocated;

[0007] After the multiple traffic groups are evenly distributed to the multiple nodes, a backup group is created for each traffic group to obtain multiple backup groups;

[0008] The backup group to be allocated corresponding to any node is evenly distributed to other nodes so that the load of each node is balanced and any traffic group and the backup group corresponding to the traffic group are not in the same node; the backup group to be allocated is: the backup group corresponding to the traffic group in the node and has not been allocated to other nodes.

[0009] Preferably, the balancing distribution of the plurality of traffic groups to the plurality of nodes comprises:

[0010] If the total number of traffic groups is an integer multiple of the total number of nodes, traffic groups are evenly distributed to each node.

[0011] Preferably, the balancing distribution of the plurality of traffic groups to the plurality of nodes comprises:

[0012] If the total number of traffic groups is not an integer multiple of the total number of nodes, then when the total number of nodes is greater than the total number of traffic groups, a traffic group is assigned to each node, and nodes that are not assigned to a traffic group are deleted.

[0013] Preferably, the balancing distribution of the plurality of traffic groups to the plurality of nodes comprises:

[0014] If the total number of traffic groups is not an integer multiple of the total number of nodes, then when the total number of nodes is less than the total number of traffic groups, after evenly allocating an equal number of traffic groups to each node, optional nodes are randomly selected from all nodes, and the remaining unallocated traffic groups are evenly distributed to the optional nodes.

[0015] Preferably, the method of evenly distributing the backup group to be allocated corresponding to any node to other nodes so that the load of each node is balanced and any flow group and the backup group corresponding to the flow group are not in the same node includes:

[0016] For any target node, other nodes including the same number of allocated backup groups are divided into one class to obtain at least one class; the allocated backup groups are: backup groups corresponding to the traffic group in the target node and allocated to other nodes;

[0017] Determine the class that includes the least number of allocated backup groups as the target class;

[0018] If the total number of nodes included in the target class is equal to the total number of backup groups to be allocated corresponding to the target node, the backup groups to be allocated corresponding to the target node are evenly allocated to each node included in the target class.

[0019] Preferably, it also includes:

[0020] If the total number of nodes included in the target class is greater than the total number of backup groups to be allocated corresponding to the target node, the nodes included in the target class are arranged in ascending order according to the total number of loads to obtain a node sequence; the total number of loads is: the total number of backup groups and traffic groups in any node;

[0021] Starting from the first position of the node sequence, a backup group to be allocated is allocated to a node until the backup groups to be allocated corresponding to the target node are allocated, thereby achieving relative load balance and no conflict between the flow group and the backup group.

[0022] Preferably, it also includes:

[0023] If the total number of nodes included in the target class is less than the total number of backup groups to be allocated corresponding to the target nodes, then after allocating a backup group to be allocated to each node included in the target class, the step of dividing other nodes with the same number of allocated backup groups into one class to obtain at least one class is performed; and the class with the least number of allocated backup groups is determined as the target class.

[0024] Preferably, after the backup group to be allocated corresponding to any node is evenly allocated to other nodes, the method further includes:

[0025] If the total loads in different nodes are not equal, the flow groups and backup groups in each node are migrated according to preset rules; the total load is: the total number of backup groups and flow groups in any node.

[0026] Preferably, migrating the traffic group and the backup group in each node according to a preset rule includes:

[0027] The node with the largest total load among all nodes is determined as the maximum node, and the node with the smallest total load is determined as the minimum node;

[0028] Migrate any backup group or any flow group in the maximum node to the minimum node; wherein the flow group corresponding to any migrated backup group is not in the minimum node, and the backup group corresponding to any migrated flow group is not in the minimum node;

[0029] If after the migration, the difference between the total load in the maximum node and the total load in the minimum node is 1, the migration ends, so that the relative balance of the load can be achieved, and the flow group and the backup group do not conflict.

[0030] Preferably, it also includes:

[0031] If after migration, the difference between the total loads in the maximum node and the minimum node is not 1, then execute the steps of determining the node with the largest total load among all nodes as the maximum node, and determining the node with the least total load as the minimum node; and migrating any backup group or any traffic group in the maximum node to the minimum node.

[0032] Preferably, it also includes:

[0033] If any node fails, all flow groups in the failed node are determined as failed flow groups, and the failed flow groups are replaced by backup groups corresponding to the failed flow groups in other nodes.

[0034] Preferably, it also includes:

[0035] If any node fails, the node with the least total load is selected from all nodes that have not failed as the minimum node; the total load is: the total number of backup groups and flow groups in any node;

[0036] Migrate any backup group or any flow group in the failed node to the minimum node; wherein the flow group corresponding to any migrated backup group is not in the minimum node, and the backup group corresponding to any migrated flow group is not in the minimum node.

[0037] Preferably, it also includes:

[0038] If there are backup groups or traffic groups that have not been migrated in the failed node, the steps of selecting the node with the least total load from all nodes that have not failed as the minimum node; and migrating any backup group or any traffic group in the failed node to the minimum node are performed.

[0039] In a second aspect, the present application provides a load balancing device, including:

[0040] A determination module, used to determine multiple nodes that can carry traffic groups and multiple traffic groups to be allocated;

[0041] A flow group allocation module, configured to create a backup group for each flow group after evenly allocating the multiple flow groups to the multiple nodes, thereby obtaining multiple backup groups;

[0042] The backup group allocation module is used to evenly distribute the backup group to be allocated corresponding to any node to other nodes so that the load of each node is balanced and any traffic group and the backup group corresponding to the traffic group are not in the same node; the backup group to be allocated is: the backup group corresponding to the traffic group in the node and has not been allocated to other nodes.

[0043] In a third aspect, the present application provides an electronic device, including:

[0044] Memory for storing computer programs;

[0045] The processor is used to execute the computer program to implement the load balancing method disclosed above.

[0046] In a fourth aspect, the present application provides a readable storage medium for storing a computer program, wherein the computer program implements the aforementioned disclosed load balancing method when executed by a processor.

[0047] It can be seen from the above scheme that the present application provides a load balancing method, including: determining multiple nodes that can carry traffic groups, and multiple traffic groups to be allocated; after evenly allocating the multiple traffic groups to the multiple nodes, creating a backup group for each traffic group to obtain multiple backup groups; evenly allocating the backup group to be allocated corresponding to any node to other nodes, so that the load of each node is balanced and any traffic group and the backup group corresponding to the traffic group are not in the same node; the backup group to be allocated is: a backup group corresponding to the traffic group in the node and has not been allocated to other nodes.

[0048] It can be seen that the present application first evenly distributes the multiple flow groups to be allocated to each node so that the service pressure actually borne by each node is balanced; then the backup groups of each flow group are evenly distributed to each node, so that after a certain flow group or node fails, other nodes or corresponding backup groups can immediately continue the service to ensure that the service is not interrupted, and the actual load on each node is relatively balanced. Any flow group and the backup group corresponding to the flow group are not in the same node, so as to avoid conflicts between the flow group and the corresponding backup group and reduce the probability of simultaneous failure of the backup group and the corresponding flow group.

[0049] Correspondingly, a load balancing device, equipment and readable storage medium provided by the present application also have the above-mentioned technical effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0051] Figure 1 A flow chart of a load balancing method disclosed in this application;

[0052] Figure 2 A node schematic diagram disclosed in this application;

[0053] Figure 3 A schematic diagram of deploying a traffic group in a node disclosed in the present application;

[0054] Figure 4 A schematic diagram of balanced deployment of traffic groups and backup groups in a node disclosed in the present application;

[0055] Figure 5 A schematic diagram of a load balancing device disclosed in this application;

[0056] Figure 6 A schematic diagram of an electronic device disclosed in this application;

[0057] Figure 7 A schematic diagram of another electronic device disclosed in this application;

[0058] Figure 8 A schematic diagram of each node before allocating F1-F5 disclosed in this application;

[0059] Fig. 9 A schematic diagram of each node after sorting and level division of the first layer disclosed in this application;

[0060] Fig.10A schematic diagram of each node after the second-layer sorting disclosed in this application;

[0061] Fig.11 This is a schematic diagram of each node after a round of allocation disclosed in this application. DETAILED DESCRIPTION

[0062] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0063] At present, the existing load balancing solution only performs load balancing on the services running on each node, and does not consider the load size on different nodes after individual service failures. Therefore, the solution is not flexible and accurate, resulting in uneven load on each node after individual service failures. To this end, the present application provides a load balancing solution that can improve the flexibility and accuracy of the load balancing solution.

[0064] See also Figure 1 As shown, the embodiment of the present application discloses a load balancing method, including:

[0065] S101. Determine multiple nodes that can carry traffic groups and multiple traffic groups to be allocated.

[0066] It should be noted that a traffic group is configured with a FIP (Fload IP, floating IP), VMAC (virtual physical address) and other information. A virtual service can correspond to one or more traffic groups. When a traffic group is bound to a virtual service, the FIP configured in the traffic group can be regarded as a VIP (Virtual IP), which is the IP used when the virtual service is published.

[0067] A traffic group specifically refers to a set of related conditions for carrying a group of traffic, including FIP, VMAC, port and other information.

[0068] Node refers to: a virtual device in a cloud-native environment that carries a traffic group or backup group and actually processes traffic. Figure 2 ,exist Figure 2 In the example, four nodes are virtualized based on a switch: Node 1, Node 2, Node 3, and Node 4. Traffic groups are deployed in each node. Traffic groups include "VS-1|VIP-1" and "VS-2|VIP-2" in Node 1.

[0069] S102: After the multiple traffic groups are evenly distributed to the multiple nodes, a backup group is created for each traffic group to obtain multiple backup groups.

[0070] In a specific implementation, balancing multiple traffic groups to multiple nodes includes:

[0071] If the total number of traffic groups is an integer multiple of the total number of nodes, traffic groups are evenly distributed to each node.

[0072] If the total number of traffic groups is not an integer multiple of the total number of nodes, then when the total number of nodes is greater than the total number of traffic groups, a traffic group is assigned to each node and nodes that are not assigned to a traffic group are deleted.

[0073] If the total number of traffic groups is not an integer multiple of the total number of nodes, then when the total number of nodes is less than the total number of traffic groups, after allocating an equal number of traffic groups to each node, randomly select optional nodes from all nodes, and evenly distribute the remaining unallocated traffic groups to the optional nodes. That is, when the total number of nodes is less than the total number of traffic groups, calculate the ratio of the total number of traffic groups to the total number of nodes, round down the ratio to get the target value, allocate the target value of traffic groups to each node, determine the number of unallocated traffic groups, randomly select optional nodes equal to the number from all nodes, and evenly distribute the unallocated traffic groups to the optional nodes.

[0074] Assume there are 5 nodes and 5 traffic groups, then each node is assigned 1 traffic group. Assume there are 5 nodes and 10 traffic groups, then each node is assigned 2 traffic groups. It can be seen that when the total number of traffic groups is an integer multiple of the total number of nodes, traffic groups can be evenly allocated to each node so that all nodes carry the same number of traffic groups.

[0075] In the case where the total number of traffic groups is not an integer multiple of the total number of nodes, the total number of traffic groups may be greater than the total number of nodes or may be less than the total number of nodes.

[0076] When the total number of nodes is greater than the total number of traffic groups, a traffic group is assigned to each node, and nodes that are not assigned to a traffic group are discarded. For example, if there are 5 nodes and 4 traffic groups, 4 of them are assigned 1 traffic group each, and the remaining node is empty. This empty node is not used temporarily, so it is deleted.

[0077] When the total number of nodes is less than the total number of traffic groups, first calculate the lowest mean value that each node can be assigned to, and then assign the remaining traffic groups. Assuming there are 5 nodes and 12 traffic groups, then 12 / 5=2.4, rounded down to 2, then after each node is assigned 2 traffic groups, the remaining 2 traffic groups are randomly assigned to 2 of the 5 nodes.

[0078] S103: Evenly distribute the backup group to be allocated corresponding to any node to other nodes, so that the load of each node is balanced and any flow group and the backup group corresponding to the flow group are not in the same node.

[0079] The backup group to be allocated is a backup group that corresponds to the traffic group in the node and has not been allocated to other nodes.

[0080] It should be noted that any traffic group has a backup group. That is, there are as many backup groups as there are traffic groups. The backup group of a traffic group is exactly the same as the traffic group. In order to make the backup group and the corresponding traffic group back up each other and play a backup role, the backup group corresponding to a traffic group and the traffic group cannot be deployed in the same node. Only in this way, when the node where the traffic group is located fails, the corresponding backup group can play a backup role in other nodes. Among them, when a certain traffic group is effective, its corresponding backup group is not effective, that is, a traffic group and its corresponding backup group are used alternately.

[0081] In a specific implementation, the backup group to be allocated corresponding to any node is evenly allocated to other nodes so that the load of each node is balanced and any traffic group and the backup group corresponding to the traffic group are not in the same node, including: for any target node, other nodes including the same number of allocated backup groups are divided into one class to obtain at least one class; the allocated backup groups are: the backup groups corresponding to the traffic group in the target node and allocated to other nodes; the class including the least number of allocated backup groups is determined as the target class; if the total number of nodes included in the target class is equal to the total number of backup groups to be allocated corresponding to the target node, then the backup groups to be allocated corresponding to the target node are evenly distributed to each node included in the target class.

[0082] If the total number of nodes included in the target class is greater than the total number of backup groups to be allocated corresponding to the target node, the nodes included in the target class are arranged in ascending order according to the total load to obtain a node sequence; the total load is: the total number of backup groups and traffic groups in any node; starting from the first position of the node sequence, a backup group to be allocated is allocated to a node until the backup groups to be allocated corresponding to the target node are allocated.

[0083] If the total number of nodes included in the target class is less than the total number of backup groups to be allocated corresponding to the target nodes, then after allocating a backup group to be allocated to each node included in the target class, the other nodes including the same number of allocated backup groups are divided into one class to obtain at least one class; the class including the least number of allocated backup groups is determined as the target class, thereby realizing circular allocation.

[0084] See also Figure 3, there are 5 nodes: A, B, C, D, E. Node A includes 2 traffic groups, A1 and A2; Node B includes 2 traffic groups, B1 and B2; Node C includes 2 traffic groups, C1 and C2; Node D includes 2 traffic groups, D1 and D2; Node E includes 3 traffic groups, E1, E2, and E3. There are 11 traffic groups in total, so the 11 backup groups corresponding to these 11 traffic groups also need to be allocated to these 5 nodes. Before these 11 backup groups are allocated, the backup group schematic area is empty.

[0085] For node A, the backup groups to be allocated corresponding to node A include A1' corresponding to A1 and A2' corresponding to A2. So where should A1' and A2' be allocated? First, classify nodes B, C, D, and E except node A. Currently, nodes B, C, D, and E do not have backup groups corresponding to A1 and A2. Then nodes B, C, D, and E can be classified into one category, and the number of allocated backup groups included in this category is the least (0), so this category is the target category.

[0086] At this time, there are 4 nodes in the target class (i.e., B, C, D, E), and the total number of backup groups to be allocated is 2 (i.e., A1' and A2'), that is, the total number of nodes included in the target class is greater than the total number of backup groups to be allocated. Then, arrange the nodes included in the target class in ascending order according to the total number of loads, and obtain the node sequence: [B, C, D, E]. The total number of loads of B is 2, the total number of loads of C is 2, the total number of loads of D is 2, and the total number of loads of E is 3. Then, starting from the first node in the node sequence (i.e., node B), allocate a backup group to be allocated to each node until all the backup groups to be allocated are allocated. That is, A1' is allocated to B, and A2' is allocated to C, thereby completing the allocation of A1' and A2'.

[0087] Assume that the allocation of backup groups to be allocated is performed for node B later. After the above allocation, node B includes: B1, B2, A1'; node C includes C1, C2, A2'. The load of other nodes has not changed. At this time, the backup groups to be allocated corresponding to node B include B1' corresponding to B1 and B2' corresponding to B2, so where should B1' and B2' be allocated? First, classify the nodes A, C, D, and E except node B. Currently, there are no backup groups corresponding to B1 and B2 in nodes A, C, D, and E. Then nodes A, C, D, and E can be classified into one category, and this category includes the least number of allocated backup groups (0), so this category is the target category.

[0088] At this time, there are 4 nodes in the target class (i.e., A, C, D, E), and the total number of backup groups to be allocated is 2 (i.e., B1' and B2'), that is, the total number of nodes included in the target class is greater than the total number of backup groups to be allocated. Then, the nodes included in the target class are arranged in ascending order according to the total number of loads, and the node sequence is obtained: [A, D, C, E]. The total number of loads of A is 2, the total number of loads of D is 2, the total number of loads of C is 3, and the total number of loads of E is 3. Then, starting from the first node in the node sequence (i.e., node A), a backup group to be allocated is allocated to each node until all the backup groups to be allocated are allocated. That is, B1' is allocated to A, and B2' is allocated to D, thereby completing the allocation of A1' and A2'.

[0089] See also Figure 4 , assuming that the backup groups to be allocated are subsequently allocated to nodes C, D, and E. After the allocation is completed, the load results presented can be:

[0090] Node A includes 4 loads: A1, A2, B1', and C1';

[0091] Node B includes 5 loads, namely B1, B2, A1', C2', and E3';

[0092] Node C includes 5 loads, namely C1, C2, A2', D1', and E2';

[0093] Node D includes 4 loads: D1, D2, B2', and E1';

[0094] Node E includes four loads, namely E1, E2, E3 and D2'.

[0095] It can be seen that the difference in load between the node with the most load and the node with the least load is 1, which achieves relative load balance and there is no conflict between the traffic group and the backup group.

[0096] When arranging the nodes according to the total number of loads, the arrangement positions of different nodes with the same total number of loads can be interchanged, and the interchange does not affect the implementation of this embodiment.

[0097] It can be seen that this embodiment first evenly distributes multiple flow groups to be allocated to each node, so that the service pressure actually borne by each node is balanced; then the backup groups of each flow group are evenly distributed to each node, so that after a certain flow group or node fails, other nodes or corresponding backup groups can immediately continue the service, so that the service is not interrupted, and the actual load on each node is relatively balanced. Any flow group and the backup group corresponding to the flow group are not in the same node, so as to avoid conflicts between the flow group and the corresponding backup group and reduce the probability of simultaneous failure of the backup group and the corresponding flow group.

[0098] Based on the above embodiment, it should be noted that after the backup group to be allocated corresponding to any node is evenly distributed to other nodes, it also includes: if the total loads in different nodes are not equal, the traffic groups and backup groups in each node are migrated according to preset rules; the total load is: the total number of backup groups and traffic groups in any node.

[0099] The traffic groups and backup groups in each node are migrated according to preset rules, including:

[0100] The node with the largest total load among all nodes is determined as the largest node, and the node with the smallest total load is determined as the smallest node; any backup group or any flow group in the largest node is migrated to the smallest node; wherein, the flow group corresponding to any migrated backup group is not in the smallest node, and the backup group corresponding to any migrated flow group is not in the smallest node; if after migration, the difference between the total loads in the largest node and the smallest node is 1, then the migration ends. If after migration, the difference between the total loads in the largest node and the smallest node is not 1, then the step of determining the node with the largest total load among all nodes as the largest node and the node with the smallest total load as the smallest node is executed; and migrating any backup group or any flow group in the largest node to the smallest node is executed to realize the cyclic execution of the migration step. When the difference between the total loads in the largest node and the smallest node is 1, the relative load balance is achieved, and the flow group and the backup group do not conflict.

[0101] Based on the above embodiments, it should be noted that if any node fails, it is necessary to migrate the loads in the failed node to other normal nodes, and at the same time use the backup group corresponding to the failed traffic group in other nodes to replace the failed traffic group to continue running the relevant virtual services.

[0102] In a specific implementation, if any node fails, all traffic groups in the failed node are identified as failed traffic groups, and the failed traffic groups are replaced by backup groups corresponding to the failed traffic groups in other nodes to ensure that virtual services are not interrupted.

[0103] In a specific implementation, if any node fails, the node with the least total load from all nodes that have not failed is selected as the minimum node; the total load is: the total number of backup groups and flow groups in any node; any backup group or any flow group in the failed node is migrated to the minimum node; wherein, the flow group corresponding to any migrated backup group is not in the minimum node, and the backup group corresponding to any migrated flow group is not in the minimum node; if there are backup groups or flow groups that have not been migrated in the failed node, the steps of selecting the node with the least total load from all nodes that have not failed as the minimum node; migrating any backup group or any flow group in the failed node to the minimum node are performed until there are no backup groups or flow groups that have not been migrated in the failed node.

[0104] It can be seen that in the process of migrating each load in the failed node to other normal nodes, it is still necessary to avoid conflicts between the traffic group and the corresponding backup group to reduce the probability of simultaneous failure of the backup group and the corresponding traffic group.

[0105] Based on the above embodiment, it should be noted that if a new node is added, the new node will be added to all nodes, and the node with the largest total load among all nodes will be determined as the largest node, and the node with the smallest total load will be determined as the smallest node; any backup group or any flow group in the largest node will be migrated to the smallest node; if after migration, the difference between the total loads in the largest node and the smallest node is 1, the migration ends; otherwise, the node with the largest total load among all nodes will be determined as the largest node, and the node with the smallest total load will be determined as the smallest node; any backup group or any flow group in the largest node will be migrated to the smallest node, until the difference between the total loads in the largest node and the smallest node is 1, so as to achieve relative load balance, and the flow group and the backup group do not conflict.

[0106] It can be seen that after adding a new node, the new node is used to share the load of the original node. In this process, it is still necessary to avoid conflicts between the traffic group and the corresponding backup group to reduce the probability of simultaneous failure of the backup group and the corresponding traffic group.

[0107] A load balancing device provided in an embodiment of the present application is introduced below. The load balancing device described below and the load balancing method described above can be referenced to each other.

[0108] See also Figure 5 As shown, the embodiment of the present application discloses a load balancing device, including:

[0109] A determination module 501, used to determine a plurality of nodes that can carry a traffic group, and a plurality of traffic groups to be allocated;

[0110] A flow group allocation module 502 is used to evenly allocate multiple flow groups to multiple nodes, and then create a backup group for each flow group to obtain multiple backup groups;

[0111] The backup group allocation module 503 is used to evenly distribute the backup group to be allocated corresponding to any node to other nodes so that the load of each node is balanced and any traffic group and the backup group corresponding to the traffic group are not in the same node; the backup group to be allocated is: the backup group corresponding to the traffic group in the node and has not been allocated to other nodes.

[0112] In a specific implementation, the flow group allocation module is specifically used to:

[0113] If the total number of traffic groups is an integer multiple of the total number of nodes, traffic groups are evenly distributed to each node.

[0114] In a specific implementation, the flow group allocation module is specifically used to:

[0115] If the total number of traffic groups is not an integer multiple of the total number of nodes, then when the total number of nodes is greater than the total number of traffic groups, a traffic group is assigned to each node, and nodes that are not assigned to a traffic group are deleted.

[0116] In a specific implementation, the flow group allocation module is specifically used to:

[0117] If the total number of traffic groups is not an integer multiple of the total number of nodes, then when the total number of nodes is less than the total number of traffic groups, after evenly allocating an equal number of traffic groups to each node, select optional nodes randomly from all nodes and evenly distribute the remaining unallocated traffic groups to the optional nodes.

[0118] In a specific implementation, the backup group allocation module includes:

[0119] A division unit is used to divide other nodes including the same number of allocated backup groups into one class for any target node, so as to obtain at least one class; the allocated backup groups are: backup groups corresponding to the traffic groups in the target node and allocated to other nodes;

[0120] A determination unit, configured to determine the class including the least number of allocated backup groups as the target class;

[0121] The first allocation unit is configured to evenly allocate the backup groups to be allocated corresponding to the target nodes to each node included in the target class if the total number of nodes included in the target class is equal to the total number of backup groups to be allocated corresponding to the target nodes.

[0122] In a specific implementation, the backup group allocation module further includes:

[0123] A sorting unit is used to arrange the nodes included in the target class in ascending order according to the total load to obtain a node sequence if the total number of nodes included in the target class is greater than the total number of backup groups to be allocated corresponding to the target node; the total load is: the total number of backup groups and flow groups in any node;

[0124] The second allocation unit is used to allocate a backup group to be allocated to a node starting from the first node in the node sequence until the backup groups to be allocated corresponding to the target node are allocated, so as to achieve relative load balance and no conflict between the flow group and the backup group.

[0125] In a specific implementation, the backup group allocation module further includes:

[0126] The third allocation unit is used for allocating a backup group to be allocated to each node included in the target class if the total number of nodes included in the target class is less than the total number of backup groups to be allocated corresponding to the target nodes, and then dividing other nodes including the same number of allocated backup groups into one class to obtain at least one class; and determining the class including the least number of allocated backup groups as the target class.

[0127] In a specific embodiment, it also includes:

[0128] The load balancing module is used to migrate the traffic groups and backup groups in each node according to preset rules if the total loads in different nodes are not equal; the total load is: the total number of backup groups and traffic groups in any node.

[0129] In a specific implementation, the load balancing module includes:

[0130] A node determination unit, used to determine the node with the largest total load among all nodes as the maximum node, and determine the node with the smallest total load as the minimum node;

[0131] A migration unit, used to migrate any backup group or any flow group in the largest node to the smallest node; wherein the flow group corresponding to any migrated backup group is not in the smallest node, and the backup group corresponding to any migrated flow group is not in the smallest node;

[0132] The detection unit is used to terminate the migration if the difference between the total load in the maximum node and the total load in the minimum node after the migration is 1, thereby achieving relative load balance and no conflict between the flow group and the backup group.

[0133] In a specific implementation, the load balancing module further includes:

[0134] A cyclic execution unit is used to determine the node with the largest total load among all nodes as the largest node and the node with the smallest total load as the smallest node if the difference between the total loads in the largest node and the minimum node after migration is not 1; and to migrate any backup group or any traffic group in the largest node to the minimum node.

[0135] In a specific embodiment, it also includes:

[0136] The service continuation module is used to determine all flow groups in the failed node as failed flow groups if any node fails, and use the backup groups corresponding to the failed flow groups in other nodes to replace the failed flow groups.

[0137] In a specific embodiment, it also includes:

[0138] A post-failure migration module is used to select the node with the least total load from all nodes that have not failed as the minimum node if any node fails; the total load is: the total number of backup groups and flow groups in any node; any backup group or any flow group in the failed node is migrated to the minimum node; wherein the flow group corresponding to any migrated backup group is not in the minimum node, and the backup group corresponding to any migrated flow group is not in the minimum node.

[0139] In a specific implementation manner, the post-failure migration module is further configured to:

[0140] If there are backup groups or traffic groups that have not been migrated in the failed node, the steps of selecting a node with the least total load from all nodes that have not failed as the minimum node; and migrating any backup group or any traffic group in the failed node to the minimum node are performed.

[0141] Among them, for more specific working processes of each module and unit in this embodiment, reference can be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0142] It can be seen that this embodiment provides a load balancing device, which can make the actual load on each node relatively balanced. At the same time, any traffic group and the backup group corresponding to the traffic group are not in the same node, thereby avoiding conflicts between the traffic group and the corresponding backup group and reducing the probability of simultaneous failure of the backup group and the corresponding traffic group.

[0143] An electronic device provided in an embodiment of the present application is introduced below. The electronic device described below and the load balancing method and device described above can be referenced to each other.

[0144] See also Figure 6 As shown, the embodiment of the present application discloses an electronic device, including:

[0145] Memory 601, used for storing computer programs;

[0146] The processor 602 is used to execute the computer program to implement the method disclosed in any of the above embodiments.

[0147] Please refer to Figure 7 , Figure 7 Another electronic device schematic diagram provided for this embodiment, the electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 322 (for example, one or more processors) and memory 332, one or more storage media 330 (for example, one or more mass storage devices) storing application programs 342 or data 344. Among them, the memory 332 and the storage medium 330 can be short-term storage or permanent storage. The program stored in the storage medium 330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the central processor 322 can be configured to communicate with the storage medium 330 to execute a series of instruction operations in the storage medium 330 on the electronic device 301.

[0148] The electronic device 301 may further include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341. For example, Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0149] exist Figure 7 In the embodiment, the application 342 may be a program for executing the load balancing method, and the data 344 may be data required or generated for executing the load balancing method.

[0150] The steps in the load balancing method described above can be implemented by the structure of an electronic device.

[0151] A readable storage medium provided in an embodiment of the present application is introduced below. The readable storage medium described below and the load balancing method, apparatus, and device described above can refer to each other.

[0152] A readable storage medium is used to store a computer program, wherein the computer program, when executed by a processor, implements the load balancing method disclosed in the above embodiment. The specific steps of the method can refer to the corresponding contents disclosed in the above embodiment, and will not be repeated here.

[0153] A load balancing solution provided in an embodiment of the present application is introduced below. The load balancing solution described below and the load balancing method, device and equipment described above can be referenced to each other.

[0154] 1. Configure virtual services.

[0155] One virtual service is configured with at least one traffic group, so as to obtain multiple traffic groups that need to be allocated. One traffic group is configured with one FIP.

[0156] For a virtual service, all traffic of the service can be considered to be divided equally by FIP (i.e. traffic group). Multiple FIPs can further subdivide the traffic, and the pressure can be more evenly distributed to other nodes when a node is offline.

[0157] 2. Allocation of traffic groups.

[0158] Assume that there are currently N nodes and M FIPs (i.e., each traffic group to be allocated). Each node is allocated at least M / N FIPs and at most M / N+1 FIPs, so that the number of FIPs on different nodes does not differ by more than 1. Among them, M%N nodes can be allocated M / N+1 FIPs.

[0159] When a new node is added, FIPs need to be distributed from other nodes; when a node is deleted, the FIPs on the deleted node need to be distributed to other nodes.

[0160] Since FIP cannot be recovered after being allocated, in order to simplify the logic, generally during the system construction phase, all available FIPs are directly allocated to all virtual services, thereby directly allocating traffic groups to each node.

[0161] Generally, M FIPs support at most M nodes. Ideally, N nodes require N(N-1) FIPs.

[0162] 3. Balancing of traffic groups.

[0163] Count the number of traffic groups in all nodes, take the node with the largest number of traffic groups as the maximum node, and take the node with the least number of traffic groups as the minimum node.

[0164] Select a traffic group from the largest node and migrate it to the smallest node. After the migration is completed, re-determine the largest node and the smallest node until the difference in the number of traffic groups on the smallest node and the largest node does not exceed 1.

[0165] Among them, if the traffic group selected from the largest node corresponds to a backup group in the smallest node, then the traffic group in the largest node is directly designated as the backup group, and the backup group corresponding to the traffic group in the smallest node is designated as the traffic group, that is, the identities of the backup group and the traffic group are swapped. Of course, it is also possible to avoid migrating such traffic groups, so that the backup group and the traffic group do not need to exchange their identities.

[0166] 4. Balance of the backup group.

[0167] Set up a backup group for each traffic group. The backup group is not deployed on the same node as its corresponding traffic group and can be assigned to any other node.

[0168] When any node goes offline, all traffic groups on the node are immediately switched to the corresponding backup group, and all traffic groups on the node are distributed to other nodes.

[0169] All backup groups corresponding to the traffic group in a node need to be evenly distributed to other nodes.

[0170] When allocating backup groups, it is necessary to ensure that after a single node goes offline and the backup group takes effect, the total traffic on different nodes is balanced. At this time, the number of traffic groups that have taken effect on each node needs to be considered.

[0171] Assign all backup groups corresponding to any node as follows.

[0172] Assume that there are nodes: N1, N2, N3, N4, N5, N6, and record the traffic groups on nodes N1-N5 as "node ID / number of backup groups containing N6 (i.e., the allocated backup groups corresponding to the N6 node) / total number of loads", then there are: N1 / 2 / 4, N2 / 0 / 5, N3 / 2 / 2, N4 / 0 / 3, N5 / 3 / 4. For example: N1 / 2 / 4 means: there are 2 allocated backup groups corresponding to N6 on the N1 node, and there are 4 loads on the N1 node.

[0173] See also Figure 8 , there are 4 loads on the N1 node, of which the 2 shaded ones are the allocated backup groups corresponding to N6. There are 5 loads on the N2 node, and there is no allocated backup group corresponding to N6. There are 2 loads on the N3 node, both of which are the allocated backup groups corresponding to N6. There are 3 loads on the N4 node, and there is no allocated backup group corresponding to N6. There are 4 loads on the N5 node, of which the 3 shaded ones are the allocated backup groups corresponding to N6.

[0174] First, sort N1-N5 according to the first layer, that is, sort N1-N5 according to the number of allocated backup groups corresponding to N6 contained in it, from small to large, and then there is a sequence: [N2 / 0 / 5, N4 / 0 / 3, N1 / 2 / 4, N3 / 2 / 2, N5 / 3 / 4]. The bold numbers are the basis for sorting. The first layer sorting can prevent the backup groups corresponding to the same node from being concentrated on one device.

[0175] Then group N1-N5 according to the second level. N2 and N4, which have 0 assigned backup groups, are classified into the first level, N1 and N3, which have 2 assigned backup groups, are classified into the second level, and N5 is the third level. For details, see Fig. 9 .

[0176] In any level, the nodes are arranged in ascending order according to the total load. The first level corresponds to the ordered sequence: [N4 / 0 / 3, N2 / 0 / 5]; the second level corresponds to the ordered sequence: [N3 / 2 / 2, N1 / 2 / 4]; the third level corresponds to the ordered sequence: [N5 / 3 / 4]. The bold numbers are the basis for arrangement. The second-level sorting can avoid uneven load numbers on each node after a single node goes offline. Fig.10 shown.

[0177] Assume that there are 5 backup groups to be assigned to N6: F1, F2, F3, F4, and F5. Then first assign one backup group to be assigned to N4 and N2 respectively. Assume that F1 is assigned to N4 and F2 is assigned to N2. After the round of assignment is completed, N4 is changed to N4 / 1 / 4 and N2 is changed to N2 / 1 / 6. For details, please refer to Fig.11 .

[0178] At this time, N1-N5 are processed according to the first-level sorting and the second-level sorting, so as to redetermine the nodes belonging to the first level, and then F3, F4, and F5 are allocated to the nodes in the newly determined first level.

[0179] In this example, the nodes belonging to the first level next time are still: N4 and N2, so F3 is allocated to N4, and F4 is allocated to N2. After the allocation, N4 is changed to N4 / 2 / 5, and N2 is changed to N2 / 2 / 7.

[0180] Based on this, the nodes belonging to the first level next time are: N3 / 2 / 2, N1 / 2 / 4, N4 / 2 / 5, N2 / 2 / 7, so F5 is assigned to N3. Finally, the load situation on each node is: N3 / 3 / 3, N1 / 2 / 4, N4 / 2 / 5, N2 / 2 / 7, N5 / 3 / 2.

[0181] According to the above example, continue to allocate the backup groups to be allocated corresponding to other nodes until the list of backup groups to be allocated is completed.

[0182] According to this embodiment, by balancing the load on each node, the difference in the number of loads on different nodes can be no more than 1. After the backup group and the traffic group are sorted together and balanced, the actual load on each node (i.e., the traffic group or backup group that is running the virtual service) can be balanced after the node is offline. At this time, the total load number on each node may not be balanced, because the node with fewer traffic groups will preferentially receive the backup groups of other nodes, and the final total load number will be larger.

[0183] It can be seen that this embodiment can dynamically adjust the pressure of each node (the node is a virtualized node) according to the actual traffic pressure, and can ensure automatic switching to the appropriate node in case of business failure or load node failure, and can also ensure traffic balance, avoid abnormalities caused by overload of a certain node, and ensure business continuity. Therefore, this embodiment can achieve balanced distribution of business traffic among multiple nodes. When a certain node is abnormal, the traffic can be automatically migrated to other nodes to ensure that business operations are not affected, while meeting the requirements of traffic balance between nodes.

[0184] The "first", "second", "third", "fourth", etc. (if any) referred to in this application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods or devices.

[0185] It should be noted that the descriptions involving "first", "second", etc. in this application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0186] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0187] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of readable storage medium known in the art.

[0188] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A load balancing method, characterized in that: include: Determine multiple nodes that can carry traffic groups and multiple traffic groups to be allocated; After the multiple traffic groups are evenly distributed to the multiple nodes, a backup group is created for each traffic group to obtain multiple backup groups; The backup group to be allocated corresponding to any node is evenly allocated to other nodes, so that the load of each node is balanced and any flow group and the backup group corresponding to the flow group are not in the same node; the backup group to be allocated is: the backup group corresponding to the flow group in the node and not allocated to other nodes; The method of evenly distributing the backup group to be allocated corresponding to any node to other nodes so that the load of each node is balanced and any flow group and the backup group corresponding to the flow group are not in the same node includes: For any target node, other nodes including the same number of allocated backup groups are divided into one class to obtain at least one class; the allocated backup groups are: backup groups corresponding to the traffic group in the target node and allocated to other nodes; Determine the class that includes the least number of allocated backup groups as the target class; If the total number of nodes included in the target class is equal to the total number of backup groups to be allocated corresponding to the target node, the backup groups to be allocated corresponding to the target node are evenly allocated to each node included in the target class.

2. The method according to claim 1, characterized in that The balancing the distribution of the plurality of traffic groups to the plurality of nodes comprises: If the total number of traffic groups is an integer multiple of the total number of nodes, traffic groups are evenly distributed to each node.

3. The method according to claim 1, characterized in that The balancing the distribution of the plurality of traffic groups to the plurality of nodes comprises: If the total number of traffic groups is not an integer multiple of the total number of nodes, then when the total number of nodes is greater than the total number of traffic groups, a traffic group is assigned to each node, and nodes that are not assigned to a traffic group are deleted.

4. The method according to claim 1, characterized in that: The balancing the distribution of the plurality of traffic groups to the plurality of nodes comprises: If the total number of traffic groups is not an integer multiple of the total number of nodes, then when the total number of nodes is less than the total number of traffic groups, after evenly allocating an equal number of traffic groups to each node, optional nodes are randomly selected from all nodes, and the remaining unallocated traffic groups are evenly distributed to the optional nodes.

5. The method according to claim 1, characterized in that Also includes: If the total number of nodes included in the target class is greater than the total number of backup groups to be allocated corresponding to the target node, the nodes included in the target class are arranged in ascending order according to the total number of loads to obtain a node sequence; the total number of loads is: the total number of backup groups and traffic groups in any node; Starting from the first position of the node sequence, a backup group to be allocated is allocated to a node until all the backup groups to be allocated corresponding to the target node are allocated.

6. The method according to claim 1, characterized in that Also includes: If the total number of nodes included in the target class is less than the total number of backup groups to be allocated corresponding to the target nodes, then after allocating a backup group to be allocated to each node included in the target class, the step of dividing other nodes with the same number of allocated backup groups into one class to obtain at least one class is performed; and the class with the least number of allocated backup groups is determined as the target class.

7. The method according to any one of claims 1 to 6, characterized in that: After the backup group to be allocated corresponding to any node is evenly allocated to other nodes, the method further includes: If the total loads in different nodes are not equal, the flow groups and backup groups in each node are migrated according to preset rules; the total load is: the total number of backup groups and flow groups in any node.

8. The method according to claim 7, characterized in that The migrating of the traffic group and the backup group in each node according to the preset rules includes: The node with the largest total load among all nodes is determined as the maximum node, and the node with the smallest total load is determined as the minimum node; Migrate any backup group or any flow group in the maximum node to the minimum node; wherein the flow group corresponding to any migrated backup group is not in the minimum node, and the backup group corresponding to any migrated flow group is not in the minimum node; If after the migration, the difference between the total loads in the maximum node and the minimum node is 1, the migration ends.

9. The method according to claim 8, characterized in that Also includes: If after migration, the difference between the total loads in the maximum node and the minimum node is not 1, then execute the steps of determining the node with the largest total load among all nodes as the maximum node, and determining the node with the least total load as the minimum node; and migrating any backup group or any traffic group in the maximum node to the minimum node.

10. The method according to any one of claims 1 to 6, characterized in that: Also includes: If any node fails, all flow groups in the failed node are determined as failed flow groups, and the failed flow groups are replaced by backup groups corresponding to the failed flow groups in other nodes.

11. The method according to any one of claims 1 to 6, characterized in that: Also includes: If any node fails, the node with the least total load is selected from all nodes that have not failed as the minimum node; the total load is: the total number of backup groups and flow groups in any node; Migrate any backup group or any flow group in the failed node to the minimum node; wherein the flow group corresponding to any migrated backup group is not in the minimum node, and the backup group corresponding to any migrated flow group is not in the minimum node.

12. The method according to claim 11, characterized in that Also includes: If there are backup groups or traffic groups that have not been migrated in the failed node, the steps of selecting the node with the least total load from all nodes that have not failed as the minimum node; and migrating any backup group or any traffic group in the failed node to the minimum node are performed.

13. A load balancing device, characterized in that: include: A determination module, used to determine multiple nodes that can carry traffic groups and multiple traffic groups to be allocated; A flow group allocation module, configured to create a backup group for each flow group after evenly allocating the multiple flow groups to the multiple nodes, thereby obtaining multiple backup groups; The backup group allocation module is used to evenly allocate the backup group to be allocated corresponding to any node to other nodes, so that the load of each node is balanced and any flow group and the backup group corresponding to the flow group are not in the same node; The backup group to be allocated is: a backup group corresponding to the traffic group in the node and not allocated to other nodes; Wherein, the backup group allocation module includes: A division unit is used to divide other nodes including the same number of allocated backup groups into one class for any target node, so as to obtain at least one class; the allocated backup groups are backup groups corresponding to the traffic groups in the target node and allocated to other nodes; A determination unit, configured to determine the class including the least number of allocated backup groups as the target class; The first allocation unit is configured to evenly allocate the backup groups to be allocated corresponding to the target nodes to each node included in the target class if the total number of nodes included in the target class is equal to the total number of backup groups to be allocated corresponding to the target nodes.

14. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the load balancing method according to any one of claims 1 to 12.

15. A readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the load balancing method according to any one of claims 1 to 12 is implemented.

Citation Information

Patent Citations

  • Method and device for realizing multiple backups of multiple flow groups in high-availability cluster system

    CN105141445A

  • Multi-cloud security storage dynamic balance backup method and system

    CN108733516A

  • Virtual IP balanced distribution method and system, terminal and storage medium

    CN111866210A

  • MQ load balancing method, device and equipment and storage medium

    CN112346892A