Task Allocation Method, Device, Equipment and Medium
By acquiring the protocol processing time and hardware resources of the execution node, determining the target weight and distributing tasks, the problem of unreasonable task allocation caused by single dimensions in the prior art is solved, and the task processing efficiency is improved.
Patent Information
- Application Number
- CN202211000578.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-19
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2042-08-19
AI Technical Summary
In load balancing, the prior art only uses weights to allocate from the hardware usage of nodes, and the dimensions are single, resulting in poor rationality and low efficiency of task allocation.
By obtaining the protocol processing of multiple protocols supported by multiple execution nodes, the target protocol weights and target node weights are determined, and tasks are allocated based on these weights to ensure the rationality of the task issuance order.
It realizes comprehensive adjustment of task allocation from two dimensions: protocol processing time and node hardware resources, improving the rationality and processing efficiency of task allocation.
Smart Images

Figure CN115309532B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular, to a task allocation method, apparatus, device, and medium. Background Art
[0002] Load balancing refers to balancing multiple loads (i.e., tasks) and distributing them to multiple nodes for processing. Thus, through load balancing technology, the situation where each node has no task to process and the situation of task backlog can be reduced, and the collaborative processing ability of multiple nodes for tasks can be improved.
[0003] In the related art, the weights of each node can be adjusted according to the hardware usage rate of each node, and thus load balancing processing can be performed based on the weights. However, when task allocation is performed based on this solution, the weights are only allocated from the hardware aspect of the nodes, and the reference dimension is relatively single. Therefore, the rationality of the allocation is poor, and the efficiency of task processing is low. Summary of the Invention
[0004] To solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a task allocation method, apparatus, device, and medium.
[0005] An embodiment of the present disclosure provides a task allocation method, which is applied to a control node, and the method includes:
[0006] Obtaining the protocol processing time consumption of multiple protocols supported by multiple execution nodes;
[0007] Determining a target protocol weight according to the protocol processing time consumption of each protocol;
[0008] Extracting multiple tasks to be allocated based on the target protocol weights of the protocols, and determining the extraction order as the task distribution order;
[0009] Determining the target node weights of the execution nodes;
[0010] Allocating the multiple tasks to be allocated to the execution nodes based on the target node weights and the task distribution order.
[0011] An embodiment of the present disclosure further provides a task allocation apparatus, which is applied to a control node, and the apparatus includes:
[0012] An obtaining module, configured to obtain the protocol processing time consumption of multiple protocols supported by multiple execution nodes;
[0013] A first determining module, configured to determine a target protocol weight according to the protocol processing time consumption of each protocol;
[0014] An extraction module, configured to extract a plurality of tasks to be assigned based on the target protocol weights of the respective protocols, and determine the extraction order as the task distribution order;
[0015] A second determination module, configured to determine the target node weights of the respective execution nodes;
[0016] An assignment module, configured to assign the plurality of tasks to be assigned to the respective execution nodes based on the target node weights and the task distribution order.
[0017] An embodiment of the present disclosure further provides an electronic device, including: a processor; a memory for storing executable instructions of the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the task assignment method provided by the embodiment of the present disclosure.
[0018] An embodiment of the present disclosure further provides a computer-readable storage medium, storing a computer program, where the computer program is used to execute the task assignment method provided by the embodiment of the present disclosure.
[0019] The technical solution provided by the embodiment of the present disclosure has the following advantages compared with the prior art: In the task assignment solution provided by the embodiment of the present disclosure, the protocol processing time taken by a plurality of protocols supported by a plurality of execution nodes is obtained; the target protocol weights are determined according to the protocol processing time taken by each protocol; a plurality of tasks to be assigned are extracted based on the target protocol weights of the respective protocols, and the extraction order is determined as the task distribution order; the target node weights of the respective execution nodes are determined; based on the target node weights and the task distribution order, the plurality of tasks to be assigned are assigned to the respective execution nodes. By adopting the above technical solution, the target protocol weights are generated based on the protocol processing time taken, and the task distribution order is determined according to the target protocol weights, so that the adjustment of task assignment can be carried out from the dimension of the protocol processing time taken, and the target node weights of the respective execution nodes are determined, so that the adjustment of task assignment can be carried out from the dimension of the nodes, realizing the multi-dimensional comprehensive adjustment in the whole process of task assignment, improving the rationality of task assignment, and making the task processing based on the task assignment more efficient. Description of the Drawings
[0020] The accompanying drawings here are incorporated into the description and form a part of this description, showing embodiments consistent with the present disclosure and used together with the description to explain the principles of the present disclosure.
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.
[0022] Figure 1 Schematic flowchart of a task allocation method provided by an embodiment of the present disclosure;
[0023] Figure 2 Schematic flowchart of another task allocation method provided by an embodiment of the present disclosure;
[0024] Figure 3 Schematic flowchart of yet another task allocation method provided by an embodiment of the present disclosure;
[0025] Figure 4 Schematic flowchart of yet another task allocation method provided by an embodiment of the present disclosure;
[0026] Figure 5 Schematic flowchart of yet another task allocation method provided by an embodiment of the present disclosure;
[0027] Figure 6 Schematic structural diagram of a task allocation device provided by an embodiment of the present disclosure;
[0028] Figure 7 Schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. Detailed implementation manners
[0029] In order to more clearly understand the above objects, features, and advantages of the present disclosure, the solutions of the present disclosure will be further described below. It should be noted that, without conflict, the embodiments of the present disclosure and the features in the embodiments may be combined with each other.
[0030] Many specific details are set forth in the following description in order to provide a thorough understanding of the present disclosure, but the present disclosure may be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only a part of the embodiments of the present disclosure, rather than all of the embodiments.
[0031] To solve the above problems, an embodiment of the present disclosure provides a task allocation method, which will be introduced below in combination with specific embodiments.
[0032] Figure 1 Schematic flowchart of a task allocation method provided by an embodiment of the present disclosure. This method can be executed by a task allocation device, where the device can be implemented by software and / or hardware and is generally integrated in an electronic device. As Figure 1 shown, the method includes:
[0033] Step 101, obtaining the protocol processing time consumption of multiple protocols supported by multiple execution nodes.
[0034] Among them, the execution node can be a functional node for executing tasks. Different execution nodes may have corresponding hardware configurations, so the processing capabilities of different execution nodes for tasks may be different. This embodiment does not limit the tasks executed by the execution node. For example, the task can be a data collection task.
[0035] The protocol can be a network protocol related to data transmission. This protocol can be related to the system of the interaction device that exchanges data with the execution node. For example, if the interaction device is a Linux system, the protocol can be the Secure Shell (SSH) protocol; if the interaction device is a Windows system, the protocol can be the Windows Management Instrumentation (WMI) protocol. It can be understood that the processing durations consumed by tasks corresponding to different protocols when executed on the same execution node may be different. For example, the time consumed by a task using the SSH protocol may be longer than the time consumed by a task using the WMI protocol. The protocol processing time consumption can be the average duration consumed by executing the task corresponding to the protocol. Since different execution nodes have corresponding task processing capabilities, and different tasks have corresponding processing durations, selecting appropriate tasks and allocating them to appropriate execution nodes is the key to realizing the rational utilization of the computing power of the execution node.
[0036] In this embodiment, for each protocol, multiple sampling tasks can be obtained by sampling multiple tasks included in the protocol. Determine the average time consumption for executing each sampling task, and use this average time consumption as the protocol processing time consumption of the protocol.
[0037] In some embodiments, obtaining the protocol processing time consumptions of multiple protocols supported by multiple execution nodes includes: obtaining the execution time consumptions of multiple tasks corresponding to a preset historical time period; classifying the tasks according to multiple protocols to obtain multiple task sets, where one task set includes at least one task, and the task sets and the protocols are in one-to-one correspondence; determining the average time consumption of the execution time consumptions of the multiple tasks included in each task set as the protocol processing time consumption of the protocol corresponding to each task set.
[0038] During the task assignment process, multiple rounds of task assignment can be performed according to a preset cycle. The task assignment method provided in this embodiment can be an implementation method for one round of task assignment. The preset cycle is the duration of one round of task assignment, and this preset cycle can be set according to user requirements, etc., and this embodiment does not limit it. For example, this preset cycle can be set to 5 minutes. The preset historical time period can be a time period before the current time point. This preset historical time period can be the time period corresponding to the previous round of task assignment, and the length of this preset historical time period can be the same as the duration of one round of task assignment. The execution time consumption can be the time length consumed by the execution node to complete the task. The task set can be a set including multiple tasks, and the tasks in the same task set belong to the same protocol.
[0039] In this embodiment, for a task in the protocol, the task assignment device can obtain the sending time when the task is sent to the execution node, and obtain the completion time when the execution node completes the task, and use the time interval between the sending time and the completion time as the execution time consumption of the task. Perform the above calculations for multiple tasks within the preset historical time period to obtain the execution time consumption of each task. Classify each task according to the protocol corresponding to the task, and assign the tasks using the same protocol to the same task set to obtain a task set corresponding to the protocol one by one. For each task set, calculate the average time consumption of the execution time consumption of each task included therein, and use this average time consumption as the protocol processing time consumption of the protocol corresponding to the task set.
[0040] For example, if the sending time is sendTime and the completion time is endTime, the execution time consumption of the task can be: (endTime - sendTime) / 1000, where the units of the sending time and the completion time are milliseconds, and the unit of the execution time consumption is seconds. Taking the Simple Network Management Protocol (SNMP) as an example, if the task set corresponding to the SNMP protocol includes a total of N tasks, SNMP_1, SNMP_2, ……, SNMP_N, then the protocol processing time consumption corresponding to the SNMP protocol can be: sum(time(SNMP_1), time(SNMP_1), …, time(SNMP_N)) / N, where the time() function represents obtaining the execution time consumption of the corresponding task, and the sum() function represents summing multiple time periods.
[0041] Step 102, determine the target protocol weight according to the protocol processing time consumption of each protocol.
[0042] Among them, the target protocol weight can be a parameter characterizing the importance of the corresponding protocol in the task assignment process.
[0043] In this embodiment, for each protocol, the time taken for processing the protocol can be used as the target protocol weight of the protocol. For example, if there are three protocols: the first protocol, the second protocol, and the third protocol, and the time taken for processing the first protocol is 1 second, the time taken for processing the second protocol is 2 seconds, and the time taken for processing the third protocol is 3 seconds, then the target protocol weight of the first protocol can be 1, the target protocol weight of the second protocol can be 2, and the target protocol weight of the third protocol can be 3.
[0044] In some embodiments, determining the target protocol weight according to the time taken for processing each protocol includes: for each protocol, determining the corresponding target protocol weight based on its historical protocol weight and the corresponding time taken for processing the protocol.
[0045] Among them, if there was a previous round of task allocation before the current round of task allocation, the target protocol weight in the previous round of task allocation can be used as the historical protocol weight in the current round of task allocation; if there was no previous round of task allocation before the current round of task allocation, that is, the current round of task allocation is the first round of task allocation, the historical protocol weight in the current round of task allocation can be preset. This embodiment does not limit the specific value of this historical protocol weight. For example, the historical protocol weights corresponding to each protocol can be the same, or the historical protocol weights corresponding to each protocol can be related to the number of tasks included in the protocol.
[0046] In this embodiment, for each protocol, the historical protocol weight of the protocol can be multiplied by the time taken for processing the protocol to obtain the target protocol weight corresponding to the protocol. For example, if there are three protocols: the first protocol, the second protocol, and the third protocol, the historical protocol weight of the first protocol is a, the historical protocol weight of the second protocol is b, the historical protocol weight of the third protocol is c, and the time taken for processing the first protocol is time_a, the time taken for processing the second protocol is time_b, and the time taken for processing the third protocol is time_c, then the target protocol weight of the first protocol is (a·time_a), the target protocol weight of the second protocol is (b·time_b), and the target protocol weight of the third protocol is (c·time_c).
[0047] Step 103: Extract multiple tasks to be allocated based on the target protocol weights of each protocol, and determine the extraction order as the task distribution order.
[0048] Among them, the task to be allocated can be a task determined from multiple tasks that needs to be allocated to an execution node for processing. There are multiple tasks to be allocated, and these multiple tasks to be allocated can be extracted sequentially. The extraction order can represent the sequence in which these multiple tasks to be allocated are extracted. The task distribution order can be the order in which multiple tasks to be allocated are distributed to the execution node, and this task distribution order can be consistent with the extraction order of the tasks to be allocated, that is, the task to be allocated that is extracted first is distributed to the execution node first.
[0049] In this embodiment, after determining the target protocol weights corresponding to each protocol, tasks corresponding to each protocol are extracted based on the target protocol weights. The extracted tasks are used as tasks to be allocated, and the extraction order of the tasks to be allocated is recorded, and this extraction order is used as the distribution order when distributing the tasks to be allocated to the execution node. Among them, the specific method for extracting tasks to be allocated according to the target protocol weights is not limited in this embodiment. For example, tasks to be allocated can be extracted based on a weighted round-robin algorithm.
[0050] Step 104, determine the target node weights of each execution node.
[0051] Among them, the target node weight can be a parameter representing the importance degree of each execution node in the process of receiving tasks to be allocated.
[0052] In this embodiment, the task allocation device can determine the target node weights of the execution nodes according to the hardware resource conditions of the execution nodes. For example, if the comprehensive idle value of the hardware resource conditions of the execution node is larger, the target node weight of this execution node is larger. Among them, the comprehensive idle value of the hardware resource conditions can be calculated from one or more of the following parameters, and these parameters include but are not limited to: central processing unit idle value, memory idle value, network module idle value.
[0053] Figure 2 The flowchart of another task allocation method provided by an embodiment of the present disclosure is as Figure 2 shown. In some embodiments, determining the target node weights of each execution node includes:
[0054] Step 201, obtain the node processing time consumption, central processing unit idle rate, and historical node weights of each execution node.
[0055] Among them, the node processing time consumption can be the average time consumption of the node processing tasks within the historical time period. The central processing unit (CPU) idle rate can be a parameter characterizing the remaining processing capacity of the CPU, and the CPU idle rate can be obtained by calculating the CPU utilization rate. For example, the difference between 1 and the CPU utilization rate can be used as the CPU idle rate. If there is a previous round of task allocation before the current round of task allocation, the target node weight in the previous round of task allocation can be used as the historical node weight in the current round of task allocation; if there is no previous round of task allocation before the current round of task allocation, that is, the current round of task allocation is the first round of task allocation, the historical node weight in the current round of task allocation can be preset. The specific preset value of the historical node weight is not limited in this embodiment. For example, the historical node weight corresponding to each execution node can be related to the hardware resource situation of the execution node, or the historical node weight corresponding to each execution node can be the same.
[0056] In this embodiment, the task allocation device can record the execution time consumption of multiple tasks within the historical time period, and calculate the average execution time consumption of the tasks processed by each node in units of nodes, and use this average value as the node processing time consumption. Among them, the calculation method of the execution time consumption corresponding to each task is similar to the foregoing method, and will not be elaborated here. Detect the CPU of the execution node at the sampling time point within the historical time period to obtain the corresponding CPU idle rate. Read the target node weight in the previous round of task allocation, and use the target node weight in the previous round as the historical node weight in the current round. If there is no previous round of task allocation in the current round, the preset historical node weight can be read as the historical node weight in the current round.
[0057] Step 202, for each execution node, determine the corresponding target node weight based on the corresponding node processing time consumption, CPU idle rate, and historical node weight.
[0058] After determining the node processing time consumption, CPU idle rate, and historical node weight of each execution node, the task allocation device can determine the working coefficient corresponding to the execution node based on the node processing time consumption and CPU idle rate corresponding to each execution node. And for each execution node, determine the target node weight of the execution node according to the working coefficient and historical node weight of the execution node. Specifically, the product of the node processing time consumption and the CPU idle rate of the execution node can be used as the working coefficient of the execution node, and the historical node weight of the node is multiplied by the working coefficient of the node to obtain the target node weight of the node.
[0059] For example, if the tasks executed by an execution node within a historical time period include TASK_1, TASK_2, ……, TASK_M, a total of M tasks, then the node processing time corresponding to this execution node can be: sum(time(TASK_1), time(TASK_1), …, time(TASK_M)) / M, where the time() function represents the execution time of the corresponding task, and the sum() function represents the sum of multiple time periods. If there are three execution nodes, namely the first execution node, the second execution node, and the third execution node, and the historical node weight of the first execution node is α, the historical node weight of the second execution node is β, the historical node weight of the third execution node is γ, and the node processing time of the first execution node is time_α and the CPU usage rate is u_α; the node processing time of the second execution node is time_β and the CPU usage rate is u_β; the node processing time of the third execution node is time_γ and the CPU usage rate is u_γ. Then the working coefficient k_α of the first execution node is time_α·(1 - u_α), the working coefficient k_β of the second execution node is time_β·(1 - u_β), and the working coefficient k_γ of the third execution node is time_γ·(1 - u_γ). Then the target node weight of the first execution node is (α·k_α), the target node weight of the second execution node is (β·k_β), and the target node weight of the third execution node is (γ·k_γ).
[0060] In some embodiments, the task allocation method further includes: obtaining the hardware resource conditions of multiple candidate nodes, and determining the candidate nodes whose hardware resource conditions meet the preset performance conditions as execution nodes; where the hardware resource conditions include one or more of CPU usage rate, memory usage rate, and the number of idle tasks. Among them, the hardware resource conditions can be parameters characterizing the hardware processing capabilities of the candidate nodes. The preset performance conditions can be the minimum conditions preset for the nodes to be able to process the tasks to be allocated, and the preset performance conditions can include the minimum conditions of the hardware processing capabilities in each dimension.
[0061] In this embodiment, if the hardware resource conditions include CPU usage rate, memory usage rate, and the number of idle tasks, the preset performance conditions can include that the CPU usage rate is less than the CPU threshold, the memory usage rate is less than the memory threshold, and the number of idle tasks is greater than the idle task threshold. If a candidate node meets this preset performance condition, then this candidate node can be determined as an execution node that can process the tasks to be allocated. For candidate nodes whose hardware resource conditions do not meet the preset performance conditions, the task issuance to this candidate node is postponed.
[0062] Step 105, based on the target node weights and the task issuance order, allocate multiple tasks to be allocated to each execution node.
[0063] In this embodiment, the to-be-assigned task to be issued currently can be determined according to the task issuing order, and the execution node to which the task needs to be issued currently can be determined according to the node weights of each execution node. Then, the to-be-assigned task is issued to the execution node to realize task allocation. Among them, there are various methods to determine the execution node to which the task needs to be issued, and this embodiment does not limit them. For example, weighted round-robin can be performed based on the target node weights of each execution node to determine the execution node to which the task needs to be issued.
[0064] In some embodiments, the protocols to which two adjacent tasks assigned to an execution node belong are different. Therefore, it is possible to avoid an execution node processing a relatively large number of tasks of the same protocol. The execution time of tasks using the same protocol is relatively consistent, which may lead to the node processing time of this execution node being too short or too long. To balance the execution time of the tasks processed by this execution node and avoid the execution node continuously processing tasks of the same protocol.
[0065] Specifically, before the to-be-assigned task is assigned to the to-be-assigned node, the previous task processed by the to-be-assigned node can be read. If the previous task and the to-be-assigned task use the same protocol, a new to-be-assigned node for the to-be-assigned task is re-determined from other execution nodes except the to-be-assigned node.
[0066] The task allocation method provided by the embodiments of the present disclosure includes: obtaining the protocol processing time of multiple protocols supported by multiple execution nodes; determining the target protocol weight according to the protocol processing time of each protocol; extracting multiple to-be-assigned tasks based on the target protocol weights of each protocol, and determining the extraction order as the task issuing order; determining the target node weights of each execution node; and based on the target node weights and the task issuing order, allocating multiple to-be-assigned tasks to each execution node. By adopting the above technical solution, the target protocol weight is generated based on the protocol processing time, and the task issuing order is determined according to the target protocol weight, which can adjust the task allocation from the dimension of the protocol processing time. And by determining the target node weights of each execution node, the task allocation can be adjusted from the dimension of the node, realizing the multi-dimensional comprehensive adjustment in the whole process of task allocation, improving the rationality of task allocation, and making the efficiency of task processing based on this task allocation higher.
[0067] Figure 3 For the flowchart of another task allocation method provided by the embodiments of the present disclosure, as Figure 3 shown, in some embodiments of the present disclosure, extracting multiple to-be-assigned tasks based on the target protocol weights of each protocol includes:
[0068] Step 301, determining the protocol with the largest target protocol weight among multiple protocols as the protocol to be extracted, and extracting the to-be-assigned tasks of the protocol to be extracted.
[0069] Among them, the protocol to be extracted can be the protocol for which task extraction is required, the task to be assigned can be the task using the protocol to be extracted, and the task to be assigned can be the task that needs to be assigned to the execution node.
[0070] In this embodiment, after determining the target protocol weights of each protocol, algorithms such as quicksort and bubble sort can be used to determine the maximum value among multiple target protocol weight values, and the protocol corresponding to the maximum value is determined as the protocol to be extracted. Then, one task is extracted from multiple tasks using the protocol to be extracted as the task to be assigned.
[0071] Step 302, determine the updated protocol weights of each protocol.
[0072] Among them, in one round of task assignment in this embodiment, multiple task assignments can be included. In one task assignment process, a task to be assigned is assigned to the corresponding node to be assigned. The updated protocol weight can represent the importance of the corresponding protocol in one task assignment process. The updated protocol weight can be the new weight coefficient of each protocol recalculated after determining the protocol to be extracted. It can be understood that in the process of updating the weights of each protocol, for the protocol to be extracted, the protocol weight corresponding to the protocol to be extracted can be appropriately reduced, and for other protocols except the protocol to be extracted, the protocol weights corresponding to other protocols can be appropriately increased.
[0073] In some embodiments, determining the updated protocol weights of each protocol includes: determining the updated protocol weight of the protocol to be extracted based on the target protocol weight of the protocol to be extracted and the sum of the target protocol weights of each protocol; determining the updated protocol weights of other protocols except the protocol to be extracted among multiple protocols.
[0074] In this embodiment, the task assignment device can calculate the sum of the target protocol weights of each protocol to obtain the weight sum. Calculate the difference between the target protocol weight of the protocol to be extracted and the weight sum, and use the sum of the difference and the target protocol weight as the updated protocol weight of the protocol to be extracted. For each other protocol except the protocol to be extracted, add the target protocol weight of the other protocol to the target protocol weight corresponding to the other protocol to obtain the updated protocol weight of the other protocol.
[0075] Step 303, based on the updated protocol weights of multiple protocols, return to determine a new protocol to be extracted, and extract the task to be assigned of the new protocol to be extracted until the extraction end condition is met and stop, to obtain multiple tasks to be assigned.
[0076] Among them, the extraction end condition may be a condition indicating the end of task extraction, and this extraction end condition can be set according to user requirements. For example, a count threshold can be set. When the number of tasks to be assigned extracted reaches the count threshold, it is determined that the extraction end condition is met. Alternatively, a time threshold can be set. When the total time consumed for extracting tasks to be assigned reaches the time threshold, it is determined that the extraction end condition is met.
[0077] In this embodiment, after determining the update protocol weights of multiple protocols, iterative calculation can be performed to determine new protocols to be extracted, and new tasks to be assigned can be extracted. Specifically, the task allocation device can determine the protocol with the largest weight value in the update protocol weights as the target weight, use the protocol corresponding to this target weight as the new protocol to be extracted, and extract new tasks to be assigned from this new protocol to be extracted. Iterative calculation is performed in this way until the extraction stop condition is met, then multiple tasks to be assigned can be obtained, and the extraction order of these multiple tasks to be assigned is used as the task distribution order of the tasks to be assigned.
[0078] It should be noted that when calculating the new update protocol weights based on the update protocol weights, the task allocation device can calculate the sum of the update protocol weights of each protocol to obtain the weight sum. Calculate the difference between the update protocol weight of the protocol to be extracted and this weight sum, and use the sum of this difference and the target protocol weight of the protocol to be extracted as the new update protocol weight of the protocol to be extracted. For each other protocol except the protocol to be extracted, add the update protocol weight of this other protocol and the target protocol weight corresponding to this other protocol to obtain the update protocol weight of this other protocol.
[0079] In the above solution, iterative calculation is performed based on the target protocol weights to determine the update protocol weights, the protocols to be extracted are determined based on the update protocol weights calculated each time, and the tasks to be assigned are sequentially extracted from these protocols to be extracted, achieving balanced distribution from the protocol dimension.
[0080] Figure 4 The flowchart of a task allocation method provided by an embodiment of the present disclosure is shown as Figure 4 shown. Based on the target node weights and the task distribution order, multiple tasks to be assigned are assigned to each execution node, including:
[0081] Step 401, determine the execution node with the largest target node weight among multiple execution nodes as the node to be assigned, assign the task to be assigned ranked first in the task distribution order to the node to be assigned, and update the tasks to be assigned according to the task distribution order.
[0082] In this embodiment, after determining the target node weights of each execution node, algorithms such as quicksort and bubble sort can be used to determine the maximum value among multiple target node weight values, and the execution node corresponding to this maximum value is determined as the node to be assigned. Then, determine the task to be assigned that ranks first in the task distribution order, and assign this task to be assigned that ranks first to the node to be assigned for task processing. After completing the assignment of this task to be assigned, according to the task distribution order of the task to be assigned, determine the next task of the task to be assigned that has been newly assigned as the new task to be assigned. Thus, it is realized that each task to be assigned is sequentially distributed to the corresponding node to be assigned according to the task distribution order.
[0083] Step 402: Based on the target node weight of the node to be assigned and the sum of the target node weights of each execution node, determine the updated node weight of the node to be assigned.
[0084] Step 403: Determine the updated node weights of other execution nodes among multiple execution nodes except the node to be assigned.
[0085] Among them, the updated node weight can represent the importance of the execution node during a task assignment process, and this updated node weight can be the new weight coefficient of each node recalculated after determining the node to be assigned.
[0086] In this embodiment, the task assignment device can calculate the sum of the target node weights of each execution node to obtain the weight sum. Calculate the difference between the target node weight of the node to be assigned and this weight sum, and use the sum of this difference and the target node weight as the updated node weight of the node to be assigned. For each other execution node except the node to be assigned, add the target node weight of this other execution node to the target node weight corresponding to this other execution node to obtain the updated node weight of this other execution node.
[0087] Step 404: Based on the updated node weights of multiple execution nodes, return to determine a new node to be assigned, and assign the updated task to be assigned to the new node to be assigned until all the tasks to be assigned are assigned and then stop.
[0088] In this embodiment, after determining the updated node weights of multiple execution nodes, iterative calculation can be performed to determine a new node to be assigned. Specifically, the task assignment device can determine the weight with the largest value among the updated node weights as the target weight, and use the execution node corresponding to this target weight as the new node to be assigned. Perform iterative calculation in this way to determine the node to be assigned corresponding to each task to be assigned until all the tasks to be assigned in the task distribution order are assigned to the corresponding nodes to be assigned.
[0089] It should be noted that when calculating the new updated node weight based on the updated node weight, the task allocation device can calculate the sum of the updated node weights of each execution node to obtain the weight sum. Calculate the difference between the updated node weight of the node to be allocated and the weight sum, and use the sum of the difference and the target node weight of the node to be allocated as the new updated node weight of the node to be allocated. For each other execution node except the node to be allocated, add the updated node weight of the other execution node to the target node weight corresponding to the other execution node to obtain the updated node weight of the other execution node.
[0090] In the above solution, an iterative calculation is implemented based on the target node weight to determine the updated node weight, and the node to be allocated is determined based on the updated node weight calculated each time, realizing the balanced allocation of tasks from the dimension of execution nodes.
[0091] Next, a specific example is used to further illustrate the task allocation method in the embodiments of the present disclosure. Figure 5 It is a schematic flowchart of another task allocation method provided by the embodiments of the present disclosure, as Figure 5 shown. The task allocation method includes:
[0092] Step 501, group tasks according to the protocol to obtain multiple task sets, initialize the initial protocol weight corresponding to each protocol, and determine the tasks to be allocated according to the initial weight during the first round of task collection.
[0093] This step 501 may include the following steps a1 - step a2.
[0094] Step a1, create multiple task sets according to the protocol type. Tasks of the same protocol type belong to the same task set, and initialize the initial queue weight corresponding to each protocol to 1.
[0095] Step a2, sequentially obtain the tasks to be allocated from the multiple task sets. The number of tasks to be allocated collected from each task set is the same, and the total number of tasks to be allocated collected is less than or equal to the total number of idle tasks of the execution nodes, where the total number of idle tasks represents the maximum number of tasks that multiple execution nodes can handle.
[0096] Step 502, regularly obtain the running status of each candidate node, determine the execution nodes that can handle tasks according to the running status, and allocate the tasks to be allocated to the execution nodes that can handle tasks.
[0097] This step 502 may include the following steps b1 - step b3.
[0098] Step b1: Obtain the CPU usage rate, memory usage rate, and number of idle tasks of each candidate node, compare them with the preset performance conditions, and temporarily suspend the distribution of tasks to be allocated to the candidate nodes that do not meet the preset performance conditions, thereby alleviating the pressure on the candidate nodes. Among them, the preset parameter conditions may include: the CPU usage rate of the candidate node < the preset CPU threshold, the memory usage rate of the candidate node < the preset memory threshold, and the number of idle tasks of the candidate node > 0.
[0099] Step b2: Ensure that tasks belonging to the same protocol are not continuously allocated to the same execution node, that is, the protocols to which adjacent tasks processed by the execution node belong are different. Record the number of tasks sent to each execution node, the sending time of each task, and the protocol to which each task belongs.
[0100] Step b3: Set the initial node weights of each execution node to be equal, and use a polling strategy to allocate tasks to be allocated to each execution node.
[0101] Step 503: Receive the collected data sent by each execution node and count the time-consuming situation. Among them, the collected data includes: the sending time of each task, the completion time of each task, the number of tasks processed by each execution node, and the number of tasks sent by each protocol. The time-consuming situation includes: protocol processing time-consuming and node processing time-consuming.
[0102] This step 503 may include the following steps c1 - step c3.
[0103] Step c1: Calculate the time-consuming situation of a single task. The calculation formula is as follows:
[0104] The time when the collected data corresponding to the task is received is endTime, in milliseconds; the time when the task is sent is sendTime, in milliseconds. Then the execution time-consuming of this task can be (endTime - sendTime) / 1000, in seconds.
[0105] Step c2: Calculate the node processing time-consuming of each execution node and record it in the protocol counter. The tasks processed by the execution node are TASK_1, TASK_2,..., TASK_M, and the number is M. Receive the corresponding collected data through the protocol counter. Then the calculation formula for the node processing time-consuming corresponding to this execution node is as follows: sum(time(TASK_1), time(TASK_1), …, time(TASK_M)) / M, where the time() function represents the execution time-consuming of the corresponding task, and the sum() function represents summation.
[0106] Step c3: Calculate the average time taken by each execution node to process each protocol. Taking the SNMP protocol as an example, the tasks corresponding to the SNMP protocol are SNMP_1, SNMP_2, ……, SNMP_N, and the number of tasks is N. The relevant data of the SNMP protocol type is received through the protocol counter. The formula for calculating the average time taken by this execution node to process the tasks of the SNMP protocol type is as follows: sum(time(SNMP_1), time(SNMP_1), …, time(SNMP_N)) / N, where the time() function represents the execution time of the corresponding task, and the sum() function represents summation. After determining the average time taken by each execution node to process each protocol, the average value of the average time taken by each protocol at each execution node can be statistically calculated, and this average value is used as the protocol processing time of this protocol. For example, if there are three execution nodes, namely the first execution node, the second execution node, and the third execution node, and the average time taken by the SNMP protocol at the first execution node is t_1, at the second execution node is t_2, and at the third execution node is t_3, then the protocol processing time of the SNMP protocol can be (t_1 + t_2 + t_3) / 3.
[0107] Step 504: Calculate the working coefficient of each node by using the protocol processing time and node processing time of the previous round, as well as the CPU usage of each current execution node, and adjust the target protocol weight of each execution node.
[0108] This step 504 may include the following steps d1 - d3.
[0109] Step d1: Calculate the working coefficient of each execution node. The working coefficient of each node is equal to the node processing time of this node multiplied by the CPU idle rate of this node. Taking the first execution node as an example, the working coefficient of this node is k_α, the node processing time is time_α, and the CPU usage rate is u_α, then the working coefficient k_α = time_α·(1 - u_α).
[0110] Step d2: Determine the target node weight of each execution node according to the working coefficient of each execution node and the historical node weight of each node. Taking the first execution node as an example, if the historical node weight of the first execution node is α and the working coefficient is k_α, then the target execution node is α·k_α.
[0111] Step d3: Adjust the target protocol weight corresponding to each protocol. Taking the first protocol as an example, if the historical protocol weight corresponding to the first protocol is a and the protocol processing time of the first protocol is time_a, then the target protocol weight corresponding to this first protocol is a·time_a.
[0112] Step 505: Extract the tasks to be assigned according to the target protocol weight, and assign the tasks to be assigned through the weighted round-robin algorithm based on the target node weight.
[0113] This step 505 may include the following steps e1 - step e2.
[0114] Step e1: Obtain the tasks to be assigned in the task set according to the target protocol weight.
[0115] Step e2: Assign the tasks to be assigned to the corresponding execution nodes through the weighted round-robin algorithm. Among them, the weighted round-robin algorithm is: Based on the target node weights of each execution node, dynamically adjust the weights of each execution node to determine the execution node that receives the tasks to be assigned. For example, if there is a first execution node and the target node weight of the first execution node is 2, a second execution node and the target node weight of the second execution node is 1, and a third execution node and the target node weight of the third execution node is 1, then select the execution node corresponding to the maximum value in the target node weights to receive the tasks to be assigned, that is, select the first execution node as the node to be assigned, and subtract the sum of the target node weights from the target node weight of the first execution node and then add the target node weight of the first execution node to obtain the updated node weight corresponding to the first execution node as 0. Add the node weights of the other execution nodes to the target node weights to obtain the updated node weight of the second execution node as 2 and the updated node weight of the third execution node as 2. At this time, the updated node weights of the two execution nodes are the same, and randomly select one of them as the node to be assigned. Taking the selection of the second node as the node to be assigned as an example to continue the description, then subtract the sum of the updated node weights of each node from the updated node weight of the second node and then add the target node weight of the second node to obtain the updated node weight of the second execution node as -1. Add the updated node weights of the other execution nodes to the target node weights to obtain the updated node weight of the first execution node as 2 and the updated node weight of the third execution node as 3. And so on, assign the tasks to be assigned to the corresponding execution nodes.
[0116] In the above solution, the tasks are grouped according to the protocol to obtain multiple task sets, calculate the watch protocol weights corresponding to each protocol, obtain the tasks to be assigned for the corresponding protocol according to the target protocol weight ratio, regularly calculate the working coefficients of each execution node, adjust the target node weights according to the working coefficients, and issue the tasks to be assigned through the weighted round-robin algorithm according to the target node weight ratio, which improves the rationality of the utilization of the execution nodes, increases the number of tasks processed by the execution nodes, and improves the execution efficiency of the tasks.
[0117] Figure 6 A schematic structural diagram of a task allocation device provided by an embodiment of the present disclosure. This device can be implemented by software and / or hardware and is generally integrated in an electronic device. As Figure 6As shown, the device includes:
[0118] An acquisition module 601, configured to acquire the protocol processing time consumption of multiple protocols supported by multiple execution nodes;
[0119] A first determination module 602, configured to determine a target protocol weight according to the protocol processing time consumption of each protocol;
[0120] An extraction module 603, configured to extract multiple tasks to be assigned based on the target protocol weights of the protocols, and determine the extraction order as the task distribution order;
[0121] A second determination module 604, configured to determine the target node weights of the execution nodes;
[0122] An allocation module 605, configured to allocate the multiple tasks to be assigned to the execution nodes based on the target node weights and the task distribution order.
[0123] Optionally, the acquisition module 601 is configured to:
[0124] Acquire the execution time consumption of multiple tasks corresponding to a preset historical time period;
[0125] Classify the tasks according to the multiple protocols to obtain multiple task sets, where one task set includes at least one task, and the task sets and the protocols correspond one by one;
[0126] Determine the average time consumption of the execution time consumption of the multiple tasks included in each task set as the protocol processing time consumption of the protocol corresponding to each task set.
[0127] Optionally, the first determination module 602 includes:
[0128] For each protocol, determine the corresponding target protocol weight based on its historical protocol weight and the corresponding protocol processing time consumption.
[0129] Optionally, the extraction module 603 includes:
[0130] A first determination sub-module, configured to determine the protocol with the largest target protocol weight among the multiple protocols as the protocol to be extracted, and extract the tasks to be assigned of the protocol to be extracted;
[0131] A second determination sub-module, configured to determine the updated protocol weights of the protocols;
[0132] An extraction sub-module, configured to return and determine a new protocol to be extracted based on the updated protocol weights of the multiple protocols, and extract the tasks to be assigned of the new protocol to be extracted, and stop until the extraction end condition is met, to obtain multiple tasks to be assigned.
[0133] Optionally, the second determination sub-module is configured to:
[0134] Determine the updated protocol weight of the protocol to be extracted based on the target protocol weight of the protocol to be extracted and the sum of the target protocol weights of all the protocols;
[0135] Determine the updated protocol weights of the other protocols in the multiple protocols except the protocol to be extracted.
[0136] Optionally, the second determination module 604 is configured to:
[0137] Obtain the node processing time consumption, the central processing unit idle rate, and the historical node weight of each execution node;
[0138] For each execution node, determine its corresponding target node weight based on its corresponding node processing time consumption, the central processing unit idle rate, and the historical node weight.
[0139] Optionally, the allocation module 605 is configured to:
[0140] Determine the execution node with the largest target node weight among the multiple execution nodes as the node to be allocated, allocate the task to be allocated ranked first in the task distribution order to the node to be allocated, and update the task to be allocated according to the task distribution order;
[0141] Determine the updated node weight of the node to be allocated based on the target node weight of the node to be allocated and the sum of the target node weights of all the execution nodes;
[0142] Determine the updated node weights of the other execution nodes in the multiple execution nodes except the node to be allocated;
[0143] Based on the updated node weights of the multiple execution nodes, determine a new node to be allocated and allocate the updated task to be allocated to the new node to be allocated until all the tasks to be allocated are allocated and then stop.
[0144] The task allocation device provided by the embodiments of the present disclosure can execute the task allocation method provided by any embodiment of the present disclosure, and has corresponding functional modules and beneficial effects for executing the method.
[0145] Figure 7 It is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. As Figure 7 shown, the electronic device 700 includes one or more processors 701 and a memory 702.
[0146] The processor 701 can be a central processing unit (CPU) or other forms of processing units with task allocation capabilities and / or instruction execution capabilities, and can control other components in the electronic device 700 to perform desired functions.
[0147] The memory 702 can include one or more computer program products, and the computer program products can include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory can include, for example, random access memory (RAM) and / or cache memory, etc. The non-volatile memory can include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions can be stored on the computer-readable storage media, and the processor 701 can run the program instructions to implement the task allocation method of the embodiments of the present disclosure described above and / or other desired functions. Various contents such as input signals, signal components, noise components, etc. can also be stored in the computer-readable storage media.
[0148] In one example, the electronic device 700 can further include: an input device 703 and an output device 704, and these components are interconnected through a bus system and / or other forms of connection mechanisms (not shown).
[0149] In addition, the input device 703 can further include, for example, a keyboard, a mouse, etc.
[0150] The output device 704 can output various information to the outside, including the determined distance information, direction information, etc. The output device 704 can include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0151] Of course, for simplicity, Figure 7 only some of the components related to the present disclosure in the electronic device 700 are shown, and components such as buses, input / output interfaces, etc. are omitted. In addition, according to specific application scenarios, the electronic device 700 can further include any other appropriate components.
[0152] In addition to the above methods and devices, the embodiments of the present disclosure can also be a computer program product, which includes computer program instructions that, when run by a processor, cause the processor to execute the task allocation method provided by the embodiments of the present disclosure.
[0153] The computer program product may be written in any combination of one or more programming languages for programming code to perform the operations of the embodiments of the present disclosure. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The programming code may be executed entirely on the user computing device, partially on the user device, executed as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0154] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, and when the computer program instructions are run by a processor, the processor is caused to execute the task allocation method provided by the embodiments of the present disclosure.
[0155] The computer-readable storage medium may employ any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. The readable storage medium may include, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0156] It should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.
[0157] The above are only specific embodiments of the present disclosure, enabling those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments described herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.
Claims
1. A task allocation method, characterized in that, Including: Obtaining the protocol processing time consumption of multiple protocols supported by multiple execution nodes; Determining the target protocol weight according to the protocol processing time consumption of each protocol; Extracting multiple tasks to be assigned based on the target protocol weights of each of the said protocols, and determining the extraction order as the task distribution order; Determining the target node weights of each of the said execution nodes; Based on the target node weights and the task distribution order, distributing the multiple tasks to be assigned to each of the said execution nodes.
2. The method according to claim 1, wherein The obtaining the protocol processing time consumption of multiple protocols supported by multiple execution nodes includes: Obtaining the execution time consumption of multiple tasks corresponding to a preset historical time period; Classifying the tasks according to the multiple protocols to obtain multiple task sets, where one of the said task sets includes at least one task, and the task sets and the protocols correspond one by one; Determining the average time consumption of the execution time consumption of the multiple tasks included in each of the said task sets as the protocol processing time consumption of the protocol corresponding to each of the said task sets.
3. The method according to claim 1, wherein The determining the target protocol weight according to the protocol processing time consumption of each protocol includes: For each of the said protocols, determining the corresponding target protocol weight based on its historical protocol weight and the corresponding protocol processing time consumption.
4. The method according to claim 1, wherein The extracting multiple tasks to be assigned based on the target protocol weights of each of the said protocols includes: Determining the protocol with the largest target protocol weight among the multiple protocols as the protocol to be extracted, and extracting the tasks to be assigned of the protocol to be extracted; Determining the updated protocol weights of each of the said protocols; Based on the updated protocol weights of the multiple protocols, determining a new protocol to be extracted and extracting the tasks to be assigned of the new protocol to be extracted, and stopping until the extraction end condition is met, to obtain multiple tasks to be assigned.
5. The method according to claim 4, wherein The determining the updated protocol weights of each of the said protocols includes: Based on the target protocol weight of the protocol to be extracted and the sum of the target protocol weights of each of the said protocols, determining the updated protocol weight of the protocol to be extracted; Determining the updated protocol weights of the other protocols among the multiple protocols except the protocol to be extracted.
6. The method according to claim 1, characterized in that, The determining the target node weights of each of the said execution nodes includes: Obtaining the node processing time consumption, CPU idle rate, and historical node weights of each execution node; For each of the said execution nodes, determining its corresponding target node weight based on its corresponding node processing time consumption, CPU idle rate, and historical node weight.
7. The method according to claim 1, characterized in that The distributing the multiple tasks to be assigned to each of the said execution nodes based on the target node weights and the task distribution order includes: Determining the execution node with the largest target node weight among the multiple execution nodes as the node to be assigned, assigning the task to be assigned ranked first in the task distribution order to the node to be assigned, and updating the task to be assigned according to the task distribution order; Based on the target node weight of the node to be assigned and the sum of the target node weights of each of the said execution nodes, determining the updated node weight of the node to be assigned; Determining the updated node weights of the other execution nodes among the multiple execution nodes except the node to be assigned. Based on the updated node weights returned by the multiple execution nodes, determine new nodes to be allocated, and allocate the updated tasks to be allocated to the new nodes to be allocated until all the tasks to be allocated are allocated and then stop.
8. A task allocation device, characterized in that, It includes: An acquisition module, configured to acquire the protocol processing time consumption of multiple protocols supported by multiple execution nodes; A first determination module, configured to determine the target protocol weight according to the protocol processing time consumption of each protocol; An extraction module, configured to extract multiple tasks to be allocated based on the target protocol weights of the protocols, and determine the extraction order as the task distribution order; A second determination module, configured to determine the target node weights of the execution nodes; An allocation module, configured to allocate the multiple tasks to be allocated to each execution node based on the target node weights and the task distribution order.
9. An electronic device, characterized in that, The electronic device includes: A processor; A memory for storing executable instructions of the processor; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the task allocation method according to any one of claims 1-7 above.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, and the computer program is used to execute the task allocation method according to any one of claims 1-7 above.
Citation Information
Patent Citations
Task scheduling processing method and device, computer equipment and storage medium
CN112667376A
Method and apparatus for transaction verification in a blockchain-based network
WO2020022958A1