Task scheduling method and device, computer device, storage medium and program product

By obtaining the minimum number of idle threads for candidate tasks and key service nodes in a distributed system, adjusting the number of concurrent tasks, and constructing a service node classification tree, the problem of inaccurate resource consumption when tasks are restarted in a distributed system is solved, thereby optimizing task scheduling and improving fault tolerance.

CN115016915BActive Publication Date: 2026-08-25INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210757280.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-30
Publication Date
2026-08-25
Estimated Expiration
2042-06-30

AI Technical Summary

Technical Problem

In distributed systems, existing fault tolerance mechanisms cannot accurately predict the resource consumption when restarting a task, which may lead to blocking again.

Method used

By obtaining the minimum number of idle threads for candidate tasks and key service nodes in the distributed system, adjusting the number of concurrent tasks, constructing a service node classification tree, estimating the node thread resource usage, and scheduling tasks to avoid blocking.

Benefits of technology

It effectively reduces the probability of critical service nodes becoming blocked when executing candidate tasks, achieves optimized scheduling of task concurrency, and improves the system's fault tolerance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115016915B_ABST
    Figure CN115016915B_ABST
Patent Text Reader

Abstract

The application relates to the field of big data, in particular to a task scheduling method and device, computer equipment, a storage medium and a program product. The method comprises the following steps: acquiring all candidate tasks in a distributed system and the task concurrency quantity of each candidate task; the candidate task represents a task in the distributed system which has been executed by a fault tolerance mechanism; acquiring the minimum idle thread quantity of a key service node corresponding to each candidate task; adjusting the task concurrency quantity of the corresponding candidate task according to the minimum idle thread quantity of each key service node, so as to obtain the target task concurrency quantity of each candidate task; the target task concurrency quantity is the task quantity that each key service node can execute the corresponding candidate task. By using the method, the risk that the candidate task may still be blocked when being executed again can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of big data technology, and in particular to a task scheduling method, apparatus, computer equipment, storage medium, and program product. Background Technology

[0002] In a distributed system, multiple servers (nodes) or services simultaneously provide a business function. If a service node in the distributed system fails or a network anomaly occurs, and the timeout period is long, it may lead to a cascading failure of the distributed system.

[0003] Therefore, related technologies can avoid the cascading failure limitation of distributed systems by improving the overall fault tolerance of the system. For example, common fault tolerance solutions include service degradation, circuit breaking, and service rate limiting. Among them, circuit breaking is a passive timeout framework, which is a post-event fault tolerance mechanism. Excessive retries and post-event fault tolerance mechanisms can lead to unnecessary system occupation. Degradation and rate limiting are both in-event fault tolerance mechanisms. Tasks that have been degraded or rate-limited will be restarted after a certain period of time. However, both cannot accurately estimate the resource occupation of service nodes in the call chain when restarting tasks, which may lead to blocking of the re-executed task. Summary of the Invention

[0004] Therefore, it is necessary to provide a task scheduling method, apparatus, computer device, storage medium, and program product that can reduce the risk of blocking when candidate tasks are executed again, in order to address the above-mentioned technical problems.

[0005] Firstly, this application provides a task scheduling method. The method includes:

[0006] Retrieve all candidate tasks in the distributed system and the concurrency of each candidate task; candidate tasks represent tasks in the distributed system that have currently had fault-tolerant mechanisms implemented.

[0007] Obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task;

[0008] Based on the minimum number of idle threads at each key service node, the concurrency of the corresponding candidate tasks is adjusted to obtain the target concurrency of each candidate task; the target concurrency is the number of tasks that each key service node can execute for the corresponding candidate task.

[0009] In one embodiment, before obtaining the minimum number of idle threads for the key service nodes corresponding to each candidate task, the method further includes:

[0010] Obtain the service call hierarchy, which includes the service node call chain of each task;

[0011] Service nodes with preset node identifiers in the service node call chain of each task in the service call hierarchy are identified as critical service nodes; the node identifier is used to identify service nodes whose probability of task scheduling blockage is greater than the preset probability value.

[0012] In one embodiment, obtaining the minimum number of idle threads for the key service nodes corresponding to each candidate task includes:

[0013] Based on the key service nodes in the service call hierarchy, a service node classification tree is constructed. The service node classification tree includes the node ranges corresponding to all key service nodes and the real-time idle thread count for each node range.

[0014] Based on the service node classification tree, determine the minimum number of idle threads for the key service nodes corresponding to each candidate task.

[0015] In one embodiment, the minimum number of idle threads for the key service node corresponding to each candidate task is determined based on the service node classification tree, including:

[0016] Query the real-time idle thread count of the key service nodes corresponding to each candidate task from the service node classification tree;

[0017] For any candidate task, the minimum number of real-time idle threads of the key service node corresponding to the candidate task is determined as the minimum number of idle threads of the key service node corresponding to the candidate task.

[0018] In one embodiment, the minimum number of idle threads for the key service node corresponding to each candidate task is determined based on the service node classification tree, including:

[0019] For any candidate task, query the target node range to which the key service node corresponding to the candidate task belongs from the service node classification tree;

[0020] The minimum number of idle threads in the target node range is determined as the minimum number of idle threads for the critical service node corresponding to the candidate task.

[0021] In one embodiment, after adjusting the concurrency of the corresponding candidate tasks to obtain the target concurrency of each candidate task, the method further includes:

[0022] For any candidate task, based on the concurrency of the candidate task's target task, update the real-time idle thread count of the target node interval corresponding to the candidate task in the service node classification tree, and mark the updated target node interval.

[0023] In one embodiment, the concurrency of corresponding candidate tasks is adjusted based on the minimum number of idle threads at each key service node to obtain the target concurrency of each candidate task, including:

[0024] The comparison results of each candidate task are obtained by comparing the number of concurrent tasks of each candidate task with the minimum number of idle threads of the key service node corresponding to each candidate task.

[0025] Based on the comparison results of each candidate task, the number of concurrent tasks for the corresponding candidate tasks is adjusted to obtain the target number of concurrent tasks for each candidate task.

[0026] In one embodiment, the concurrency level of each candidate task is adjusted based on the comparison results to obtain the target concurrency level for each candidate task, including:

[0027] For any candidate task, if the comparison result shows that the number of concurrent tasks of the candidate task is greater than the minimum number of idle threads of the critical service node corresponding to the candidate task, then the number of concurrent tasks of the candidate task is adjusted to be the same as the minimum number of idle threads; the minimum number of idle threads is the target number of concurrent tasks of the candidate task.

[0028] Secondly, this application also provides a task scheduling apparatus. The apparatus includes:

