A load balancing method and device
By adjusting the number of task sets and attribute divisions that a node can handle when cluster nodes change, the problems of uneven task set distribution and large load migration are solved, thus achieving load balancing and data continuity.
Patent Information
- Application Number
- CN202110922920.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-12
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2041-08-12
AI Technical Summary
In existing technologies, uneven distribution of task sets and large load migration during dynamic load adjustment lead to unbalanced task scheduling and data continuity issues.
When a change in the number of cluster nodes is detected, the quotient d and remainder n are obtained by dividing the current number of task sets by the current number of nodes. The number of task sets that each node can support is adjusted so that the n nodes with the largest number of task sets are d+1 and the other nodes are d. The task sets are then distributed to the nodes in a round-robin manner. The task attributes are combined to divide and adjust the queues to reduce the amount of migration.
It achieves uniform distribution of task sets and minimal task migration during dynamic load adjustment, ensuring the continuity and consistency of data acquisition tasks.
Smart Images

Figure CN113778618B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data acquisition technology, and in particular to a load balancing method and apparatus. Background Technology
[0002] In a cluster, task scheduling and dynamic load are unavoidable issues. In operation and maintenance scenarios, data collection tasks not only need to achieve balanced task distribution and dynamic load, but also need to load tasks with the same collection objects onto the same collector as much as possible to reuse collection connections. Furthermore, under dynamic load, task adjustments should be minimized to ensure the continuity of collection tasks and data continuity.
[0003] Currently, a consistent hashing algorithm is used to distribute load across different nodes. However, since the hash key is always an IP address, the hash's dispersion is not high enough, resulting in uneven distribution. For example, there might be situations where a certain range of IP addresses has their load hash value on one node, while other nodes do not distribute any load.
[0004] Furthermore, when dynamic load is redistributed via hash, since the number of tasks corresponding to each IP is not fixed, a task set with a large number of tasks may be subject to load migration. Summary of the Invention
[0005] This application provides a load balancing method and apparatus to solve the problems of uneven distribution of task sets and large load migration during dynamic adjustment in the prior art.
[0006] Firstly, this application provides a load balancing method applied to a load balancing system, the method comprising:
[0007] When a change in the number of cluster nodes is detected, the current number of task sets is divided by the current number of nodes to obtain the quotient d and the remainder n;
[0008] Set the number of task sets that can be carried by the n first-type nodes with the largest number of task sets currently being carried to d+1, and set the number of task sets that can be carried by the second-type nodes other than the first-type nodes to d.
[0009] Adjust the current task set of each node so that the current task set of each node is equal to the corresponding number of task sets it can support.
[0010] Optionally, the method further includes:
[0011] Based on the attributes of each task, tasks with the same attribute are grouped into the same task set;
[0012] The task sets are distributed to the nodes in the cluster using a round-robin method.
[0013] Optionally, the step of setting the number of task sets that can be carried by the n first-type nodes with the largest number of currently carried task sets to d+1, and setting the number of task sets that can be carried by the second-type nodes other than the first-type nodes to d, includes:
[0014] Based on the number of tasks currently being carried by each node, the nodes are sorted in a forward order to obtain a node set P. The first n nodes in node set P are designated as first-type nodes, and the number of tasks that the first-type nodes can carry is set to d+1. The other nodes besides the first n nodes are designated as second-type nodes, and the number of tasks that the second-type nodes can carry is set to d; or...
[0015] Based on the number of task sets currently carried by each node, the nodes are sorted in reverse order to obtain a node set Q. The last n nodes in the node set Q are designated as first-type nodes, and the number of task sets that the first-type nodes can carry is set to d+1. The other nodes besides the last n nodes are designated as second-type nodes, and the number of task sets that the second-type nodes can carry is set to d.
[0016] Optionally, the step of adjusting the current task set carried by each node so that the number of current task sets carried by each node is equal to the number of corresponding task sets it can carry includes:
[0017] Calculate the difference G between the number of task sets currently carried by each node and the number of task sets it can carry. If the difference G1 for a node is greater than 0, add the G1 task sets currently carried by that node to a preset queue. If the difference G2 for a node is less than 0, adjust the G2 task sets in the preset queue to the task sets currently carried by that node.
[0018] Optionally, the step of adding the G1 sets of tasks currently carried by the node to a preset queue includes:
[0019] Add the G1 task sets with the fewest tasks currently being handled by the node to the preset queue.
[0020] Secondly, this application provides a load balancing device for use in a load balancing system, the device comprising:
[0021] The detection unit is used to divide the current task set number by the current node number to obtain the quotient d and remainder n when a change in the number of cluster nodes is detected.
[0022] The setting unit is used to set the number of task sets that can be carried by the n first-type nodes with the largest number of task sets currently being carried to d+1, and to set the number of task sets that can be carried by the second-type nodes other than the first-type nodes to d.
[0023] The adjustment unit is used to adjust the current task set carried by each node so that the number of current task sets carried by each node is equal to the number of corresponding task sets that it can carry.
[0024] Optionally, the device further includes:
[0025] A partitioning unit is used to group tasks with the same attribute into the same task set based on the attributes of each task.
[0026] The allocation unit is used to distribute each task set to each node in the cluster using a round-robin method.
[0027] Optionally, when the number of task sets that can be carried by the n first-type nodes with the largest number of currently carried task sets is set to d+1, and the number of task sets that can be carried by the second-type nodes other than the first-type nodes is set to d, the setting unit is specifically used for:
[0028] Based on the number of tasks currently being carried by each node, the nodes are sorted in a forward order to obtain a node set P. The first n nodes in node set P are designated as first-type nodes, and the number of tasks that the first-type nodes can carry is set to d+1. The other nodes besides the first n nodes are designated as second-type nodes, and the number of tasks that the second-type nodes can carry is set to d; or...
[0029] Based on the number of task sets currently carried by each node, the nodes are sorted in reverse order to obtain a node set Q. The last n nodes in the node set Q are designated as first-type nodes, and the number of task sets that the first-type nodes can carry is set to d+1. The other nodes besides the last n nodes are designated as second-type nodes, and the number of task sets that the second-type nodes can carry is set to d.
[0030] Optionally, when adjusting the current task set carried by each node so that the number of current task sets carried by each node is equal to the number of corresponding task sets it can carry, the adjustment unit is specifically used for:
[0031] Calculate the difference G between the number of task sets currently carried by each node and the number of task sets it can carry. If the difference G1 for a node is greater than 0, add the G1 task sets currently carried by that node to a preset queue. If the difference G2 for a node is less than 0, adjust the G2 task sets in the preset queue to the task sets currently carried by that node.
[0032] Optionally, when adding the G1 sets of tasks currently carried by the node to a preset queue, the adjustment unit is specifically used for:
[0033] Add the G1 task sets with the fewest tasks currently being handled by the node to the preset queue.
[0034] Thirdly, embodiments of this application provide a load balancing device, which includes:
[0035] Memory, used to store program instructions;
[0036] A processor is configured to invoke program instructions stored in the memory and execute the steps of the method as described in any one of the first aspects above, according to the obtained program instructions.
[0037] Fourthly, embodiments of this application also provide a computer-readable storage medium storing computer-executable instructions for causing a computer to perform the steps of the method as described in any of the first aspects above.
[0038] In summary, the load balancing method provided in this application embodiment is applied to a load balancing system. The method includes: when a change in the number of cluster nodes is detected, dividing the current number of task sets by the current number of nodes to obtain a quotient d and a remainder n; setting the number of task sets that can be carried by the n first-type nodes with the largest number of task sets currently carried to d+1, and setting the number of task sets that can be carried by the second-type nodes other than the first-type nodes to d; adjusting the task sets currently carried by each node so that the number of task sets currently carried by each node is equal to its corresponding number of task sets that can be carried.
[0039] The load balancing method provided in this application embodiment determines the number of task sets that each node can support during dynamic adjustment based on the total number of currently supported service sets and the number of currently supported task sets. Nodes with a larger number of currently supported task sets can support a larger number of task sets, thus reducing the overall number of service sets that need to be migrated and adjusted. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments of this application or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings of the embodiments of this application.
[0041] Figure 1 A detailed flowchart of a load balancing method provided in an embodiment of this application;
[0042] Figure 2 This is a schematic diagram of the structure of a load balancing device provided in an embodiment of this application;
[0043] Figure 3 This is a schematic diagram of another load balancing device provided in an embodiment of this application. Detailed Implementation
[0044] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the application. The singular forms “a,” “the,” and “the” as used in this application and claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to any and all possible combinations comprising one or more of the associated listed items.
[0045] It should be understood that although the terms first, second, third, etc., may be used to describe various information in embodiments of this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" may also be interpreted as "when," "when," or "in response to a determination."
[0046] For example, see Figure 1 The diagram shown is a detailed flowchart of a load balancing method provided in an embodiment of this application. The method includes the following steps:
[0047] Step 100: When a change in the number of cluster nodes is detected, divide the current number of task sets by the current number of nodes to obtain the quotient d and the remainder n.
[0048] In this embodiment of the application, before performing step 100, the above-mentioned load balancing method may further include the following steps: based on the attributes of each task, tasks with the same attribute are divided into the same task set; and each task set is allocated to each node in the cluster using a round-robin method.
[0049] This involves pre-classifying tasks based on target attributes, grouping tasks with the same target attribute into the same task set. For example, in a data acquisition scenario, if the target attribute could be the IP address of the acquisition device, then tasks can be classified based on the IP address of the device being acquired. Tasks involving the same acquisition device are grouped into the same task set.
[0050] For example, suppose the load data acquisition cluster consists of 3 nodes. Task A (IP: 192.167.2.2) is assigned to node 1, task B (IP: 192.167.2.3) to node 2, task C (IP: 192.167.2.3) to node 2, task D (IP: 192.167.2.4) to node 3, task E (IP: 192.167.2.5) to node 1, task F (IP: 192.167.2.4) to node 3, and task G (IP: 192.167.2.4) to node 3. After assignment, the task status of each node is as follows:
[0051] Node 1 currently hosts two task sets: Task set 1 (IP: 192.167.2.2) includes task A, and Task set 2 (IP: 192.167.2.5) includes task E.
[0052] Node 2 currently hosts one task set, and task set 3 (IP: 192.167.2.3) includes task B and task C;
[0053] Node 3 currently hosts one task set. Task set 4 (IP: 192.167.2.4) includes task D, task F, and task G.
[0054] Therefore, when a node is added or removed in the cluster, dynamic load balancing of the task set needs to be triggered. Specifically, if a node is added to the cluster, a portion of the task set currently carried by other nodes needs to be migrated to the new node. If a node is removed from the cluster, all the task set currently carried by the removed node needs to be migrated to other nodes.
[0055] If nodes are added or removed from the cluster, determine the current number of nodes m and the total number of task sets t currently being carried by the nodes. Divide t by m to obtain the quotient d and the remainder n. In other words, theoretically, after each node in the cluster carries d task sets, there are still n task sets that have not been carried by any node. At this point, n nodes need to be selected, and each of the n nodes carries one of the uncarried task sets.
[0056] Step 110: Set the number of task sets that can be carried by the n first-type nodes with the largest number of task sets currently being carried to d+1, and set the number of task sets that can be carried by the second-type nodes other than the first-type nodes to d.
[0057] In this embodiment of the application, as can be seen from the above, through theoretical calculation, some nodes need to carry d+1 task sets, and some nodes need to carry d task sets. Since each node already carries a corresponding number of task sets, in order to reduce the number of task sets that need to be migrated, the number of task sets that the n nodes with the largest number of task sets currently carried can be set to d+1, while the number of task sets that other nodes (nodes with smaller number of task sets currently carried) can be set to d.
[0058] Specifically, when setting the number of task sets that the n first-type nodes with the largest number of currently carried task sets to be d+1, and setting the number of task sets that the second-type nodes other than the first-type nodes to be d, a preferred implementation is to perform forward sorting on each node based on the number of task sets it currently carries, to obtain a node set P. The first n nodes in the node set P are designated as first-type nodes, and the number of task sets that the first-type nodes can carry is set to d+1. The other nodes other than the first n nodes are designated as second-type nodes, and the number of task sets that the second-type nodes can carry is set to d.
[0059] That is, based on the number of task sets currently carried by each node, the nodes are sorted, and the node with the largest number of task sets currently carried is taken as the first node of set P, the node with the second largest number of task sets currently carried is taken as the second node of set P, and so on, and the node with the smallest number of task sets currently carried is taken as the last node of set P.
[0060] Specifically, when setting the number of task sets that the n first-type nodes with the largest number of currently carried task sets to be d+1, and setting the number of task sets that the second-type nodes other than the first-type nodes to be d, another preferred implementation is to perform reverse sorting on each node based on the number of task sets currently carried by each node to obtain a node set Q. The last n nodes in the node set Q are taken as first-type nodes, and the number of task sets that the first-type nodes can carry is set to d+1. The other nodes other than the last n nodes are taken as second-type nodes, and the number of task sets that the second-type nodes can carry is set to d.
[0061] That is, based on the number of task sets currently carried by each node, the nodes are sorted, and the node with the smallest number of task sets currently carried is taken as the first node of set P, the node with the second smallest number of task sets currently carried is taken as the second node of set P, and so on, and the node with the largest number of task sets currently carried is taken as the last node of set P.
[0062] Step 120: Adjust the current task set carried by each node so that the current task set carried by each node is equal to the corresponding number of task sets it can carry.
[0063] Specifically, in this embodiment of the application, when adjusting the current task set carried by each node so that the number of current task sets carried by each node is equal to the number of corresponding task sets that can be carried, a preferred implementation is to calculate the difference G between the number of current task sets carried by each node and the number of corresponding task sets that can be carried. If the difference G1 corresponding to a node is greater than 0, then the G1 task sets currently carried by that node are added to a preset queue. If the difference G2 corresponding to a node is less than 0, then the G2 task sets in the preset queue are adjusted to the task sets currently carried by that node.
[0064] In other words, a task queue R is pre-built. If node 1 currently carries 7 task sets and its corresponding number of available task sets is 5, then two task sets currently carried by node 1 need to be added to task queue R. At this time, the number of task sets currently carried by node 1 changes from 7 to 5. If node 3 currently carries 4 task sets and its corresponding number of available task sets is 5, then one task set in task queue R is added to node 1, and node 1 carries that one task set.
[0065] Of course, if the number of tasks a node is currently carrying is equal to the number of tasks it can carry, then there is no need to adjust the number of tasks it is currently carrying.
[0066] Furthermore, when adding the G1 sets of tasks currently carried by the node to the preset queue, a preferred implementation is to add the G1 sets of tasks with the fewest tasks from the current set of tasks carried by the node to the preset queue.
[0067] Since each task set contains a different number of tasks, in order to further reduce the amount of task migration during the load balancing process, when it is determined that at least one task set needs to be migrated from a node, at least one task set with the fewest tasks is added to a preset queue R based on the number of tasks included in each task set.
[0068] For example, suppose we need to migrate two task sets from node 1. Currently, task set 1 and task set 2 on node 1 each contain only one task, while other task sets each contain at least two tasks. In this case, task set 1 and task set 2 can be added to a preset queue R, thus minimizing the number of tasks that need to be migrated.
[0069] Based on the same inventive concept as the above-described embodiments, see, for example, the following: Figure 2The diagram shown is a structural schematic of a load balancing device provided in an embodiment of this application. The device includes:
[0070] The detection unit 20 is used to divide the current task set number by the current number of nodes to obtain the quotient d and the remainder n when a change in the number of cluster nodes is detected.
[0071] Setting unit 21 is used to set the number of task sets that can be carried by the n first-type nodes with the largest number of task sets currently carried to d+1, and set the number of task sets that can be carried by the second-type nodes other than the first-type nodes to d.
[0072] The adjustment unit 22 is used to adjust the current task set carried by each node so that the number of current task sets carried by each node is equal to the number of corresponding task sets that can be carried.
[0073] Optionally, the device further includes:
[0074] A partitioning unit is used to group tasks with the same attribute into the same task set based on the attributes of each task.
[0075] The allocation unit is used to distribute each task set to each node in the cluster using a round-robin method.
[0076] Optionally, when the number of task sets that can be carried by the n first-type nodes with the largest number of currently carried task sets is set to d+1, and the number of task sets that can be carried by the second-type nodes other than the first-type nodes is set to d, the setting unit 21 is specifically used for:
[0077] Based on the number of tasks currently being carried by each node, the nodes are sorted in a forward order to obtain a node set P. The first n nodes in node set P are designated as first-type nodes, and the number of tasks that the first-type nodes can carry is set to d+1. The other nodes besides the first n nodes are designated as second-type nodes, and the number of tasks that the second-type nodes can carry is set to d; or...
[0078] Based on the number of task sets currently carried by each node, the nodes are sorted in reverse order to obtain a node set Q. The last n nodes in the node set Q are designated as first-type nodes, and the number of task sets that the first-type nodes can carry is set to d+1. The other nodes besides the last n nodes are designated as second-type nodes, and the number of task sets that the second-type nodes can carry is set to d.
[0079] Optionally, when adjusting the current task set carried by each node so that the number of current task sets carried by each node is equal to the number of corresponding task sets it can carry, the adjustment unit 22 is specifically used for:
[0080] Calculate the difference G between the number of task sets currently carried by each node and the number of task sets it can carry. If the difference G1 for a node is greater than 0, add the G1 task sets currently carried by that node to a preset queue. If the difference G2 for a node is less than 0, adjust the G2 task sets in the preset queue to the task sets currently carried by that node.
[0081] Optionally, when adding the G1 sets of tasks currently carried by the node to a preset queue, the adjustment unit 22 is specifically used for:
[0082] Add the G1 task sets with the fewest tasks currently being handled by the node to the preset queue.
[0083] These units can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more digital signal processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, when one of these units is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these units can be integrated together to form a system-on-a-chip (SOC).
[0084] Furthermore, regarding the load balancing device provided in this application embodiment, from a hardware perspective, the hardware architecture diagram of the load balancing device can be found in [reference needed]. Figure 3 As shown, the load balancing device may include: a memory 30 and a processor 31.
[0085] The memory 30 is used to store program instructions; the processor 31 calls the program instructions stored in the memory 30 and executes the above method embodiment according to the obtained program instructions. The specific implementation method and technical effect are similar, and will not be described again here.
[0086] Optionally, this application also provides a load balancing device, including at least one processing element (or chip) for performing the above method embodiments.
[0087] Optionally, this application also provides a program product, such as a computer-readable storage medium storing computer-executable instructions for causing the computer to perform the above-described method embodiments.
[0088] Here, a machine-readable storage medium can be any electronic, magnetic, optical, or other physical storage device that can contain or store information, such as executable instructions, data, etc. For example, a machine-readable storage medium can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or combinations thereof.
[0089] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.
[0090] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.
[0091] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0092] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0093] Furthermore, these computer program instructions can also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in the process. Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0094] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0095] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A load balancing method, characterized in that, Applied to a load balancing system, the method includes: When a change in the number of cluster nodes is detected, the current number of task sets is divided by the current number of nodes to obtain the quotient d and the remainder n; Set the number of task sets that can be carried by the n first-type nodes with the largest number of task sets currently being carried to d+1, and set the number of task sets that can be carried by the second-type nodes other than the first-type nodes to d. Adjust the current task set carried by each node so that the current task set carried by each node is equal to the corresponding number of task sets it can carry. The steps to adjust the current task set carried by each node so that the number of tasks carried by each node is equal to the number of tasks it can carry include: Calculate the difference G between the number of task sets currently carried by each node and the number of task sets it can carry. If the difference G1 for a node is greater than 0, add the G1 task sets currently carried by that node to a preset queue. If the difference G2 for a node is less than 0, adjust the G2 task sets in the preset queue to the task sets currently carried by that node. The steps to add the set of G1 tasks currently being carried by the node to the preset queue include: Add the G1 task sets with the fewest tasks currently being handled by the node to the preset queue.
2. The method as described in claim 1, characterized in that, The method further includes: Based on the attributes of each task, tasks with the same attribute are grouped into the same task set; The task sets are distributed to the nodes in the cluster using a round-robin method.
3. The method as described in claim 1, characterized in that, The steps of setting the number of tasks that can be carried by the n first-type nodes with the largest number of currently carried tasks to d+1, and setting the number of tasks that can be carried by the second-type nodes (excluding the first-type nodes) to d, include: Based on the number of tasks currently being carried by each node, the nodes are sorted in a forward order to obtain a node set P. The first n nodes in node set P are designated as first-type nodes, and the number of tasks that the first-type nodes can carry is set to d+1. The other nodes besides the first n nodes are designated as second-type nodes, and the number of tasks that the second-type nodes can carry is set to d; or... Based on the number of task sets currently carried by each node, the nodes are sorted in reverse order to obtain a node set Q. The last n nodes in the node set Q are designated as first-type nodes, and the number of task sets that the first-type nodes can carry is set to d+1. The other nodes besides the last n nodes are designated as second-type nodes, and the number of task sets that the second-type nodes can carry is set to d.
4. A load balancing device, characterized in that, The device, used in a load balancing system, includes: The detection unit is used to divide the current task set number by the current node number to obtain the quotient d and remainder n when a change in the number of cluster nodes is detected. The setting unit is used to set the number of task sets that can be carried by the n first-type nodes with the largest number of task sets currently being carried to d+1, and to set the number of task sets that can be carried by the second-type nodes other than the first-type nodes to d. The adjustment unit is used to adjust the current task set carried by each node so that the number of current task sets carried by each node is equal to the number of corresponding task sets that it can carry. When adjusting the current task set carried by each node so that the number of current task sets carried by each node is equal to the number of corresponding task sets it can carry, the adjustment unit is specifically used for: Calculate the difference G between the number of task sets currently carried by each node and the number of task sets it can carry. If the difference G1 for a node is greater than 0, add the G1 task sets currently carried by that node to a preset queue. If the difference G2 for a node is less than 0, adjust the G2 task sets in the preset queue to the task sets currently carried by that node. When adding the set of G1 tasks currently carried by the node to a preset queue, the adjustment unit is specifically used for: Add the G1 task sets with the fewest tasks currently being handled by the node to the preset queue.
5. The apparatus as described in claim 4, characterized in that, The device further includes: A partitioning unit is used to group tasks with the same attribute into the same task set based on the attributes of each task. The allocation unit is used to distribute each task set to each node in the cluster using a round-robin method.
6. The apparatus as claimed in claim 4, characterized in that, When setting the number of task sets that the n first-type nodes with the largest number of currently carried task sets can carry to d+1, and setting the number of task sets that the second-type nodes (excluding the first-type nodes) can carry to d, the setting unit is specifically used for: Based on the number of tasks currently being carried by each node, the nodes are sorted in a forward order to obtain a node set P. The first n nodes in node set P are designated as first-type nodes, and the number of tasks that the first-type nodes can carry is set to d+1. The other nodes besides the first n nodes are designated as second-type nodes, and the number of tasks that the second-type nodes can carry is set to d; or... Based on the number of task sets currently carried by each node, the nodes are sorted in reverse order to obtain a node set Q. The last n nodes in the node set Q are designated as first-type nodes, and the number of task sets that the first-type nodes can carry is set to d+1. The other nodes besides the last n nodes are designated as second-type nodes, and the number of task sets that the second-type nodes can carry is set to d.
Citation Information
Patent Citations
Dynamic load balancing method of trunking system based on task immigration
CN104615498A
Distributed load balancing method and device
CN104702691A
Resource load balancing control method and cluster scheduler
CN108009016A