[0029] The first acquisition module is used to acquire all candidate tasks in the distributed system and the number of concurrent tasks for each candidate task; candidate tasks represent tasks in the distributed system that have already had fault-tolerant mechanisms implemented.

[0030] The second acquisition module is used to obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task;

[0031] The adjustment module is used to adjust the concurrency of corresponding candidate tasks based on the minimum number of idle threads of each key service node, so as to obtain the target concurrency of each candidate task; the target concurrency is the number of tasks that each key service node can execute for the corresponding candidate task.

[0032] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0033] Retrieve all candidate tasks in the distributed system and the concurrency of each candidate task; candidate tasks represent tasks in the distributed system that have currently had fault-tolerant mechanisms implemented.

[0034] Obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task;

[0035] Based on the minimum number of idle threads at each key service node, the concurrency of the corresponding candidate tasks is adjusted to obtain the target concurrency of each candidate task; the target concurrency is the number of tasks that each key service node can execute for the corresponding candidate task.

[0036] Fourthly, this application also provides a computer-readable storage medium. This computer-readable storage medium stores a computer program, which, when executed by a processor, performs the following steps:

[0037] Retrieve all candidate tasks in the distributed system and the concurrency of each candidate task; candidate tasks represent tasks in the distributed system that have currently had fault-tolerant mechanisms implemented.

[0038] Obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task;

[0039] Based on the minimum number of idle threads at each key service node, the concurrency of the corresponding candidate tasks is adjusted to obtain the target concurrency of each candidate task; the target concurrency is the number of tasks that each key service node can execute for the corresponding candidate task.

[0040] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0041] Retrieve all candidate tasks in the distributed system and the concurrency of each candidate task; candidate tasks represent tasks in the distributed system that have currently had fault-tolerant mechanisms implemented.

[0042] Obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task;

[0043] Based on the minimum number of idle threads at each key service node, the concurrency of the corresponding candidate tasks is adjusted to obtain the target concurrency of each candidate task; the target concurrency is the number of tasks that each key service node can execute for the corresponding candidate task.

[0044] The aforementioned task scheduling method, apparatus, computer equipment, storage medium, and program product adjust the concurrency of each candidate task based on the minimum number of idle threads on the critical service nodes of each candidate task, thereby achieving scheduling and planning for all candidate tasks. After adjusting the concurrency of each candidate task, for any candidate task, each critical service node corresponding to that candidate task can execute the candidate task with the target concurrency, achieving the effect of advance planning by estimating the node thread resource usage. During execution, it can effectively reduce the probability of critical service nodes being blocked when executing each candidate task. Attached Figure Description

[0045] Figure 1 This is a diagram illustrating the application environment of a task scheduling method in one embodiment;

[0046] Figure 2 This is a flowchart illustrating a task scheduling method in one embodiment;

[0047] Figure 3 This is a flowchart illustrating the steps for determining key service nodes in one embodiment;

[0048] Figure 4 This is a schematic diagram of the service call hierarchy in one embodiment;

[0049] Figure 5 This is a schematic diagram illustrating the process of constructing a node service classification tree in one embodiment;

[0050] Figure 6 This is a schematic diagram of a service classification tree in one embodiment;

[0051] Figure 7 This is a flowchart illustrating the process of determining the minimum number of idle threads for each candidate task in one embodiment.

[0052] Figure 8 This is a flowchart illustrating the process of determining the minimum number of idle threads for each candidate task in another embodiment;

[0053] Figure 9 This is a schematic diagram of the process of updating the service node classification tree in one embodiment;

[0054] Figure 10 This is a flowchart illustrating the process of determining the target task concurrency based on the comparison results in one embodiment.

[0055] Figure 11 This is a structural block diagram of a task scheduling device in one embodiment;

[0056] Figure 12 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0057] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0058] The task scheduling method provided in this application embodiment can be applied to, for example, Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. Server 104 is a server used for task scheduling in the distributed system. Terminal 102 communicates with server 104 to obtain tasks (i.e., candidate tasks) after fault-tolerant processing by server 104. Terminal 102 obtains all candidate tasks in the distributed system and the task concurrency of each candidate task, and obtains the minimum number of idle threads of the key service nodes corresponding to each candidate task. Based on the minimum number of idle threads of each key service node, the task concurrency of the corresponding candidate task is adjusted to obtain the target task concurrency of each candidate task. The target task concurrency is the number of tasks that each key service node can execute for the corresponding candidate task. To distinguish it from server 104, terminal 102 can be defined as a function scheduler; terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. Server 104 can be implemented using a standalone server or a server cluster composed of multiple servers.

[0059] With the development of the internet and cloud computing, distributed architecture has become widely used. Distributed architecture decouples and combines applications by breaking them down into multiple microservices to better meet the needs of rapidly evolving businesses. Therefore, a single business request may involve numerous service calls. The relationships between services and node servers can be: 1) A single node server can provide multiple services, and different services within the same node server may also have calling relationships; 2) A service may be provided by multiple different node servers, meaning that calling a service requires calling multiple node servers corresponding to that service. The call chain of a business request refers to determining the corresponding node servers for each service based on the services called by the business request. The calling relationships between these node servers constitute a business request call chain.

[0060] When users initiate business requests to a distributed system through a client, due to the complexity and uncertainty of the network environment, resource congestion may occur on a node server accessed by the user. This congestion can lead to the unavailability of the microservices corresponding to that node server, and may even cause the entire business system to crash. To avoid a cascading failure, fault tolerance mechanisms such as service degradation, service rate limiting, or circuit breaking are typically pre-configured. Circuit breaking is triggered when individual services in the distributed system become unavailable or experience timeouts; calls to the faulty service are temporarily suspended until the service recovers. Service degradation refers to strategically delaying, suspending, or partially suspending the use of some services when the overall load of the distributed system exceeds a set threshold, while ensuring the normal operation of core services. Service rate limiting restricts the number of concurrent requests and the number of requests processed per unit of time. However, the aforementioned service degradation, service rate limiting, or circuit breaking are all fault tolerance mechanisms during or after the event. These two methods cannot accurately predict the resource consumption of service nodes in the call chain for candidate tasks that are restarted, which may result in the candidate tasks being executed again still being blocked.

[0061] In one embodiment, such as Figure 2 As shown, a task scheduling method is provided, which can be applied to... Figure 1 Taking terminal 102 as an example, the explanation includes the following steps:

[0062] Step 200: Obtain all candidate tasks in the distributed system and the number of concurrent tasks for each candidate task.

[0063] In this context, candidate tasks refer to tasks in the distributed system that have already had fault tolerance mechanisms implemented. Specifically, for service degradation, candidate tasks are those that have been processed to delay, suspend, or partially suspend service use; for service rate limiting, candidate tasks are those that have had their concurrency reduced; and for circuit breaking, candidate tasks are those that will be invoked again when the service recovers.

[0064] Typically, batch processing tasks in a distributed system are executed at intervals from real-time online tasks, and the node servers called by batch processing tasks are different from those called by real-time online tasks. Therefore, batch processing tasks usually have no timeliness requirements and do not require fault tolerance processing, and can be scheduled and executed by the fault tolerance processing module (i.e., server 104) in a traditional distributed system. However, the candidate tasks in the embodiments of this application are fault-tolerant tasks. Fault tolerance processing indicates that the task may involve some critical node servers. Therefore, the candidate tasks in the embodiments of this application are different from traditional batch processing tasks and need to be rescheduled and re-arranged by terminal 102. Specifically, terminal 102 is connected to the fault tolerance processing module in the traditional distributed system to obtain each candidate task and the concurrency of each candidate task, and then re-schedules each candidate task uniformly through terminal 102.

[0065] The specific method by which terminal 102 uniformly schedules each candidate task is as follows: The acquired candidate tasks are sorted according to a preset priority, and then, in turn, it is determined whether the node servers of the distributed system support the smooth execution of each candidate task with the corresponding number of concurrent tasks at each preset execution time point (or execution time period). For example, the candidate tasks received by terminal 102 from the fault tolerance processing module are candidate task 1 (with a concurrent task count of 4), candidate task 2 (with a concurrent task count of 2), and candidate task 3 (with a concurrent task count of 4). After prioritizing, we obtain candidate tasks 1, 2, and 3. At this point, candidate task 1, which ranks first, is designated as the current candidate task. First, we determine if the distributed system can execute all four candidate tasks at the current time. If so, we add candidate task 2, which also ranks first, as the current candidate task. We then determine if the distributed system can execute two more candidate tasks. If not, we determine how many candidate tasks 2 the distributed system can execute and adjust their concurrency accordingly. If the distributed system cannot execute all four candidate tasks at the current time, we can only use candidate task 1 as the current candidate task and adjust its concurrency. Only after all the concurrency for candidate task 1 has been scheduled will candidate task 2 be designated as the new current candidate task. This process is repeated sequentially. The scheduling method for candidate task 3 is the same as that for candidate task 2 and will not be elaborated further. The current time point for the prediction and judgment step is earlier than the execution time point (execution period). By making a preliminary assessment, each candidate task is pre-scheduled to avoid the distributed system from being blocked when the candidate task is executed at the execution time point (execution period).

[0066] In this embodiment, when scheduling various candidate tasks, the terminal 102 will select a time node where the service calls of real-time customer service (online service) are relatively stable and do not suddenly increase or decrease, so as to avoid the node server of the service being blocked when the candidate task is executed due to a sudden increase in the service calls of real-time customer service (online service).

[0067] For each candidate task, the task concurrency level represents the number of accesses / requests made by multiple clients concurrently accessing / requesting the same node server based on that candidate task. This application embodiment uses the concurrency level parameter to measure whether the node server corresponding to the candidate task can execute the candidate task, in order to determine whether to rate limit (reduce) the concurrency level of the candidate task. The concurrent processing capacity of a node server refers to the maximum number of requests that the node server can handle per unit of time, typically defined as 1 second. The concurrent processing capacity of a node server is determined by its number of threads; specifically, one thread of a node server can only handle one concurrent request at a time.

[0068] Step 202: Obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task.

[0069] For each candidate task, the key service node refers to the critical node among all nodes called to execute the candidate task. Key service nodes can be pre-defined, and there must be at least one key service node. Each key service node corresponds to a number of idle threads, which represents the number of unused threads on the server of that node. The minimum number of idle threads for each candidate task's key service node is the minimum value among all the idle threads of the candidate task's key service nodes.

[0070] Specifically, terminal 102 needs to communicate with each key service node to obtain the number of idle threads for each key service node. After obtaining the number, the number of idle threads for each key service node can be cached locally. When obtaining the number of idle threads for any key service node, the following two methods can be used: 1) Directly use the number of unoccupied threads of the accessed node server as the number of idle threads for that node server. In this case, the number of idle threads for that node server = the total number of threads of that node server - the number of threads already occupied by that node server; 2) Obtain the number of unoccupied threads of that node server, and calculate the number of idle threads for that node server based on the number of unoccupied threads and the number of reserved threads. In this case, the number of idle threads for that node server = the total number of threads of that node server - the number of threads already occupied by that node server - the number of reserved threads; where the number of reserved threads refers to the number of threads that the node server is expected to occupy when processing real-time customer services. In this embodiment, by obtaining the number of idle threads of the key service node through the above method 2), the necessary thread resources can be reserved for the online service (real-time customer service), so that the execution of candidate tasks will not affect the online service (real-time customer service).

[0071] Step 204: Adjust the concurrency of the corresponding candidate tasks according to the minimum number of idle threads of each key service node to obtain the target concurrency of each candidate task.

[0072] The target task concurrency is the number of candidate tasks that each key service node can execute. For any candidate task, taking the current candidate task as an example: if the minimum number of idle threads on each key service node of the current candidate task is greater than or equal to the current candidate task's task concurrency, then each key service node of the current candidate task can execute the current candidate task at that concurrency level, and no adjustment to the current candidate task's task concurrency is needed. If the minimum number of idle threads on each key service node of the current candidate task is less than the current candidate task's task concurrency, then each key service node of the current candidate task cannot execute the current candidate task at that concurrency level. In this case, the current candidate task's task concurrency needs to be adjusted to the target task concurrency level so that each key service node of the current candidate task can execute candidate tasks at the target task concurrency level. After adjustment, the current candidate task can be rescheduled.

[0073] In the above task scheduling method, the task concurrency of each candidate task is adjusted according to the minimum number of idle threads of the key service nodes of each candidate task, thereby realizing the scheduling and planning of all candidate tasks. After adjusting the task concurrency of each candidate task, for any candidate task, each key service node corresponding to that candidate task can execute the candidate task with the target task concurrency, achieving the effect of advance planning by estimating the node thread resource usage. During the execution process, it can effectively reduce the probability of key service nodes being blocked when executing each candidate task.

[0074] When making advance predictions about the execution status of candidate tasks, analyzing all service nodes in the call chain of the candidate tasks can lead to low analysis efficiency and poor practicality when the number of service nodes is large due to the massive amount of data. Furthermore, during actual task execution, the service nodes that cause congestion are usually nodes on the call chain that are frequently called and prone to thread resource bottlenecks (or crash-prone nodes). Therefore, without sacrificing the accuracy of task scheduling, this embodiment only analyzes the upper part of the key nodes in the call chain to improve analysis efficiency. Thus, in one embodiment, before obtaining the minimum number of idle threads for the key service nodes corresponding to each candidate task in step 202, the task scheduling method further includes step 201, such as... Figure 3 As shown, step 201 includes: obtaining the service call hierarchy relationship, which includes the service node call chain of each task, and identifying the service nodes with preset node identifiers in the service node call chain of each task in the service call hierarchy relationship as key service nodes.

[0075] The node identifier is used to identify service nodes where the probability of task scheduling congestion exceeds a preset probability value. Node identifiers can be manually assigned. When identifying critical service nodes, administrators can identify them one by one at the node level based on experience, or they can select some critical services at the service level and mark the corresponding nodes as critical service nodes. Specifically, the service call hierarchy is stored in the registry center. Terminal 102 communicates with the registry center to obtain the service call hierarchy, which can be reconstructed and initialized in memory during application version updates. When selecting critical services, administrators can analyze the actual production environment's operation and maintenance platform and identify (select) each critical service in the service call hierarchy. Therefore, critical services can be changed and adjusted, and the nodes called by critical services can also be changed within the registry center.

[0076] Within the registry center, the storage methods for service call hierarchy relationships may include: (1) storing the call chains of each task separately; (2) storing the call chains of each task in a unified manner as a table to generate a service call hierarchy table; and (3) storing the call chains of each task in a unified manner as a graph to generate a service call hierarchy graph.

[0077] Below, examples will be given regarding the above method (3), such as Figure 4 As shown, with Figure 4 A single node can provide multiple services. For ease of representation, we will... Figure 4 Each service in the system is simplified to be provided by only one node, but in reality, each service can also be provided by multiple nodes.

[0078] exist Figure 4 In this context, the services that node 0 can provide include: service w11, service w12, service w13 and service w14; the services that node 1 can provide include: service w21, service w22, service w23 and service w24; the services that node 2 can provide include: service w31, service w33, service w33, service w34 and service w35; and the services that node 3 can provide include: service w41, service w42, service w43 and service w44.

[0079] The call chain for task s11 starting from node 0 is as follows: starting from service w11, it calls services w21, w32, and w43 in sequence; the call chain for task s11' starting from node 0 is as follows: starting from service w11, it calls services w24, w35, and w44 in sequence; the call chain for task s12 starting from node 0 is as follows: starting from service w12, it calls services w23, w32, and w43 in sequence; the call chain for task s13 starting from node 0 is as follows: starting from service w13, it calls services w22, w33, and w45 in sequence; the call chain for task s13' starting from node 0 is as follows: starting from service w13, it calls services w24, w35, and w44 in sequence; and the call chain for task s14 starting from node 0 is as follows: starting from service w14, it calls services w34 and w43 in sequence.

[0080] Following the example in case (3) above, the call chain corresponding to task s11 is: service w11, service w21, service w32 and service w43. Among them, the key services identified are service w23, service w32 and service w43 (the other black areas in the figure are marked). The node corresponding to service w23 is node 1, the node corresponding to service w32 is node 2, and the node corresponding to service w43 is node 3. Then, node 1, node 2 and node 3 are key service nodes. By analogy, the key service nodes corresponding to each task in the call hierarchy diagram can be obtained. Each task in the call hierarchy diagram may contain candidate tasks or may not contain candidate tasks. It may also contain each task executed in the history of the distributed system.

[0081] After identifying the key services, each key service in any task call chain and each key service node corresponding to each key service are represented in the above storage method (2), as shown in Table 1 below:

[0082] Table 1

[0083] Task Key services Key service nodes s11 w32, w32, w43 2、3 s12 w23、w32w43 1、2、3 S13 none none s14 w43 3

[0084] Since critical services are frequently invoked services on the call chain and prone to thread resource bottlenecks, the corresponding critical service nodes are also frequently invoked nodes on the call chain that are prone to resource bottlenecks (or crash-prone nodes). Therefore, when determining whether a candidate task can be executed, it is only necessary to measure whether the idle threads of the critical service nodes to be invoked by the candidate task can execute the candidate task. Thus, before determining whether a candidate task can be executed, the number of idle threads of each critical service node corresponding to the candidate task must first be obtained, and then the minimum number of idle threads of the critical service nodes corresponding to the candidate task is determined based on the obtained number of idle threads.

[0085] Specifically, the method for determining the minimum number of idle threads corresponding to the current candidate task based on the number of idle threads of each key service node corresponding to the current candidate task includes: Comparison method 1, directly comparing the number of idle threads of each key service node corresponding to the current candidate task and determining the minimum value as the minimum number of idle threads; Comparison method 2, dividing each key service node corresponding to all tasks in the service call hierarchy into multiple node intervals, and determining the number of idle threads corresponding to each node interval, wherein the real-time number of idle threads of each node interval is the minimum value among the real-time idle threads of each node in that node interval; Then, when the current candidate task is obtained, determining which node interval(s) the key service node corresponding to the current candidate task is successfully matched with, and directly calling the minimum value of the number of idle threads of the successfully matched node interval as the minimum number of idle threads of the key service node corresponding to the current candidate task.

[0086] Specifically, the comparison method 1 described above uses real-time comparison and is suitable for situations where the number of candidate tasks is small, the number of key service nodes corresponding to the current candidate task is small, or the key service nodes corresponding to the current candidate task are widely distributed. The comparison method 2 described above is suitable for situations where the function scheduler schedules multiple candidate tasks when the real-time customer service of the distributed system is relatively stable, or when the number of key service nodes corresponding to the current candidate task is large and relatively concentrated.

[0087] To combine the advantages of the two comparison methods mentioned above, this application adopts a hierarchical (or layered) storage approach to store the real-time idle thread data of key service nodes for all tasks in the service call hierarchy. The bottom layer of the hierarchical storage is the real-time idle thread count at the service node level, while the middle and / or top layers are the real-time idle thread counts at the node interval level obtained from the bottom layer. Using this hierarchical storage approach, when a candidate task is obtained, the hierarchical storage model can be used regardless of whether the candidate task is applicable to comparison method 1 or comparison method 2. Furthermore, the hierarchical storage model can be updated periodically to be applicable to the next candidate task, improving the reusability of the hierarchical storage model. In addition, when the real-time customer service of the distributed system is relatively stable, the real-time idle thread data of each service node in the distributed system is relatively stable. This allows the hierarchical storage model to only update the real-time idle thread data of the service nodes and node intervals associated with the previous candidate task when judging the next candidate task, further improving the data reusability of the hierarchical storage model.

[0088] Therefore, in one embodiment, as Figure 5 As shown, step 202 involves obtaining the minimum number of idle threads for the key service nodes corresponding to each candidate task, including:

[0089] Step 2021: Construct a service node classification tree based on the key service nodes in the service call hierarchy.

[0090] The service node classification tree includes node ranges corresponding to all key service nodes and the real-time number of idle threads for each node range.

[0091] Step 2022: Determine the minimum number of idle threads for the key service nodes corresponding to each candidate task based on the service node classification tree.

[0092] The node intervals can be divided in two ways: Method 1) based on node continuity, or Method 2) based on key services as the aggregation unit. Method 1) places a high emphasis on node continuity; Method 2 places a high emphasis on the matching between key services and key service nodes.

[0093] Specifically, taking one of the scenarios in partitioning method 2) as an example, if the key services already stored in the service call hierarchy include key service w1 and key service w2, and the key service nodes corresponding to key service w1 are {1, 2, 4}; the key service nodes corresponding to key service w2 are {3, 5, 6, 8}; and the key service nodes corresponding to the key service w3 of the current candidate task are {3, 5, 6, 7}, then if key service w3 and key service w2 do not match through key service matching, but both key service w2 and key service w3 occupy nodes 3, 5, and 6, it may be impossible to accurately match and accurately predict the usage of each key service node corresponding to the current candidate task.

[0094] Therefore, as Figure 6As shown, in this embodiment, the above-mentioned partitioning method 1) is used to partition the node intervals. Specifically, a classification storage model is constructed using the idea of ​​a classification tree to obtain a service node classification tree. The classification tree idea refers to taking the items in the dataset as leaf nodes of the classification tree for a given dataset, and generalizing the leaf nodes to become nodes of the service node classification tree. The root node of the classification tree is the set of all leaf nodes. In this embodiment, the key service nodes stored in the service call hierarchy are set as node 1, node 2, node 3, node 4 and node 5. Node 1, node 2, node 3, node 4 and node 5 are continuous. Then the root node of the service node classification tree is the node interval [1, 5]. The first layer of leaf nodes under the node interval [1, 5] are the node interval [1, 3] and the node interval [4, 5]. The second layer of leaf nodes are the node interval [1, 2], the node interval [3, 3], the node interval [4, 4] and the node interval [5, 5]. The third layer of leaf nodes are the node interval [1, 1] and the node interval [2, 2]. Let's define a resource array {3, 5, 8, 2, 90} containing the real-time idle thread data corresponding to the node interval [1, 5]. Here, the real-time idle thread data for node 1 is 3, for node 2 it's 5, for node 3 it's 8, and so on. Then, the minimum number of idle threads corresponding to the node interval [1, 5] is 2, which is the total number of real-time idle threads in the node interval [1, 5]. Then refer to... Figure 6 Each node interval in the service node classification tree has a parameter [x, y]: z, where x and y are the interval node endpoints of the node interval, and z is the minimum number of idle threads in the resource array corresponding to the node interval, that is, the real-time idle thread data of the node interval.

[0095] Regarding the comparison method 1 described above, in one embodiment, such as Figure 7 As shown, step 2022 involves determining the minimum number of idle threads for the key service nodes corresponding to each candidate task based on the service node classification tree, including:

[0096] Step 0221: Query the real-time idle thread count of the key service nodes corresponding to each candidate task from the service node classification tree.

[0097] Continuing from the previous example, querying the real-time idle thread count of the key service nodes corresponding to each candidate task from the service node classification tree is equivalent to querying the real-time idle thread data of nodes [1,1], [2,2], [3,3], [4,4], and [5,5] at the bottom level of the service node classification tree.

[0098] Step 0222: For any candidate task, determine the minimum number of real-time idle threads of the key service node corresponding to the candidate task as the minimum number of idle threads of the key service node corresponding to the candidate task.

[0099] Continuing from the previous example, the real-time idle thread data of nodes [1,1], [2,2], [3,3], [4,4], and [5,5] are compared. The minimum value among the real-time idle thread data is 2. Therefore, the minimum number of idle threads for the key service node corresponding to the current candidate task is 2.

[0100] Regarding the comparison method 2 mentioned above, such as Figure 8 As shown, step 2022 involves determining the minimum number of idle threads for the key service nodes corresponding to each candidate task based on the service node classification tree, including:

[0101] Step 0223: For any candidate task, query the target node range to which the key service node corresponding to the candidate task belongs from the service node classification tree.

[0102] Specifically, for the comparison method 2 mentioned above, it is first necessary to determine the node interval consisting of the key service nodes corresponding to the current candidate task. Let the node interval consisting of the key service nodes corresponding to the current candidate task be [1, 4]. Continuing with the service node classification tree in the previous example, since the root node [1, 5] does not conform to this interval, we query its left and right sub-intervals downwards. The node intervals [1, 3] and [4, 4] found are successfully matched with the interval [1, 4] corresponding to the current candidate task. Therefore, the node intervals [1, 3] and [4, 4] are the target node intervals to which the key service nodes corresponding to the current candidate task belong.

[0103] Step 0224: Determine the minimum number of idle threads in the real-time idle thread count of the target node interval as the minimum number of idle threads for the critical service node corresponding to the candidate task.

[0104] In the previous example, the real-time idle thread data corresponding to the target node interval [1, 3] is 3, and the real-time idle thread data corresponding to the target node interval [4, 4] is 2. Comparing 3 and 2, the minimum value is 2. Therefore, 2 is taken as the minimum number of idle threads for the key service node corresponding to the current candidate task.

[0105] In this embodiment, the minimum value in the real-time idle thread data of the target node interval is directly called as the minimum number of idle threads for each key service node corresponding to the current candidate task, which improves the speed of scheduling a single candidate task. Furthermore, by reusing the classification storage model and some data in the classification storage model, the efficiency of the function scheduler in scheduling multiple candidate tasks is improved.

[0106] Before scheduling the next candidate task after scheduling the current candidate task, the service node classification tree needs to be updated. In one embodiment, such as... Figure 9As shown, after adjusting the number of concurrent tasks for the corresponding candidate tasks to obtain the target number of concurrent tasks for each candidate task, the task scheduling method further includes step 206: for any candidate task, based on the target number of concurrent tasks for the candidate task, update the real-time number of idle threads in the target node interval corresponding to the candidate task in the service node classification tree, and mark the updated target node interval.

[0107] Once the target task concurrency of the current candidate task is obtained, the terminal 102 can communicate with the entry service of the business processing cluster in the distributed system to directly schedule the current candidate task to start execution, or return the generated target task concurrency to the server 104.

[0108] Before the next candidate task is executed, the target node intervals in the service node classification tree are updated according to the target task concurrency of the current candidate task. The node intervals associated with the target node intervals are also updated. Specifically, following the node interval [1, 4] formed by the key service nodes corresponding to the current candidate task in the example above, the target node intervals [1, 4] are node intervals [1, 3] and [4, 4]. The z (i.e., real-time idle thread data) corresponding to the target node interval [1, 3] is adjusted to the target task concurrency to achieve the update; the z (i.e., real-time idle thread data) corresponding to the target node interval [4, 4] is adjusted to the target task concurrency to achieve the update; and the z (i.e., real-time idle thread data) corresponding to the root node interval [1, 5] associated with the target node interval is adjusted to the target task concurrency to achieve the update. Furthermore, after the current candidate task is completed, the real-time idle thread counts corresponding to each target node interval are reset, achieving a reverse update.

[0109] like Figure 6 As shown, the delay tagging refers to marking the target node interval and the node intervals associated with it. The tagging can use the formula "Lazy = - number of concurrent targets in the current candidate task". After the current candidate task is completed, the delay tags corresponding to each target node interval are deleted. If the next candidate task's query for the minimum number of idle threads involves nodes in the target node interval of the current candidate task, then the delay tags are applied to each node in the target node interval of the current candidate task.

[0110] In one embodiment, such as Figure 10 As shown, in step 204, the concurrency of the corresponding candidate tasks is adjusted based on the minimum number of idle threads at each key service node to obtain the target concurrency of each candidate task, including:

[0111] Step 2041: Compare the number of concurrent tasks for each candidate task with the minimum number of idle threads for the critical service node corresponding to each candidate task to obtain the comparison results for each candidate task.

[0112] For any candidate task, such as the current candidate task, the comparison result represents the relationship between the number of concurrent tasks of the current candidate task and the minimum number of idle threads of the key service node corresponding to the current candidate task.

[0113] Step 2042: Based on the comparison results of each candidate task, adjust the number of concurrent tasks for the corresponding candidate tasks to obtain the target number of concurrent tasks for each candidate task.

[0114] Specifically, based on the comparison results of each candidate task, the concurrency of the corresponding candidate task is adjusted to obtain the target concurrency of each candidate task. This includes: for any candidate task, if the comparison result shows that the concurrency of the candidate task is greater than the minimum number of idle threads of the critical service node corresponding to the candidate task, then the concurrency of the candidate task is adjusted to be the same as the minimum number of idle threads; the minimum number of idle threads is the target concurrency of the candidate task. In this embodiment, for any candidate task, such as the current candidate task, when the comparison result shows that the concurrency of the current candidate task is greater than the minimum number of idle threads of the critical service node corresponding to the current candidate task, a rate-limiting approach is used to reduce the concurrency of the current candidate task to achieve non-blocking scheduling.

[0115] Terminal 102 obtains all candidate tasks and the concurrency of each candidate task from server 104 in the distributed system. Before the scheduled time / delay time, it schedules all candidate tasks one by one. When scheduling any candidate service, it takes that service as the current candidate task. Based on the service call hierarchy obtained from the registry center, it determines the key service nodes corresponding to the current candidate task. It generates a service node classification tree based on the key service nodes corresponding to each task in the service call hierarchy. The service node classification tree includes node intervals corresponding to all key service nodes and the real-time idle thread count for each node interval. It queries the service node classification tree based on the key service nodes corresponding to the current candidate task, either by comparing node intervals or by node... The comparison method determines the minimum number of idle threads for the key service nodes corresponding to the current candidate task. If the minimum number of idle threads for each key service node of the current candidate task is greater than or equal to the number of concurrent tasks for the current candidate task, it means that each key service node of the current candidate task can execute the current number of concurrent candidate tasks, and there is no need to adjust the number of concurrent tasks for the current candidate task. If the minimum number of idle threads for each key service node of the current candidate task is less than the number of concurrent tasks for the current candidate task, it means that each key service node of the current candidate task cannot execute the current number of concurrent candidate tasks, and in this case, the number of concurrent tasks for the current candidate task needs to be adjusted to the target number of concurrent tasks so that each key service node of the current candidate task can execute candidate tasks of the target number of concurrent tasks. Based on the minimum number of idle threads on the key service nodes of each candidate task, the concurrency of each candidate task is adjusted, enabling scheduling and planning for all candidate tasks. After adjusting the concurrency of each candidate task, for any given candidate task, each key service node can execute the candidate task with the target concurrency, achieving the effect of pre-planning by estimating node thread resource usage. During execution, this effectively reduces the probability of key service nodes becoming blocked while executing candidate tasks. Furthermore, by constructing a service node classification tree, the minimum value of the target node range can be directly used as the minimum number of idle threads on each key service node corresponding to the current candidate task, improving the scheduling speed of a single candidate task. Moreover, by reusing the classification storage model and some data within it, the efficiency of terminal 102 in scheduling multiple candidate tasks is improved.

[0116] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0117] Based on the same inventive concept, this application also provides a task scheduling apparatus for implementing the task scheduling method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more task scheduling apparatus embodiments provided below can be found in the limitations of the task scheduling method described above, and will not be repeated here.

[0118] In one embodiment, such as Figure 11 As shown, a task scheduling device 100 is provided, including: a first acquisition module 110, a second acquisition module 120, and an adjustment module 130, wherein:

[0119] The first acquisition module 110 is used to acquire all candidate tasks in the distributed system and the number of concurrent tasks for each candidate task; the candidate tasks represent the tasks in the distributed system that have currently had fault tolerance mechanisms implemented.

[0120] The second acquisition module 120 is used to acquire the minimum number of idle threads of the key service nodes corresponding to each candidate task;

[0121] The adjustment module 130 is used to adjust the task concurrency of the corresponding candidate tasks according to the minimum number of idle threads of each key service node, so as to obtain the target task concurrency of each candidate task; the target task concurrency is the number of tasks that each key service node can execute for the corresponding candidate task.

[0122] In one embodiment, the apparatus further includes a third acquisition module, which is used to:

[0123] Obtain the service call hierarchy, which includes the service node call chain of each task;

[0124] Service nodes with preset node identifiers in the service node call chain of each task in the service call hierarchy are identified as critical service nodes; the node identifier is used to identify service nodes whose probability of task scheduling blockage is greater than the preset probability value.

[0125] In one embodiment, the second acquisition module 120 includes:

[0126] The building module is used to construct a service node classification tree based on each key service node in the service call hierarchy. The service node classification tree includes node ranges corresponding to all key service nodes and the real-time idle thread count for each node range.

[0127] The matching module is used to determine the minimum number of idle threads for the key service nodes corresponding to each candidate task based on the service node classification tree.

[0128] In one embodiment, the matching module is further configured to query the real-time idle thread count of the key service node corresponding to each candidate task from the service node classification tree.

[0129] For any candidate task, the minimum number of real-time idle threads of the key service node corresponding to the candidate task is determined as the minimum number of idle threads of the key service node corresponding to the candidate task.

[0130] In one embodiment, the matching module is further configured to query the target node range to which the key service node corresponding to the candidate task belongs from the service node classification tree for any candidate task.

[0131] The minimum number of idle threads in the target node range is determined as the minimum number of idle threads for the critical service node corresponding to the candidate task.

[0132] In one embodiment, the device further includes:

[0133] The update module is used to update the real-time idle thread count of the target node interval corresponding to the candidate task in the service node classification tree based on the target task concurrency of the candidate task, and to mark the updated target node interval.

[0134] In one embodiment, the adjustment module 130 further includes:

[0135] The result generation module is used to compare the number of concurrent tasks of each candidate task with the minimum number of idle threads of the key service node corresponding to each candidate task to obtain the comparison result of each candidate task.

[0136] The adjustment module is used to adjust the number of concurrent tasks for each candidate task based on the comparison results of each candidate task, so as to obtain the target number of concurrent tasks for each candidate task.

[0137] In one embodiment, the adjustment module is further configured to, for any candidate task, adjust the concurrency of the candidate task to the same number as the minimum number of idle threads if the comparison result of the candidate task is that the number of concurrent tasks of the candidate task is greater than the minimum number of idle threads of the key service node corresponding to the candidate task; the minimum number of idle threads is the target number of concurrent tasks of the candidate task.

[0138] Each module in the aforementioned task scheduling device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0139] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 12 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a task scheduling method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0140] Those skilled in the art will understand that Figure 12 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0141] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0142] Retrieve all candidate tasks in the distributed system and the concurrency of each candidate task; candidate tasks represent tasks in the distributed system that have currently had fault-tolerant mechanisms implemented.

[0143] Obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task;

[0144] Based on the minimum number of idle threads at each key service node, the concurrency of the corresponding candidate tasks is adjusted to obtain the target concurrency of each candidate task; the target concurrency is the number of tasks that each key service node can execute for the corresponding candidate task.

[0145] In one embodiment, when the processor executes the computer program, it further performs the following steps: obtaining a service call hierarchy relationship, which includes a service node call chain for each task; identifying service nodes with preset node identifiers in the service node call chains for each task in the service call hierarchy relationship as critical service nodes; the node identifier is used to identify service nodes whose probability of task scheduling blockage is greater than a preset probability value.

[0146] In one embodiment, when the processor executes the computer program, it further performs the following steps: constructing a service node classification tree based on each key service node in the service call hierarchy; the service node classification tree includes node intervals corresponding to all key service nodes and the real-time number of idle threads for each node interval; and determining the minimum number of idle threads for each candidate task corresponding to the key service node based on the service node classification tree.

[0147] In one embodiment, when the processor executes the computer program, it further performs the following steps: querying the real-time idle thread count of the key service node corresponding to each candidate task from the service node classification tree; and for any candidate task, determining the minimum value among the real-time idle thread counts of the key service node corresponding to the candidate task as the minimum idle thread count of the key service node corresponding to the candidate task.

[0148] In one embodiment, when the processor executes the computer program, it further performs the following steps: for any candidate task, query the target node range to which the key service node corresponding to the candidate task belongs from the service node classification tree; and determine the minimum value among the real-time idle thread counts of the target node range as the minimum idle thread count of the key service node corresponding to the candidate task.

[0149] In one embodiment, when the processor executes the computer program, it further performs the following steps: for any candidate task, based on the number of concurrent target tasks of the candidate task, updates the real-time number of idle threads in the target node interval corresponding to the candidate task in the service node classification tree, and marks the updated target node interval.

[0150] In one embodiment, when the processor executes the computer program, it further performs the following steps: comparing the number of concurrent tasks for each candidate task with the minimum number of idle threads for the critical service node corresponding to each candidate task to obtain the comparison result for each candidate task; and adjusting the number of concurrent tasks for the corresponding candidate task based on the comparison result for each candidate task to obtain the target number of concurrent tasks for each candidate task.

[0151] In one embodiment, when the processor executes the computer program, it further implements the following steps: for any candidate task, if the comparison result of the candidate tasks is that the number of concurrent tasks of the candidate task is greater than the minimum number of idle threads of the critical service node corresponding to the candidate task, then the number of concurrent tasks of the candidate task is adjusted to the same number as the minimum number of idle threads; the minimum number of idle threads is the target number of concurrent tasks of the candidate task.

[0152] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0153] Retrieve all candidate tasks in the distributed system and the concurrency of each candidate task; candidate tasks represent tasks in the distributed system that have currently had fault-tolerant mechanisms implemented.

[0154] Obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task;

[0155] Based on the minimum number of idle threads at each key service node, the concurrency of the corresponding candidate tasks is adjusted to obtain the target concurrency of each candidate task; the target concurrency is the number of tasks that each key service node can execute for the corresponding candidate task.

[0156] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining the service call hierarchy relationship, which includes the service node call chain of each task; identifying the service nodes with preset node identifiers in the service node call chain of each task in the service call hierarchy relationship as key service nodes; the node identifier is used to identify the service nodes whose probability of task scheduling blockage is greater than a preset probability value.

[0157] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: constructing a service node classification tree based on each key service node in the service call hierarchy; the service node classification tree includes node intervals corresponding to all key service nodes and the real-time number of idle threads for each node interval; and determining the minimum number of idle threads for each candidate task corresponding to the key service node based on the service node classification tree.

[0158] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: querying the real-time idle thread count of the key service node corresponding to each candidate task from the service node classification tree; for any candidate task, determining the minimum value among the real-time idle thread counts of the key service node corresponding to the candidate task as the minimum idle thread count of the key service node corresponding to the candidate task.

[0159] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for any candidate task, query the target node range to which the key service node corresponding to the candidate task belongs from the service node classification tree; and determine the minimum value among the real-time idle thread counts of the target node range as the minimum idle thread count of the key service node corresponding to the candidate task.

[0160] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for any candidate task, based on the target task concurrency of the candidate task, updates the real-time idle thread count of the target node interval corresponding to the candidate task in the service node classification tree, and marks the updated target node interval.

[0161] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: comparing the number of concurrent tasks for each candidate task with the minimum number of idle threads for the critical service node corresponding to each candidate task to obtain the comparison result for each candidate task; and adjusting the number of concurrent tasks for the corresponding candidate task based on the comparison result of each candidate task to obtain the target number of concurrent tasks for each candidate task.

[0162] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: for any candidate task, if the comparison result of the candidate task is that the number of concurrent tasks of the candidate task is greater than the minimum number of idle threads of the critical service node corresponding to the candidate task, then the number of concurrent tasks of the candidate task is adjusted to the same number as the minimum number of idle threads; the minimum number of idle threads is the target number of concurrent tasks of the candidate task.

[0163] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0164] Retrieve all candidate tasks in the distributed system and the concurrency of each candidate task; candidate tasks represent tasks in the distributed system that have currently had fault-tolerant mechanisms implemented.

[0165] Obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task;

[0166] Based on the minimum number of idle threads at each key service node, the concurrency of the corresponding candidate tasks is adjusted to obtain the target concurrency of each candidate task; the target concurrency is the number of tasks that each key service node can execute for the corresponding candidate task.

[0167] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining the service call hierarchy relationship, which includes the service node call chain of each task; identifying the service nodes with preset node identifiers in the service node call chain of each task in the service call hierarchy relationship as key service nodes; the node identifier is used to identify the service nodes whose probability of task scheduling blockage is greater than a preset probability value.

[0168] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: constructing a service node classification tree based on each key service node in the service call hierarchy; the service node classification tree includes node intervals corresponding to all key service nodes and the real-time number of idle threads for each node interval; and determining the minimum number of idle threads for each candidate task corresponding to the key service node based on the service node classification tree.

[0169] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: querying the real-time idle thread count of the key service node corresponding to each candidate task from the service node classification tree; for any candidate task, determining the minimum value among the real-time idle thread counts of the key service node corresponding to the candidate task as the minimum idle thread count of the key service node corresponding to the candidate task.

[0170] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for any candidate task, query the target node range to which the key service node corresponding to the candidate task belongs from the service node classification tree; and determine the minimum value among the real-time idle thread counts of the target node range as the minimum idle thread count of the key service node corresponding to the candidate task.

[0171] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for any candidate task, based on the target task concurrency of the candidate task, updates the real-time idle thread count of the target node interval corresponding to the candidate task in the service node classification tree, and marks the updated target node interval.

[0172] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: comparing the number of concurrent tasks for each candidate task with the minimum number of idle threads for the critical service node corresponding to each candidate task to obtain the comparison result for each candidate task; and adjusting the number of concurrent tasks for the corresponding candidate task based on the comparison result of each candidate task to obtain the target number of concurrent tasks for each candidate task.

[0173] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: for any candidate task, if the comparison result of the candidate task is that the number of concurrent tasks of the candidate task is greater than the minimum number of idle threads of the critical service node corresponding to the candidate task, then the number of concurrent tasks of the candidate task is adjusted to the same number as the minimum number of idle threads; the minimum number of idle threads is the target number of concurrent tasks of the candidate task.

[0174] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0175] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0176] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0177] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A task scheduling method, characterized in that, The method includes: Obtain all candidate tasks in the distributed system and the task concurrency of each candidate task; the candidate task represents the task in the distributed system that has currently had a fault tolerance mechanism executed; the task concurrency of the candidate task represents the number of accesses or requests when multiple clients concurrently access or request the same node server based on the candidate task; Obtain the service call hierarchy, which includes the service node call chain of each task; Service nodes with preset node identifiers in the service node call chain of each task in the service call hierarchy are identified as critical service nodes; the node identifier is used to identify service nodes whose probability of task scheduling blockage is greater than a preset probability value. Obtain the minimum number of idle threads for the key service nodes corresponding to each candidate task; The comparison results of each candidate task are obtained by comparing the number of concurrent tasks of each candidate task with the minimum number of idle threads of the key service node corresponding to each candidate task. For any candidate task, if the comparison result of the candidate task shows that the number of concurrent tasks of the candidate task is greater than the minimum number of idle threads of the key service node corresponding to the candidate task, then the number of concurrent tasks of the candidate task is adjusted to be the same as the minimum number of idle threads; the minimum number of idle threads is the target number of concurrent tasks of the candidate task, and the target number of concurrent tasks is the number of tasks that each key service node can execute for the corresponding candidate task.

2. The method according to claim 1, characterized in that, The step of obtaining the minimum number of idle threads for the key service nodes corresponding to each candidate task includes: Based on the key service nodes in the service call hierarchy, a service node classification tree is constructed; the service node classification tree includes node intervals corresponding to all the key service nodes and the real-time idle thread count for each node interval. Based on the service node classification tree, determine the minimum number of idle threads for the key service nodes corresponding to each candidate task.

3. The method according to claim 2, characterized in that, The step of determining the minimum number of idle threads for the key service nodes corresponding to each candidate task based on the service node classification tree includes: Query the real-time idle thread count of the key service node corresponding to each candidate task from the service node classification tree; For any candidate task, the minimum number of real-time idle threads of the key service node corresponding to the candidate task is determined as the minimum number of idle threads of the key service node corresponding to the candidate task.

4. The method according to claim 2, characterized in that, Based on the service node classification tree, determine the minimum number of idle threads for the key service nodes corresponding to each candidate task, including: For any candidate task, query the target node range to which the key service node corresponding to the candidate task belongs from the service node classification tree; The minimum number of real-time idle threads in the target node range is determined as the minimum number of idle threads for the critical service node corresponding to the candidate task.

5. The method according to any one of claims 2-4, characterized in that, After adjusting the concurrency of the corresponding candidate tasks to obtain the target concurrency of each candidate task, the method further includes: For any candidate task, based on the target task concurrency of the candidate task, the real-time idle thread count of the target node interval corresponding to the candidate task in the service node classification tree is updated, and the updated target node interval is marked.

6. A task scheduling device, characterized in that, The device includes: The first acquisition module is used to acquire all candidate tasks in the distributed system and the task concurrency of each candidate task; the candidate task represents the task in the distributed system that has currently had a fault tolerance mechanism executed; the task concurrency of the candidate task represents the number of accesses or requests when multiple clients concurrently access or request the same node server based on the candidate task. The third acquisition module is used to acquire the service call hierarchy, which includes the service node call chain of each task; service nodes with preset node identifiers in the service node call chain of each task in the service call hierarchy are identified as key service nodes; the node identifier is used to identify service nodes whose probability of task scheduling blockage is greater than a preset probability value. The second acquisition module is used to acquire the minimum number of idle threads of the key service nodes corresponding to each candidate task; An adjustment module is used to compare the number of concurrent tasks for each candidate task with the minimum number of idle threads for the corresponding critical service node to obtain a comparison result for each candidate task. For any candidate task, if the comparison result shows that the number of concurrent tasks for the candidate task is greater than the minimum number of idle threads for the corresponding critical service node, then the number of concurrent tasks for the candidate task is adjusted to be the same as the minimum number of idle threads. The minimum number of idle threads is the target number of concurrent tasks for the candidate task, and the target number of concurrent tasks is the number of tasks that each critical service node can execute for the corresponding candidate task.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and system for guaranteeing application service quality in distributed environment

    CN104486129A

  • Distributed task scheduling method and device, electronic equipment and storage medium

    CN114625533A