Task scheduling processing method and device, task controller and readable storage medium
By separating latency-sensitive and non-latency-sensitive tasks, prioritizing latency-sensitive tasks using a fast-channel queue, and balancing resources through preemption and sleep mechanisms, the problem of latency-sensitive tasks being blocked in task scheduling is solved, achieving consistency and efficiency in task processing.
Patent Information
- Application Number
- CN202511825606.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-05
- Publication Date
- 2026-02-27
AI Technical Summary
In existing task scheduling methods, latency-sensitive tasks are often blocked by non-latency-sensitive tasks, resulting in excessive processing latency and long queue waiting times, which affects the consistency and timeliness of task processing.
By separating latency-sensitive tasks from non-latency-sensitive tasks, a fast-channel queue is used to prioritize the retrieval of latency-sensitive tasks, and the state is modified and the transaction is terminated after successful execution. Meanwhile, non-latency-sensitive tasks are preempted by the execution cluster, and preemption and hibernation mechanisms are set up to balance resource utilization.
It improves the responsiveness of latency-sensitive tasks, ensures the consistency of task execution and overall resource utilization, avoids task omissions and duplicate executions, and enhances the system's processing capacity.
Smart Images

Figure CN121579172A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a task scheduling processing method and device, a task controller and a readable storage medium. BACKGROUND
[0002] In the current digital background, a large number of asynchronous tasks need to be processed in the software development process, among which the business data has a very high requirement on processing efficiency, and needs to maintain high consistency and reliability, that is, success or failure at the same time in a transaction; at the same time, the system also needs to cope with business peak to guarantee high throughput.
[0003] However, the existing task scheduling method has various tasks, which are sensitive to delay, have different processing time and depend on resources, resulting in that the delay-sensitive tasks are often blocked by non-delay-sensitive tasks, causing problems such as processing delay exceeding the standard, long queue waiting time, affecting the consistency and timeliness of task processing. SUMMARY
[0004] The present application aims to reduce the processing delay of delay-sensitive tasks.
[0005] Therefore, the first aspect of the present application provides a task scheduling processing method, comprising:
[0006] extracting a target business from a business execution request in response to the business execution request;
[0007] starting a target transaction, decomposing the target business into a plurality of tasks, and submitting delay-sensitive tasks in the plurality of tasks to the target transaction, wherein the task state of the delay-sensitive tasks submitted to the target transaction is a first state;
[0008] passing the delay-sensitive tasks in the target transaction to a fast channel queue for execution by an execution body in priority, and modifying the first state to a second state after successful execution;
[0009] releasing the target transaction in the case that the task state of the delay-sensitive tasks in the target transaction is all modified to the second state.
[0010] In the above technical solution, the business execution request is initiated by a user, an internal module or an external system, and is a request for triggering task scheduling processing.
[0011] The target business is a specific business matter to be processed extracted from the business execution request.
[0012] The target transaction is a transaction unit started to guarantee the consistency and integrity of the execution of delay-sensitive tasks, and is used for unified management of delay-sensitive tasks.
[0013] The delay-sensitive task is a task with high requirements for execution response time and needs to be processed in priority.
[0014] The non-delay-sensitive task is a task with low requirements for execution response time and delay execution does not have a significant impact on the business.
[0015] The first state is an initial state of the delay-sensitive task after being submitted to the target transaction, indicating that the task enters transaction management but is not executed or is to be executed.
[0016] The fast channel queue is a queue specially used to store and dispatch delay-sensitive tasks, and has a higher priority than the ordinary queue, which is used to ensure that the task is dispatched in priority.
[0017] The execution body is a specific executor of the task.
[0018] The second state is a state changed after the delay-sensitive task is successfully executed by the execution body, and is used to indicate that the task is successfully executed.
[0019] In the above technical solution, after the business execution request is sent out, the target business is filtered and extracted from the business execution request in response to the business execution request. Then, the target transaction is started, the target business extracted is divided into multiple tasks, the delay-sensitive task is filtered from the multiple tasks, and the delay-sensitive task is submitted to the target transaction. In this way, the delay-sensitive task and the non-delay-sensitive task can be separated. The task state of the delay-sensitive task submitted to the target transaction is identified as the first state; and the delay-sensitive task in the target transaction is delivered to the fast priority channel queue, which is pushed to the execution body in priority through the priority channel queue, so that the execution body can be dispatched and processed in priority without waiting for the non-delay-sensitive task, which is beneficial to shorten the response time of the delay-sensitive task and improve the timeliness of the delay-sensitive task. For the delay-sensitive task that has been successfully executed, the task state is modified to the second state; through the task identification, the completed delay-sensitive task and the uncompleted delay-sensitive task can be quickly identified, which can avoid omission of the delay-sensitive task on the one hand and repeated execution of the delay-sensitive task on the other hand. With the gradual completion of the delay-sensitive task in the target transaction, when all the delay-sensitive tasks in the target transaction are completed, i.e., all the delay-sensitive task identifiers in the target transaction are modified to the second state, the target transaction is released; in this way, on the one hand, the delay-sensitive task can be executed quickly by entering the target transaction and then entering the fast channel queue, without waiting for the non-delay-sensitive task to be executed, thereby reducing the execution delay of the delay-sensitive task; on the other hand, by setting the target transaction and releasing the target transaction only when the task state of the delay-sensitive task is all changed to the second state, the consistency of the completion of the delay-sensitive task in the target transaction is ensured, thereby avoiding the risk of data deviation caused by different execution progress of the task.
[0020] In some embodiments, the delay-sensitive task in the plurality of tasks is submitted to the target transaction, including:
[0021] The task type of each task is determined from the business information of the target transaction, and the task type includes the delay-sensitive task.
[0022] The delay-sensitive task is submitted to the target transaction, and the task state of the delay-sensitive task is set to the first state.
[0023] In the above technical solution, the business information is various information related to the target transaction, including business type, processing requirement, task component, time limit, etc.
[0024] The task type is a category according to the task execution requirement, timeliness, etc., which is mainly divided into delay-sensitive task and non-delay-sensitive task.
[0025] In the above technical solution, the task type of each task is confirmed from the business information of the target transaction, and the delay-sensitive task is selected and submitted to the target transaction, and the task state is modified to the first state. In this way, the task type can be accurately distinguished based on comprehensive business information, avoiding misjudgment of non-delay-sensitive tasks as delay-sensitive tasks to occupy high priority resources, or missing delay-sensitive tasks to cause delay execution, improving the accuracy of task classification and ensuring the rationality of resource allocation.
[0026] In some embodiments, the delay-sensitive task in the target transaction is transmitted to the fast channel queue for execution by the execution body, and the first state is modified to the second state after successful execution, including:
[0027] The delay-sensitive task in the target transaction is transmitted to the scheduler, and the delay-sensitive task includes a task serial number and a task version number.
[0028] The scheduler performs version checking according to the task version number, and in the case of passing the version checking, the first state of the delay-sensitive task is changed to the third state according to the task serial number.
[0029] The delay-sensitive task is transmitted to the fast channel queue for execution by the execution body, and the third state is changed to the second state after successful execution.
[0030] In the above technical solution, the scheduler is a core component responsible for version checking, state changing and transmitting the delay-sensitive task to the fast channel queue, connecting the target transaction and the fast channel queue.
[0031] The task serial number is a serial number allocated to the delay-sensitive task.
[0032] The task version number is a number identifying a delay-sensitive task version, which changes with task updates, and is used to determine whether the task is a valid version.
[0033] The version check is a process of checking the task version number by the scheduler to confirm whether the task meets the current business execution requirements.
[0034] The third state is a state modified by the scheduler after the delay-sensitive task passes the version check.
[0035] In the above technical solution, the delay-sensitive task contains a task serial number and a task version number, and the delay-sensitive task in the target transaction is passed to the scheduler, so that the scheduler can perform version check on the task version number. If the version check passes, the task state can be modified according to the task serial number. The version check avoids execution abnormalities caused by task version errors, and the state change according to the task serial number prevents task processing order confusion. In particular, in a multi-task association scenario, it ensures that the subsequent operation is performed after the previous task processing is completed, reduces business logic errors, and improves the standardization and reliability of task scheduling.
[0036] In some technical solutions, the plurality of tasks includes delay-sensitive tasks and non-delay-sensitive tasks.
[0037] After starting the target transaction, decomposing the target business into a plurality of tasks, and submitting the delay-sensitive tasks in the plurality of tasks to the target transaction, the task scheduling processing method further includes:
[0038] The non-delay-sensitive tasks are allocated to the ordinary channel queue for preemption processing by the plurality of execution body clusters.
[0039] In the above technical solution, the ordinary channel queue is a queue dedicated to storing and scheduling non-delay-sensitive tasks, and has a lower priority than the fast channel queue.
[0040] The execution body cluster is composed of a plurality of execution bodies and has the ability to jointly preempt and process non-delay-sensitive tasks in the ordinary channel queue.
[0041] In the above technical solution, after the target business is decomposed into a plurality of tasks, the non-delay-sensitive tasks therein are allocated to the ordinary channel queue for preemption processing by the plurality of execution body clusters. In this way, the non-delay-sensitive tasks are scheduled separately from the delay-sensitive tasks, which not only ensures that the delay-sensitive tasks have priority to use high-priority resources, but also improves the processing efficiency of the non-delay-sensitive tasks through distributed processing by the execution body clusters, avoids task accumulation, and improves overall resource utilization.
[0042] In some embodiments, the non-delay-sensitive task is assigned to the common channel queue, and is preempted by the plurality of execution clusters, including:
[0043] The non-delay-sensitive task is assigned to the common channel queue.
[0044] In response to receiving the preemption request of the execution cluster, the order of the non-delay-sensitive task in the common channel queue is randomly rearranged to obtain a rearranged queue.
[0045] The non-delay-sensitive task in the rearranged queue is preempted according to the rearranged order, wherein for the non-delay-sensitive task that fails to be preempted, the next non-delay-sensitive task after the non-delay-sensitive task is preempted; and for the non-delay-sensitive task that succeeds in being preempted, a distributed lock is added to the non-delay-sensitive task, and the distributed lock prevents preemption of other execution clusters.
[0046] The execution cluster acquires the non-delay-sensitive task that succeeds in being preempted to an execution cluster task queue of the execution cluster.
[0047] In the above technical solutions, the preemption request is an application signal sent by the execution cluster to the system, requesting to acquire the non-delay-sensitive task in the common channel queue.
[0048] The distributed lock is a lock mechanism added to the non-delay-sensitive task that succeeds in being preempted, preventing other execution clusters from preempting the task again.
[0049] The execution cluster task queue is a queue used by the execution cluster to store the non-delay-sensitive task that succeeds in being preempted by the execution cluster.
[0050] In the above technical solutions, after the non-delay-sensitive task is assigned to the common channel queue, the execution cluster can send a preemption request, so that the task processing is triggered by the preemption request, and the task can be avoided from being ignored; in response to the preemption request of the execution cluster, the order of the non-delay-sensitive task in the common channel queue is rearranged to form a rearranged queue, and the execution cluster can preempt the non-delay-sensitive task according to the rearranged order, so that all tasks have equal opportunity to be preempted, and the task backlog can be prevented from being long-term; for the non-delay-sensitive task that fails to be preempted, the next non-delay-sensitive task is preempted, and for the non-delay-sensitive task that succeeds in being preempted, a distributed lock is added, so that the task can be avoided from being preempted repeatedly, and the uniqueness of the task processing is ensured; the execution cluster acquires the non-delay-sensitive task that succeeds in being preempted to the execution cluster task queue of the execution cluster, so that the execution cluster can process the non-delay-sensitive task that succeeds in being preempted. In this way, the distributed lock improves the fairness and accuracy of task preemption, and reduces resource waste.
[0051] In some embodiments, the non-delay-sensitive task has a task source identifier and a source internal task identifier.
[0052] In response to receiving the preemption request of the execution cluster, the order of the non-delay-sensitive tasks in the common channel queue is randomly rearranged, including:
[0053] In response to receiving the preemption request of the execution cluster, the non-delay-sensitive tasks in the common channel queue are grouped according to the task source identifier.
[0054] For each group, the groups are randomly rearranged according to the task source identifier, and within each group, the non-delay-sensitive tasks are randomly rearranged according to the intra-source task identifier.
[0055] In the above technical solution, the task source identifier is an identifier used to distinguish the source of the non-delay-sensitive task, such as the business module to which the task belongs, the system that initiates, etc.
[0056] The intra-source task identifier is an identifier used to distinguish different non-delay-sensitive tasks under the same task source.
[0057] In the above technical solution, the non-delay-sensitive tasks in the common channel queue are grouped according to the task source identifier, and each group is randomly rearranged; then within each group, the non-delay-sensitive tasks are randomly rearranged according to the intra-source task identifier. In this way, the tasks of the same task source can be prevented from being preempted by a certain execution cluster, resulting in a single source of tasks processed by other execution clusters, and achieving balanced allocation of task sources; at the same time, the intra-group random rearrangement ensures fair preemption of tasks from the same source, improving the balance of overall task allocation.
[0058] In some technical solutions, optionally, after the execution cluster successfully preempts the non-delay-sensitive task to the execution cluster task queue of the execution cluster, the task scheduling processing method further includes:
[0059] Counting the number of continuously preempts successful non-delay-sensitive tasks;
[0060] If the number of continuously preempts successful non-delay-sensitive tasks reaches a first number, then the first count value is incremented by 1, the number of continuously preempts successful non-delay-sensitive tasks is cleared, and the step of counting the number of continuously preempts successful non-delay-sensitive tasks is returned, wherein the initial value of the first count value is 0;
[0061] If the first count value reaches a first count threshold, then the execution cluster is put to sleep for a first duration, and then continues to preempt non-delay-sensitive tasks.
[0062] In the above technical solution, the number of continuous preempts successful is the number of non-delay-sensitive tasks that the execution cluster continuously successfully preempts.
[0063] The first number is a threshold for judging whether the execution cluster continuously preempts successfully reaches a certain scale.
[0064] The first count value is a number of times that a number of consecutive preemptions of the execution cluster reaches a first number, and an initial value is 0.
[0065] The first count threshold is a preset upper limit of the first count value.
[0066] The first time length is a time during which the execution cluster is in a sleep state due to the first count value reaching the threshold.
[0067] In the above technical solution, the number of consecutive preemptions of the non-delay-sensitive task is recorded, and if the number of consecutive preemptions of the non-delay-sensitive task reaches the first number, such as 10, the first count value is incremented by 1 when the number of consecutive preemptions reaches 10; at the same time, the number of consecutive preemptions is cleared and re-counted. A first count threshold is set, such as 5, and the execution cluster is in a sleep state when the first count value reaches 5, and can continue to preempt the non-delay-sensitive task after the first time length of sleep. By setting the count rule of consecutive preemptions and the sleep mechanism, the task accumulation of part of the execution cluster and the situation that part of the execution cluster has no task to process are prevented; the sleep mechanism provides preemption opportunities for other execution clusters, and improves the balance and efficiency of overall task scheduling.
[0068] Exemplarily, the first number is 4, the first count threshold is 2, and the first time length is 8 seconds; the execution cluster A starts to preempt tasks, and consecutively successfully preempts 4 tasks to reach the first number, the first count value is incremented by 1, the first count value becomes 1, and the number of consecutive preemptions is cleared; the preemption is continued, and 4 tasks are consecutively successfully preempted again, the first count value is incremented by 1, the first count value becomes 2, and the first count threshold is reached; the system sleeps the execution cluster A for 8 seconds, and other execution clusters can preempt tasks during the period to avoid excessive resource occupation of the execution cluster A.
[0069] In some technical solutions, optionally, after the execution cluster acquires the non-delay-sensitive task that is successfully preempted to the execution cluster task queue of the execution cluster, the task scheduling processing method further includes:
[0070] Counting the number of consecutive preemptions of the non-delay-sensitive task that is successfully preempted;
[0071] If the number of consecutive preemptions of the non-delay-sensitive task that is successfully preempted does not reach the first number, the second count value is incremented by 1, the execution cluster is in a sleep state for a second time length, the non-delay-sensitive task is continued to be preempted, and the step of counting the number of consecutive preemptions of the non-delay-sensitive task that is successfully preempted is returned, wherein an initial value of the second count value is 0.
[0072] If the second count value reaches the second count threshold, the execution cluster is put to sleep for a third time length after which the preempting of the non-delay-sensitive tasks is continued, wherein the third time length is greater than the second time length.
[0073] In the technical solution described above, the second count value is the number of times that the execution cluster continuously succeeds in preemption without reaching the first number, and the initial value is 0.
[0074] The second count threshold is a preset upper limit of the second count value.
[0075] The second time length is the time for which the execution cluster is put to sleep due to the number of continuous preemption successes not reaching the first number.
[0076] The third time length is the time for which the execution cluster is put to sleep due to the second count value reaching the threshold, and the third time length is greater than the second time length.
[0077] In the technical solution described above, in the case of low preemption efficiency of the execution cluster, a count rule and a ladder sleep mechanism are set to reduce the consumption of system resources caused by frequent and inefficient preemption of the execution cluster, and the ladder sleep mechanism is established by the third time length being greater than the second time length, so as to prompt the execution cluster with low preemption efficiency to reduce the preemption frequency, to release resources for other efficient execution clusters, and to improve the overall system resource utilization efficiency.
[0078] By way of example, the preset first number is 4, the second count threshold is 3, the second time length is 2 seconds, and the third time length is 12 seconds; the execution cluster B preempts tasks, succeeds in preemption of only 2 tasks for the first time, does not reach the first number, the second count value is incremented by 1, the second count value becomes 1, and the preemption is continued after the execution cluster is put to sleep for 2 seconds; succeeds in preemption of only 3 tasks for the second time, does not reach the first number, the second count value is incremented by 1 again, the second count value becomes 2, and the preemption is continued after the execution cluster is put to sleep for 2 seconds; succeeds in preemption of only 1 task for the third time, does not reach the first number, the second count value is incremented by 1, the second count value becomes 3, and the second count value reaches the second count threshold; the system puts the execution cluster B to sleep for 12 seconds to reduce the consumption of resources caused by the low-efficiency preemption thereof.
[0079] In some technical solutions, optionally, the non-delay-sensitive tasks in the rearranged queue are preempted in the rearranged order, comprising:
[0080] If no non-delay-sensitive task is preempted in the rearranged queue, the execution cluster is put to sleep for a fourth time length after which the preemption of the non-delay-sensitive tasks is continued.
[0081] In the technical solution described above, the fourth time length is the time for which the execution cluster is put to sleep when no task is preempted in the rearranged queue.
[0082] In the technical solution, for the execution body cluster that does not preempt any non-delay-sensitive task, the non-delay-sensitive task is continued to be preempted after the fourth time length of dormancy. Thus, for the case that the execution body cluster has no task to preempt, the dormancy mechanism is set to avoid the execution body cluster frequently initiating invalid preemption request and reduce the waste of system resources.
[0083] Exemplarily, the fourth time length is 5 seconds; the execution body cluster C sends a preemption request to the system, after the system randomly rearranges the tasks in the common channel queue, all the tasks are preempted by other execution body clusters, and there is no task in the queue; the execution body cluster C does not preempt any task, and the system dorms it for 5 seconds; after 5 seconds, the execution body cluster C initiates a preemption request again, at this time, the system has supplemented new tasks, and the execution body cluster C successfully preempts the tasks and processes them.
[0084] In some technical solutions, the execution body cluster comprises a plurality of execution body pools;
[0085] After the execution body cluster obtains the non-delay-sensitive tasks preempts successfully to the execution body cluster task queue of the execution body cluster, the task scheduling processing method further comprises:
[0086] The delay-sensitive tasks are obtained from the fast channel queue, and the non-delay-sensitive tasks are obtained from the execution body cluster task queue, wherein the ratio of the number of the obtained delay-sensitive tasks to the number of the obtained non-delay-sensitive tasks is a predetermined ratio, and the predetermined ratio is greater than 1;
[0087] A set of to-be-allocated tasks is generated, and the to-be-allocated tasks in the set of to-be-allocated tasks comprise delay-sensitive tasks and non-delay-sensitive tasks;
[0088] The set of to-be-allocated tasks is allocated to the plurality of execution body pools.
[0089] In the technical solution, the execution body pool is composed of a plurality of execution bodies, and is responsible for processing the allocated tasks.
[0090] The predetermined ratio is the ratio of the number of the obtained delay-sensitive tasks to the number of the obtained non-delay-sensitive tasks, and the ratio is greater than 1, such as 3:1.
[0091] The set of to-be-allocated tasks is composed of the set of obtained delay-sensitive tasks and non-delay-sensitive tasks, and is used for allocation to each execution body pool.
[0092] In the technical solution, the number ratio between the delay-sensitive tasks obtained from the fast channel queue and the non-delay-sensitive tasks obtained from the task queue of the execution body cluster is greater than 1, which ensures that the delay-sensitive tasks can still be preferentially processed within the execution body cluster and avoids being squeezed out of resources by the non-delay-sensitive tasks. The generated to-be-allocated task set is allocated to the multiple execution body pools, and the form of the to-be-allocated task set facilitates subsequent allocation of the to-be-allocated task set to the execution body pools according to rules, thereby improving the orderliness and efficiency of task processing within the execution body cluster.
[0093] For example, the execution body cluster D includes three execution body pools, and the predetermined ratio of the delay-sensitive tasks to the non-delay-sensitive tasks is 2:1. The execution body cluster D obtains six delay-sensitive tasks from the fast channel queue and three non-delay-sensitive tasks from the task queue of the execution body cluster, and a total of nine tasks form a to-be-allocated task set. Subsequently, the task set is allocated to the three execution body pools, and it is ensured that each execution body pool can preferentially process delay-sensitive tasks.
[0094] In some technical solutions, the allocation of the to-be-allocated task set to the multiple execution body pools includes:
[0095] The to-be-allocated tasks are grouped according to the task type and the task source identifier to obtain to-be-allocated task groups.
[0096] For each to-be-allocated task group, the to-be-allocated tasks in the to-be-allocated task group are allocated to the multiple execution body pools.
[0097] In the technical solution, after the to-be-allocated task set is grouped according to the task type, i.e., the delay-sensitive type or the non-delay-sensitive type, and the task source identifier, to-be-allocated task groups are formed. For each to-be-allocated task group, the to-be-allocated tasks in the to-be-allocated task group are allocated to the multiple execution body pools. In this way, by grouping according to the task type and the task source identifier, the same type and the same source of tasks can be concentrated or sequentially allocated to the execution body pools, which facilitates management and processing.
[0098] In some technical solutions, the multiple execution body pools include multiple execution body pools of different priority levels.
[0099] For each to-be-allocated task group, the allocation of the to-be-allocated tasks in the to-be-allocated task group to the multiple execution body pools includes:
[0100] The idle capacities of the multiple execution body pools of different priority levels are obtained.
[0101] For each to-be-allocated task group, the to-be-allocated tasks in the to-be-allocated task group are sequentially traversed according to the priority levels from high to low, and the idle capacities of the execution body pools are sequentially matched with the to-be-allocated tasks until multiple target execution body pools are selected from the multiple execution body pools.
[0102] The to-be-assigned task is assigned to a plurality of target executor pools to generate an executor pool task queue in the target executor pool.
[0103] In the technical solution, the executor pool of a priority level is a task processing unit divided according to the priority level of the task processed by the executor pool, and the executor pool of a high priority level is preferentially assigned a task and is usually equipped with better resource configuration.
[0104] The idle capacity is the remaining capacity of the executor pool that can currently accommodate a new task, that is, the difference between the total capacity of the executor pool and the number of assigned tasks.
[0105] The target executor pool is an executor pool selected from a plurality of executor pools of different priority levels and having sufficient idle capacity to undertake the to-be-assigned task.
[0106] The executor pool task queue is a queue in which the to-be-assigned task assigned to the target executor pool is stored, and the executor in the executor pool retrieves and executes the task in sequence.
[0107] In the technical solution, the task assignment rule based on the priority level of the executor pool and the idle capacity ensures that the executor pool of a high priority level processes a task preferentially, thereby improving the response speed of a critical task, and the idle capacity is matched with the task to avoid a decrease in processing efficiency of the executor pool due to task overload or waste of resources due to idle resources, thereby achieving efficient use of the resources of the executor pool.
[0108] In some technical solutions, after the to-be-assigned task is assigned to a plurality of target executor pools to generate an executor pool task queue in the target executor pool, the task scheduling processing method further includes:
[0109] The idle executor in the target executor pool polls the executor pool task queue;
[0110] If the to-be-assigned task is not polled in the executor pool task queue, the third count value is incremented by 1, and the executor pool task queue is polled again after a first time interval, wherein the initial value of the third count value is 0.
[0111] In the technical solution, the idle executor is an executor in the executor pool that currently does not process a task and is in a standby state.
[0112] The polling is an operation of checking, by the idle executor, whether there is a to-be-processed task in the executor pool task queue at a fixed frequency or in a sequence.
[0113] The third count value is a count value recording the number of times that the idle executor does not find a task in polling, and the initial value is 0.
[0114] The first time interval is a time interval at which the idle executor initiates polling again after not finding a task in polling.
[0115] In the technical solution, the idle execution body in the target execution body pool polls the execution body pool task queue, and a retry mechanism with a fixed time interval and a count rule is set to ensure that the execution body can discover and process new tasks in time and reduce the waiting time of the tasks. The retry mechanism with a fixed time interval can avoid resource consumption caused by frequent polling of the execution body, balance between the timeliness of task response and resource utilization, and improve the running stability of the execution body pool.
[0116] For example, the idle execution body of the target execution body pool starts to poll the task queue, no task to be processed is found, the third count value is increased by 1, the third count value becomes 1, and polling is performed again after a first time interval, for example, 2 seconds. No task is found, the third count value is increased by 1, the third count value becomes 2, and polling is performed again after a time interval of 2 seconds. During this period, the system adds a task to the queue, the execution body finds the task in the third polling, immediately calls the execution, and terminates the count.
[0117] In some technical solutions, if no task to be allocated is polled in the execution body pool task queue, the third count value is increased by 1, and after the execution body pool task queue is polled again after the first time interval, the task scheduling processing method further includes:
[0118] If the third count value reaches a third count threshold, the fourth count value is increased by 1, and the execution body pool task queue is polled again after a second time interval, wherein the second time interval is greater than the first time interval, and the initial value of the fourth count value is 0.
[0119] If the fourth count value reaches a fourth count threshold, the execution body pool task queue is polled again after a third time interval, and the third time interval is greater than the second time interval.
[0120] In the technical solution, the fourth count value is the number of times that the third count value reaches the third count threshold, and the initial value is 0.
[0121] The second time interval is the time interval at which the execution body polls again after the third count value reaches the threshold, and the second time interval is greater than the first time interval.
[0122] The fourth count threshold is a preset upper limit of the fourth count value.
[0123] The third time interval is the time interval at which the execution body polls again after the fourth count value reaches the threshold, and the third time interval is greater than the second time interval.
[0124] In the technical solution, the step-by-step extension of the polling interval gradually reduces the polling frequency as the number of invalid polling increases, greatly reducing the waste of resources in the long-time no-task scenario; the hierarchical counting rule makes the polling strategy more suitable for the actual task load, taking into account the task response demand and system resource saving, and improving the energy efficiency of the overall scheduling system.
[0125] Illustratively, the preset third counting threshold is 3, the first time interval is 2 seconds, the second time interval is 5 seconds, the fourth counting threshold is 3, and the third time interval is 10 seconds. The idle executor polling does not find a task, the third counting value accumulates to 3, reaches the threshold, the fourth counting value is incremented by 1, the fourth counting value becomes 1, and the second time interval of 5 seconds is executed after polling again; still no task, the third counting value is reset and accumulates to 3 again, the fourth counting value is incremented by 1, and the fourth counting value becomes 2; repeat until the fourth counting value reaches the fourth counting threshold of 3, and the subsequent polling is executed for the third time interval, the interval is extended to 10 seconds, and until a new task appears in the task queue.
[0126] The second aspect of the present application proposes a task scheduling processing device for implementing the steps of the task scheduling processing method as proposed in the first aspect of the present application, comprising:
[0127] The extraction module is configured to extract the target service from the service execution request in response to the service execution request.
[0128] The submission module is configured to start the target transaction, decompose the target service into a plurality of tasks, and submit the delay-sensitive tasks in the plurality of tasks to the target transaction, wherein the task state of the delay-sensitive tasks submitted to the target transaction is the first state.
[0129] The delivery module is configured to deliver the delay-sensitive tasks in the target transaction to the fast channel queue for execution by the executor, and modify the first state to the second state after successful execution.
[0130] The processing module is configured to release the target transaction if the task state of the delay-sensitive tasks in the target transaction is all modified to the second state.
[0131] In the above technical solution, the service execution request is initiated by a user, an internal module of the system, or an external system, and is a request for triggering task scheduling processing.
[0132] The target service is a specific business matter to be processed extracted from the service execution request.
[0133] The target transaction is a transaction unit started to ensure the consistency and integrity of the execution of delay-sensitive tasks, and is used for unified management of delay-sensitive tasks.
[0134] The delay-sensitive task is a task that requires extremely high execution response time and needs to be processed first.
[0135] The non-delay-sensitive task is a task with low response time requirement for execution, and delay execution does not have a significant impact on the business.
[0136] The first state is the initial state of the delay-sensitive task after being submitted to the target transaction, indicating that the task enters transaction management but is not executed or is to be executed.
[0137] The fast channel queue is a queue specially used to store and dispatch delay-sensitive tasks, and has a higher priority than the ordinary queue, and is used to ensure that the task is preferentially called.
[0138] The executor is a specific undertaker of the task execution.
[0139] The second state is the state changed after the delay-sensitive task is successfully executed by the executor, and is used to indicate that the task execution is successful.
[0140] In the above technical solution, after the business execution request is issued, the target business is filtered and extracted from the business execution request in response to the business execution request. Then the target transaction is started, the extracted target business is divided into multiple tasks, and the delay-sensitive task is filtered from the multiple tasks. The delay-sensitive task is submitted to the target transaction, so that the delay-sensitive task can be separated. The task state of the delay-sensitive task submitted to the target transaction is identified as the first state; and the delay-sensitive task in the target transaction is delivered to the fast priority channel queue, which is preferentially pushed to the executor through the priority channel queue, so that the executor can preferentially call and process without waiting for the non-delay-sensitive task, which is beneficial to shorten the response time of the delay-sensitive task and improve the timeliness of the delay-sensitive task. For the delay-sensitive task that has been successfully executed, the task state is modified to the second state; through the task identification, the completed delay-sensitive task and the uncompleted delay-sensitive task can be quickly identified, which can avoid omission of the delay-sensitive task on one hand, and can also avoid repeated execution of the delay-sensitive task on the other hand. With the gradual completion of the delay-sensitive task in the target transaction, when all the delay-sensitive tasks in the target transaction are completed, i.e. all the delay-sensitive task identifiers in the target transaction are modified to the second state, the target transaction is released; in this way, the completion progress of the delay-sensitive task in the target transaction can be supervised in real time through the target transaction, the omission problem caused by scattered processing of the task can be avoided, and the key task can be covered without dead angle; on the other hand, only after all the delay-sensitive tasks are completed, the subsequent transaction release link is entered, which can guarantee the consistency of the completion of the delay-sensitive task in the target transaction from the process, and thus the data deviation risk caused by different execution progress of the task can be avoided, which is beneficial to improve the integrity and accuracy of the business data.
[0141] The third aspect of the present application provides a task controller, comprising a processor and a memory, wherein the memory stores programs or instructions, and the processor implements the steps of the task scheduling processing method according to any one of the above technical solutions when executing the programs or instructions in the memory. Therefore, the application construction device has all the beneficial effects of the task scheduling processing method according to any one of the above technical solutions.
[0142] The fourth aspect of the present application provides a readable storage medium, wherein the readable storage medium stores programs or instructions, and the programs or instructions implement the steps of the task scheduling processing method according to any one of the above technical solutions when executed by a processor. Therefore, the readable storage medium has all the beneficial effects of the task scheduling processing method according to any one of the above technical solutions.
[0143] Additional aspects and advantages of the present application will be in part apparent and in part pointed out hereinafter. BRIEF DESCRIPTION OF DRAWINGS
[0144] The above and / or additional aspects and advantages of the present application will become apparent and be readily appreciated from the following description, including the appended drawings.
[0145] Figure 1 A system architecture diagram for the task scheduling processing method provided by the embodiments of the present application;
[0146] Figure 2 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application;
[0147] Figure 3 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application; Figure 2 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application;
[0148] Figure 4 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application; Figure 2 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application;
[0149] Figure 5 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application;
[0150] Figure 6 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application;
[0151] Figure 7 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application; Figure 6 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application;
[0152] Figure 8 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application; Figure 7 One of the flowcharts of the task scheduling processing method provided by the embodiments of the present application;
[0153] Figure 9 For Figure 7 One of the specific flowcharts after step S134 in the embodiment;
[0154] Figure 10 For Figure 7 The second of the specific flowcharts after step S134 in the embodiment;
[0155] Figure 11 For Figure 6 Another specific flowchart of step S132 in the embodiment;
[0156] Figure 12 The second of the logical flowchart of a task scheduling processing system for applying the task scheduling processing method provided by the embodiment of the present application;
[0157] Figure 13 For Figure 7 The third of the specific flowcharts after step S134 in the embodiment;
[0158] Figure 14 For Figure 13 A specific flowchart of step S137c in the embodiment;
[0159] Figure 15 For Figure 14 One of the specific flowcharts of step S138b in the embodiment;
[0160] Figure 16 For Figure 14 The second of the specific flowcharts of step S138b in the embodiment;
[0161] Figure 17 The third of the logical flowchart of a task scheduling processing system for applying the task scheduling processing method provided by the embodiment of the present application;
[0162] Figure 18 The fourth of the logical flowchart of a task scheduling processing system for applying the task scheduling processing method provided by the embodiment of the present application;
[0163] Figure 19 For Figure 14 The third of the specific flowcharts of step S138b in the embodiment;
[0164] Figure 20 The fifth of the logical flowchart of a task scheduling processing system for applying the task scheduling processing method provided by the embodiment of the present application;
[0165] Figure 21 The architecture diagram of a task scheduling system provided by the embodiment of the present application;
[0166] Figure 22A structural block diagram of a task scheduling and processing device provided in an embodiment of this application;
[0167] Figure 23 This is a structural block diagram of a task controller provided in an embodiment of this application. Detailed Implementation
[0168] To better understand the above-mentioned objectives, features, and advantages of this application, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0169] Many specific details are set forth in the following description in order to provide a full understanding of this application. However, this application may also be implemented in other ways different from those described herein. Therefore, the scope of protection of this application is not limited to the specific embodiments disclosed below.
[0170] Figure 1 This diagram illustrates the architecture of the task scheduling method provided in this application. The execution entity of the task scheduling method can be a client or a server. The client or server can transmit tasks to multiple execution entities via a scheduling module. These tasks include latency-sensitive tasks and non-latency-sensitive tasks, allowing each execution entity to process its received task.
[0171] The following reference Figures 2 to 23 This application describes a task scheduling processing method and apparatus, a task controller, and a readable storage medium according to some embodiments of the present application.
[0172] like Figure 2 As shown, this application provides a task scheduling processing method, the specific steps of which include:
[0173] S100: In response to a business execution request, extract the target business from the business execution request;
[0174] S120: Start the target transaction, decompose the target business into multiple tasks, and submit the latency-sensitive tasks among the multiple tasks to the target transaction. The task status of the latency-sensitive tasks submitted to the target transaction is the first state.
[0175] S140: Transfer the delay-sensitive tasks in the target transaction to the fast channel queue for priority execution by the executor, and change the first state to the second state after successful execution;
[0176] S160: If the task states of all delay-sensitive tasks in the target transaction are modified to the second state, terminate the target transaction.
[0177] In the above embodiments, the service execution request is initiated by a user, an internal module of the system or an external system, and is a request for triggering the task scheduling process.
[0178] The target service is a specific service matter to be processed extracted from the service execution request.
[0179] The target transaction is a transaction unit opened for the purpose of guaranteeing the consistency and integrity of the execution of delay-sensitive tasks, and is used for unified management of delay-sensitive tasks.
[0180] The delay-sensitive task is a task that requires extremely high execution response time and needs to be processed in priority.
[0181] The non-delay-sensitive task is a task that has a relatively low requirement for execution response time and a delay in execution will not have a significant impact on the business.
[0182] The first state is the initial state of the delay-sensitive task after it is submitted to the target transaction, indicating that the task enters transaction management but has not been executed or is waiting to be executed.
[0183] The fast lane queue is a queue dedicated to storing and scheduling delay-sensitive tasks, with a higher priority than ordinary queues, and is used to ensure that tasks are prioritized for retrieval.
[0184] The execution body is the specific undertaker of the task execution.
[0185] The second state is the state changed after the delay-sensitive task is successfully executed by the execution body, and is used to indicate that the task execution is successful.
[0186] In the above embodiments, after the service execution request is issued, the target service is screened and extracted from the service execution request in response to the service execution request. Then the target transaction is started, the extracted target service is divided into a plurality of tasks, the delay-sensitive task is screened from the plurality of tasks, and the delay-sensitive task is submitted to the target transaction, so that the separation of the delay-sensitive task can be realized. The task state of the delay-sensitive task submitted to the target transaction is identified as a first state; and the delay-sensitive task in the target transaction is delivered to a fast priority channel queue, which is preferentially pushed to the execution body through the priority channel queue, so that the execution body can preferentially call and process without waiting for the non-delay-sensitive task, which is beneficial to shorten the response time of the delay-sensitive task and improve the timeliness of the delay-sensitive task. For the delay-sensitive task that has been successfully executed, the task state identifier is modified to a second state; through the task identifier, the completed delay-sensitive task and the uncompleted delay-sensitive task can be quickly identified, which can avoid omission of the delay-sensitive task on the one hand and avoid repeated execution of the delay-sensitive task on the other hand. With the gradual completion of the delay-sensitive task in the target transaction, when all the delay-sensitive tasks in the target transaction are completed, i.e. all the delay-sensitive task identifiers in the target transaction are modified to the second state, the target transaction is released; in this way, the completion progress of the delay-sensitive task in the target transaction can be supervised in real time through the target transaction, the omission problem caused by scattered processing of the task can be avoided, and key tasks can be covered without dead angle; on the other hand, only after all the delay-sensitive tasks are completed, the subsequent transaction release link is entered, which can guarantee the consistency of the completion of the delay-sensitive task in the target transaction from the process, thereby avoiding the risk of data deviation caused by different execution progress of the task, and being beneficial to improve the integrity and accuracy of the business data.
[0187] As shown in Figure 3 In some embodiments, the delay-sensitive task in the plurality of tasks is submitted to the target transaction, specifically including the following steps:
[0188] S122: determining the task type of each task from the service information of the target service, the task type including the delay-sensitive task;
[0189] S124: submitting the delay-sensitive task to the target transaction, and setting the task state of the delay-sensitive task to the first state.
[0190] In the above embodiments, the service information is various information related to the target service, including the service type, the processing requirement, the task constituent element, the time limit, etc.
[0191] The task type is a category divided according to the task execution requirement, timeliness, etc., which is mainly divided into the delay-sensitive task and the non-delay-sensitive task here.
[0192] In the above embodiment, the task type of each task is confirmed from the service information of the target service, from which the delay-sensitive task is screened out and submitted to the target transaction, and the task state is modified to the first state. In this way, the task type can be accurately distinguished based on comprehensive service information, avoiding misjudgment of non-delay-sensitive tasks as delay-sensitive tasks to occupy high-priority resources, or missing delay-sensitive tasks to cause their delay execution, improving the accuracy of task classification and ensuring the rationality of resource allocation.
[0193] As shown in Figure 4 In some embodiments, the delay-sensitive task in the target transaction is optionally passed to the fast channel queue for execution by the execution body in priority, and the first state is modified to the second state after successful execution, specifically including the following steps:
[0194] S162: pass the delay-sensitive task in the target transaction to the scheduler, the delay-sensitive task containing a task serial number and a task version number;
[0195] S164: version check is performed by the scheduler according to the task version number, and in the case where the version check is passed, the first state of the delay-sensitive task is sequentially changed to the third state according to the task serial number;
[0196] S166: pass the delay-sensitive task to the fast channel queue for execution by the execution body in priority, and change the third state to the second state after successful execution.
[0197] In the above embodiment, the scheduler is a core component responsible for version checking, state changing and passing the delay-sensitive task to the fast channel queue, connecting the target transaction and the fast channel queue.
[0198] The task serial number is a serial number allocated for the delay-sensitive task.
[0199] The task version number is a number identifying the version of the delay-sensitive task, which changes with the task update and is used to determine whether the task is a valid version.
[0200] Version checking is a process of checking the task version number by the scheduler to confirm whether the task meets the current service execution requirements.
[0201] The third state is the state modified by the scheduler after the delay-sensitive task passes the version check.
[0202] In the above embodiment, the delay-sensitive task contains a task sequence number and a task version number, and the delay-sensitive task in the target transaction is delivered to the scheduler, so that the scheduler can perform version checking on the task version number, and if the version checking is passed, the task state of the task can be modified according to the task sequence number. Through version checking, execution exceptions caused by task version errors are avoided, and state changes according to task sequence numbers prevent task processing order from being chaotic, especially in a multi-task association scenario, ensuring that a previous task is processed before a subsequent operation is performed, reducing business logic errors, and improving the standardization and reliability of task scheduling.
[0203] Exemplarily, a black solid dot is a step starting point, and a hollow dot surrounding the solid dot represents a step end point, but the step end point is cycled back to the starting point. Figure 5 As shown in the figure, it is a task scheduling processing system applying the task scheduling processing method provided by the embodiments of the present application, which includes steps S1 to S8,
[0204] S1: business data processing, first complete S2: save business data and S3: save task information, then execute S4: transaction commit and synchronous push message; then execute S5: task sequence number and task version number update state to processing, which corresponds to the process of verifying the task version number in the present method, if the update is successful, execute S6: push to the fast channel queue, and if the push is successful, execute S8: return success, if the push fails, execute S7: update the task state to be processed, and then S8: return success. The processing and the to-be-processed correspond to the first state and the third state respectively.
[0205] The task scheduling processing method provided by the present application can be used for reference. Among them, the processing is the first state, and the to-be-processed is the third state.
[0206] As shown in the figure, Figure 6 In some embodiments, the plurality of tasks includes delay-sensitive tasks and non-delay-sensitive tasks.
[0207] After starting the target transaction, decomposing the target business into a plurality of tasks, and submitting the delay-sensitive tasks in the plurality of tasks to the target transaction, the task scheduling processing method further includes the following steps:
[0208] S130: distribute the non-delay-sensitive tasks to the ordinary channel queue, and perform preemption processing by the plurality of execution body clusters.
[0209] In the above embodiment, the ordinary channel queue is a queue specially storing and scheduling non-delay-sensitive tasks, and has a lower priority than the fast channel queue.
[0210] The execution body cluster is composed of a plurality of execution bodies, and has the ability to jointly preempt and process non-delay-sensitive tasks in the ordinary channel queue.
[0211] In the above embodiments, after the target service is decomposed into multiple tasks, the non-latency-sensitive tasks are assigned to a regular channel queue and preempted by multiple execution clusters. This separate scheduling of non-latency-sensitive and latency-sensitive tasks ensures that latency-sensitive tasks have priority access to high-priority resources, while the distributed processing of execution clusters improves the processing efficiency of non-latency-sensitive tasks, avoids task backlog, and increases overall resource utilization.
[0212] like Figure 7 As shown, in some embodiments, non-latency-sensitive tasks may optionally be assigned to a regular channel queue, where multiple execution clusters preemptively handle the task. Specifically, this includes the following steps:
[0213] S131: Assign non-latency-sensitive tasks to the normal channel queue;
[0214] S132: In response to receiving a preemption request from the execution cluster, randomly rearrange the order of non-delay-sensitive tasks in the normal channel queue to obtain a rearranged queue;
[0215] S133: For non-delay-sensitive tasks in the reordered queue, preemption is performed according to the reordered order. For non-delay-sensitive tasks that fail to be preempted, the next non-delay-sensitive task after the first one is preempted. For non-delay-sensitive tasks that are successfully preempted, a distributed lock is added to the non-delay-sensitive task to prevent other execution clusters from preempting it.
[0216] S134: Obtain the preempted non-delay-sensitive tasks into the execution cluster task queue through the execution cluster.
[0217] In the above embodiments, the preemption request is a signal sent by the execution cluster to the system, requesting to acquire non-delay-sensitive tasks in the normal channel queue.
[0218] Distributed locks are locking mechanisms added for non-latency-sensitive tasks that have successfully preempted, preventing other execution clusters from preempting the task again.
[0219] The execution cluster task queue is a queue used by the execution cluster to store non-delay-sensitive tasks that it has successfully preempted.
[0220] In the above embodiment, after the non-delay-sensitive task is assigned to the common channel queue, the execution cluster can send a preemption request, so that the task processing is triggered by the preemption request, and the task can be avoided from being ignored; in response to the preemption request of the execution cluster, the non-delay-sensitive tasks in the common channel queue are rearranged to form a rearranged queue, and the execution cluster can preempt the non-delay-sensitive tasks according to the rearranged order, so that all tasks can have equal opportunity to be preempted, and the task backlog can be prevented from being accumulated for a long time; for the continuous preemption that is not successful, and for the distributed lock that is added after the preemption is successful, the task can be avoided from being preempted repeatedly, and the uniqueness of the task processing can be ensured; through the execution cluster, the non-delay-sensitive task that is successfully preempted is obtained to the execution cluster task queue of the execution cluster, so that the execution cluster can process the non-delay-sensitive task that is successfully preempted. In this way, the distributed lock overall process improves the fairness and accuracy of task preemption, and reduces resource waste.
[0221] As shown in Figure 8 In some embodiments, the non-delay-sensitive task has a task source identifier and an intra-source task identifier.
[0222] In response to receiving the preemption request of the execution cluster, the order of the non-delay-sensitive tasks in the common channel queue is randomly rearranged, specifically including the following steps:
[0223] S132a: In response to receiving the preemption request of the execution cluster, the non-delay-sensitive tasks in the common channel queue are grouped according to the task source identifier.
[0224] S132b: For each group, the group is randomly rearranged between groups according to the task source identifier, and within each group, the non-delay-sensitive tasks are randomly rearranged according to the intra-source task identifier.
[0225] In the above embodiment, the task source identifier is an identifier used to distinguish the source of the non-delay-sensitive task, such as a business module to which the task belongs, an initiating system, etc.
[0226] The intra-source task identifier is an identifier used to distinguish different non-delay-sensitive tasks under the same task source.
[0227] In the above embodiment, the non-delay-sensitive tasks in the common channel queue are grouped according to the task source identifier, and then each group is randomly rearranged; and then within each group, the non-delay-sensitive tasks are randomly rearranged according to the intra-source task identifier. In this way, the tasks of the same task source can be avoided from being preempted by a certain execution cluster, so that the tasks processed by other execution clusters are prevented from being single-sourced, and the balanced distribution of the task source is achieved; at the same time, the intra-group random rearrangement ensures the fair preemption of the tasks of the same source, and improves the balance of the overall task distribution.
[0228] As shown in Figure 9In some embodiments, as shown, after the task scheduling method obtains the non-delay-sensitive tasks successfully preempted by the execution cluster to the execution cluster task queue of the execution cluster by executing the execution cluster, the method further comprises the following steps:
[0229] S135a: counting the number of non-delay-sensitive tasks successfully preempted in succession;
[0230] S135b: if the number of non-delay-sensitive tasks successfully preempted in succession reaches a first number, incrementing a first count value by 1, resetting the number of non-delay-sensitive tasks successfully preempted in succession to 0, and returning to the step of counting the number of non-delay-sensitive tasks successfully preempted in succession, wherein the initial value of the first count value is 0;
[0231] S135c: if the first count value reaches a first count threshold, the execution cluster is put to sleep for a first duration, and then continues to preempt non-delay-sensitive tasks.
[0232] In the above embodiment, the number of successful preemptions in succession is the number of non-delay-sensitive tasks successfully preempted in succession by the execution cluster.
[0233] The first number is a threshold value preset to determine whether the number of successful preemptions in succession by the execution cluster reaches a certain scale.
[0234] The first count value is the number of times the number of successful preemptions in succession by the execution cluster reaches the first number, and the initial value is 0.
[0235] The first count threshold is the upper limit of the first count value.
[0236] The first duration is the time for which the execution cluster is put to sleep when the first count value reaches the threshold value.
[0237] In the above embodiment, the number of non-delay-sensitive tasks successfully preempted in succession is recorded, and if the number of non-delay-sensitive tasks successfully preempted in succession reaches the first number, such as 10, the first count value is incremented by 1 when the number of successful preemptions in succession reaches 10; at the same time, the number of successful preemptions in succession is reset to 0 for re-counting. A first count threshold is also set, such as 5, and when the first count value reaches 5, the execution cluster is put to sleep, and after the first duration of sleep, the execution cluster can continue to preempt non-delay-sensitive tasks. In this way, by setting the count rule for successful preemptions in succession and the sleep mechanism, the accumulation of tasks in some execution clusters and the situation of no tasks available for processing in some execution clusters are prevented; the sleep mechanism provides preemption opportunities for other execution clusters, improving the balance and efficiency of overall task scheduling.
[0238] Exemplarily, the preset first number is 4, the first count threshold is 2, and the first time length is 8 seconds; the execution body cluster A starts to preempt tasks, and successfully preempts 4 tasks in succession, reaches the first number, the first count value is increased by 1, the first count value becomes 1, and the number of continuous preemptions is cleared; the preemption is continued, 4 tasks are successfully preempts in succession again, the first count value is increased by 1, the first count value becomes 2, and the first count threshold is reached; the system sleeps the execution body cluster A for 8 seconds, and other execution body clusters can preempt tasks during the period, so as to avoid that the execution body cluster A excessively occupies resources.
[0239] As shown in FIG. 1, Figure 10 In some embodiments, after the execution body cluster acquires the preempts successfully the non-delay-sensitive task to the execution body cluster task queue of the execution body cluster, the task scheduling processing method specifically further includes the following steps:
[0240] S136a: count the number of continuously preempts successfully the non-delay-sensitive task;
[0241] S136b: if the number of continuously preempts successfully the non-delay-sensitive task does not reach the first number, increase the second count value by 1, sleep the execution body cluster for a second time length, continue to preempt the non-delay-sensitive task, and return to the step of counting the number of continuously preempts successfully the non-delay-sensitive task, wherein the initial value of the second count value is 0;
[0242] S136c: if the second count value reaches a second count threshold, sleep the execution body cluster for a third time length, and continue to preempt the non-delay-sensitive task, wherein the third time length is greater than the second time length.
[0243] In the above embodiment, the second count value records the number of times that the number of continuously preempts successfully the execution body cluster does not reach the first number, and the initial value is 0.
[0244] The second count threshold is a preset upper limit of the second count value.
[0245] The second time length is the time for which the execution body cluster sleeps due to that the number of continuously preempts successfully does not reach the first number.
[0246] The third time length is the time for which the execution body cluster sleeps due to that the second count value reaches the threshold, and the third time length is greater than the second time length.
[0247] In the above embodiment, for the case that the preemption efficiency of the execution body cluster is low, the count rule and the ladder sleep mechanism are set, the consumption of system resources caused by the frequent and inefficient preemption of the execution body cluster is reduced, the ladder sleep mechanism is established by the third time length being greater than the second time length, the preemption frequency of the execution body cluster with low preemption efficiency is reduced, resources are released for other efficient execution body clusters, and the overall system resource utilization efficiency is improved.
[0248] For example, the system presets a first count of 4, a second counting threshold of 3, a second duration of 2 seconds, and a third duration of 12 seconds. When performing a preemption task for cluster B, if only 2 tasks are successfully preempted in the first instance, the first count is not reached, the second count is incremented by 1, the second count becomes 1, and the system sleeps for 2 seconds before continuing to preempt. If only 3 tasks are successfully preempted in the second instance, the first count is not reached, the second count is incremented by 1 again, the second count becomes 2, and the system sleeps for 2 seconds before continuing to preempt. If only 1 task is successfully preempted in the third instance, the first count is not reached, the second count is incremented by 1, the second count becomes 3, and the second count reaches the second counting threshold. The system will then make cluster B sleep for 12 seconds to reduce the resource consumption caused by its inefficient preemption.
[0249] like Figure 11 As shown, in some embodiments, optionally, non-delay-sensitive tasks in the rearranged queue are preempted according to the rearranged order, specifically including the following steps:
[0250] S133a: If no non-delay-sensitive task is preempted in the rearrangement queue, the cluster will continue to preempt non-delay-sensitive tasks after the fourth duration of sleep.
[0251] In the above embodiments, the fourth duration is the time during which the execution cluster sleeps when it has not preempted any tasks in the reorder queue.
[0252] In the above embodiments, for execution clusters that have not preempted any non-delay-sensitive tasks, they will sleep for a fourth duration before continuing to preempt non-delay-sensitive tasks. This sleep mechanism addresses the situation where an execution cluster has no tasks to preempt, preventing it from frequently initiating invalid preemption requests and reducing system resource waste.
[0253] For example, if the fourth duration is 5 seconds; execution cluster C sends a preemption request to the system. After the system randomly rearranges the tasks in the normal channel queue, all tasks have been preempted by other execution clusters, and there are no tasks in the queue. Execution cluster C fails to preempt any tasks, and the system puts it into a sleep state for 5 seconds. After 5 seconds, execution cluster C initiates a preemption request again. At this time, the system has added new tasks, and execution cluster C successfully preempts and processes the tasks.
[0254] For example, such as Figure 12As shown, a task scheduling processing system applying the task scheduling processing method provided by the embodiments of the present application is specifically composed of steps S11 to S17, which can be used for reference to understand the task scheduling processing method provided by the present application. S11: Start with loading task data to be processed from reliable storage, and first determine the amount of loaded data: if the data is enough for one batch, go to S12 to determine whether the maximum continuous loading is reached: if reached, execute S14: short-time sleep and reset the maximum continuous loading, and then return to the loading step; if not reached, continue to load in a loop. If the loaded data is not enough for one batch, go to S13 to determine whether the maximum continuous short-time sleep is reached: if reached, execute S15: long-time sleep and reset the maximum short-time sleep number; if not reached, execute S16: short-time sleep. After the two kinds of sleep, return to the initial loading task data step to process in a loop. If empty, go directly to S17: long-time sleep.
[0255] As shown in Figure 13 In some embodiments, the execution body cluster includes a plurality of execution body pools;
[0256] After obtaining the non-delay-sensitive tasks that successfully pre-empt to the execution body cluster task queue of the execution body cluster by the execution body cluster, the task scheduling processing method further includes the following steps:
[0257] S137a: Obtain delay-sensitive tasks from the fast channel queue and non-delay-sensitive tasks from the execution body cluster task queue, wherein the ratio of the number of obtained delay-sensitive tasks to the number of obtained non-delay-sensitive tasks is a predetermined ratio, and the predetermined ratio is greater than 1;
[0258] S137b: Generate a set of tasks to be allocated, wherein the tasks to be allocated in the set of tasks to be allocated include delay-sensitive tasks and non-delay-sensitive tasks;
[0259] S137c: Distribute the set of tasks to be allocated to a plurality of execution body pools.
[0260] In the above embodiments, the execution body pool is composed of a plurality of execution bodies, which are responsible for processing the allocated tasks.
[0261] The predetermined ratio is the ratio of the number of delay-sensitive tasks obtained from the fast channel queue to the number of non-delay-sensitive tasks obtained from the execution body cluster task queue, and the ratio is greater than 1, such as 3:1.
[0262] The set of tasks to be allocated is composed of the set of obtained delay-sensitive tasks and non-delay-sensitive tasks, and is used for distribution to each execution body pool.
[0263] In the above embodiments, the ratio of latency-sensitive tasks obtained from the fast channel queue to non-latency-sensitive tasks obtained from the execution cluster task queue is preset to be greater than 1. This ensures that latency-sensitive tasks can still be processed with priority within the execution cluster, preventing them from being squeezed out by non-latency-sensitive tasks. A set of tasks to be assigned is generated and distributed to multiple execution pools. The format of the set of tasks to be assigned facilitates subsequent allocation to each execution pool according to rules, improving the orderliness and efficiency of task processing within the execution cluster.
[0264] For example, execution cluster D contains 3 execution pools, with a preset ratio of 2:1 for latency-sensitive tasks to non-latency-sensitive tasks. Execution cluster D obtains 6 latency-sensitive tasks from the fast channel queue and 3 non-latency-sensitive tasks from its own task queue, for a total of 9 tasks, forming a task set to be assigned. This task set is then assigned to the 3 execution pools to ensure that each execution pool can prioritize the processing of latency-sensitive tasks.
[0265] like Figure 14 As shown, in some embodiments, optionally, the set of tasks to be assigned is distributed to multiple execution pools, specifically including the following steps:
[0266] S138a: Group the tasks to be assigned according to task type and task source identifier to obtain task groups to be assigned;
[0267] S138b: For each group of tasks to be assigned, assign the tasks in the group to multiple execution pools.
[0268] In the above embodiments, the set of tasks to be assigned is grouped according to task type (i.e., latency-sensitive or non-latency-sensitive) and task source identifier to form task groups. For each task group, the tasks to be assigned in the task group are distributed to multiple execution pools. By grouping tasks by task type and task source identifier, it is ensured that tasks of the same type and from the same source can be centrally or orderly distributed to execution pools, which facilitates management and processing.
[0269] like Figure 15 As shown, in some embodiments, optionally, the multiple execution pools include multiple execution pools with multiple priority levels;
[0270] For each group of tasks to be assigned, the tasks in the group are distributed to multiple execution pools, specifically including the following steps:
[0271] S139a: Obtain the free capacity of each of the execution pools with multiple priority levels;
[0272] S139b: For each group of tasks to be assigned, the tasks to be assigned in the group are traversed in the execution pool in descending order of priority. The free capacity of the execution pool is matched with the tasks to be assigned in turn until multiple target execution pools are selected from multiple execution pools.
[0273] S139c: Assign tasks to be assigned to multiple target execution pools to generate execution pool task queues in the target execution pools.
[0274] In the above embodiments, the priority level execution pool is a task processing unit that is classified according to the priority of the tasks processed by the execution pool. The execution pool with higher priority is assigned tasks first and is usually equipped with better resource configuration.
[0275] Free capacity is the remaining capacity of the execution pool that can currently accept new tasks, which is the difference between the total capacity of the execution pool and the number of tasks already allocated.
[0276] The target execution pool is an execution pool selected from multiple priority pools that has sufficient free capacity to handle assigned tasks.
[0277] The task queue in the execution pool is a queue that stores tasks to be assigned to the target execution pool, allowing the execution bodies in the pool to retrieve and execute them in sequence.
[0278] In the above embodiments, based on the task allocation rules of the execution pool priority level and idle capacity, the priority level sorting ensures that high-priority execution pools process tasks first, thereby improving the response speed of critical tasks; and the idle capacity matching of tasks avoids the execution pool from experiencing a decrease in processing efficiency due to task overload or waste due to resource idleness, thereby achieving efficient utilization of execution pool resources.
[0279] like Figure 16 As shown, in some embodiments, optionally, after allocating the tasks to be assigned to multiple target execution pools to generate execution pool task queues in the target execution pools, the task scheduling processing method further includes the following steps:
[0280] S139d: Poll the task queue of the execution pool using the idle executions in the target execution pool;
[0281] S139e: If no task is found to be assigned in the task queue of the execution pool, the third count value is incremented by 1, and the task queue of the execution pool is polled again after the first time interval. The initial value of the third count value is 0.
[0282] In the above embodiments, an idle executor is an executor in the executor pool that is currently not processing any tasks and is in a standby state.
[0283] Polling is an operation that idle executors check whether there are tasks to be processed in the task queue of the executor pool at a fixed frequency or in a sequence.
[0284] The third count value is a record of the number of times that idle executors do not find tasks in polling, and the initial value is 0.
[0285] The first time interval is the time interval at which idle executors initiate polling again after not finding tasks in polling.
[0286] In the above embodiment, the idle executors in the target executor pool check the task queue of the executor pool through polling, and a retry mechanism of setting count rules and fixed time intervals is provided, so as to ensure that the executors find and process new tasks in time, reduce the waiting time of tasks, avoid resource consumption caused by frequent polling of the executors, balance between the timeliness of task response and resource utilization, and improve the running stability of the executor pool.
[0287] For example, the idle executors of the target executor pool start polling the task queue, do not find tasks to be processed, the third count value is incremented by 1, the third count value becomes 1, and polling is initiated again after the first time interval, for example, 2 seconds. Still no tasks are found, the third count value is incremented by 1, the third count value becomes 2, and polling is continued at an interval of 2 seconds. During this period, the system adds a task to the queue, the executors find this task in the third polling, immediately call the execution, and terminate the count.
[0288] For example, as shown in Figure 17 This is a task scheduling processing system applying the task scheduling processing method provided by the embodiment of the present application, which includes steps S21 to S25, and can be used for reference to understand the task scheduling processing method proposed by the present application.
[0289] Firstly, S21: the current residual processing capacity of a plurality of thread pools is obtained, then S22: tasks to be processed are obtained from the corresponding queue according to the capacity, then S23: the set of tasks to be processed is grouped according to the task type and tenant id, S24: the delay-sensitive task batch size in the group is grouped, and finally S25: the batch task is distributed to the corresponding thread pool and submitted.
[0290] For example, as shown in Figure 18 This is a task scheduling processing system applying the task scheduling processing method provided by the embodiment of the present application, which includes steps S31 to S34, and can be used for reference to understand the task scheduling processing method proposed by the present application.
[0291] Firstly, S31: find the corresponding thread pool serial number according to the task type and the strategy, then S32: judge whether the current thread pool has idle processing capacity and whether it has idle occupancy quota. If both conditions are met, S34: submit the task to the thread pool, and the flow is completed; if not, S33: get the next level thread pool serial number, and judge this next level thread pool with the same conditions, loop this "judgment-finding next level" step, until the task is successfully submitted to the thread pool that meets the conditions, or the flow eventually fails.
[0292] As shown in Figure 19 In some embodiments, if no task to be allocated is polled in the executor pool task queue, the third count value is incremented by 1, and after the first time interval, the task scheduling processing method further comprises the following steps:
[0293] S139f: if the third count value reaches the third count threshold, the fourth count value is incremented by 1, and the executor pool task queue is polled again after the second time interval, wherein the second time interval is greater than the first time interval, and the initial value of the fourth count value is 0;
[0294] S139g: if the fourth count value reaches the fourth count threshold, the executor pool task queue is polled again after the third time interval, and the third time interval is greater than the second time interval.
[0295] In the above embodiment, the fourth count value records the number of times the third count value reaches the third count threshold, and the initial value is 0.
[0296] The second time interval is the time interval at which the executor polls again after the third count value reaches the threshold, and the second time interval is greater than the first time interval.
[0297] The fourth count threshold is the upper limit of the fourth count value.
[0298] The third time interval is the time interval at which the executor polls again after the fourth count value reaches the threshold, and the third time interval is greater than the second time interval.
[0299] In the above embodiment, the polling interval is extended in steps, and the polling frequency is gradually reduced as the number of invalid polls increases, greatly reducing resource waste in the case of no task for a long time; the hierarchical counting rule makes the polling strategy more suitable for actual task load, taking into account task response demand and system resource saving, and improving the energy efficiency of the overall scheduling system.
[0300] Exemplarily, the preset third counting threshold is 3, the first time interval is 2 seconds, the second time interval is 5 seconds, the fourth counting threshold is 3, and the third time interval is 10 seconds. The idle executor polls and finds no task, the third counting value accumulates to 3, reaches the threshold, the fourth counting value is incremented by 1, the fourth counting value becomes 1, and the second time interval of 5 seconds is executed again after polling; still no task is found, the third counting value is reset and accumulates to 3 again, the fourth counting value is incremented by 1 again, and the fourth counting value becomes 2; the process is repeated until the fourth counting value reaches the fourth counting threshold of 3, and the subsequent polling is executed in the third time interval, the interval is extended to 10 seconds, and the task queue is waited until a new task appears.
[0301] Exemplarily, as shown in the figure, Figure 20 a task scheduling processing system applying the task scheduling processing method provided in the embodiments of the present application, comprising steps S41 to S50, can be used for reference to understand the task scheduling processing method provided in the present application.
[0302] Firstly, it is judged S41 whether a task is processed. If the task needs to be processed, the state is reset S42 to non-idle, the spin count is 0, and the yield count is 0. If the task does not need to be processed, it is firstly judged S43 whether the current state is in the spin state. If so, it is checked S44 whether the spin count reaches the maximum value. If not, the spin count is incremented S45 by 1. If so, the state is set S46 to yield. If the current state is in the yield state, it is checked S47 whether the yield count reaches the maximum value. If not, the yield count is incremented S48 by 1. If so, the state is set S49 to sleep and the thread is put to sleep S50 for a specified ms. After the steps are completed, the process returns to the start of the flow and is executed in a loop.
[0303] Here, sleep generally refers to thread sleep. Yield refers to thread yielding, which means that the current thread voluntarily gives up the execution right and allows other threads of the same priority to have the opportunity to run first, but the thread itself will continue to participate in the scheduling competition afterwards. Ms is the English abbreviation of millisecond, which is used to represent a very short waiting time.
[0304] Exemplarily, as shown in the figure, Figure 21 the system architecture diagram of the task scheduling system provided in the embodiments of the present application; after the client on the business service side initiates a task through the “task saving, retrying, and pushing” interface, the task is transmitted in real time through the “direct pushing service” in the RPC mode through the public network, or the task is persisted to the database through the “reliable storage service”; the former enters the “high-speed channel module” of the distributed scheduling execution service, and the latter enters the “task loading channel” after being loaded from the database; the tasks in the two types of channels are finally transmitted to the “scheduler” of the scheduling execution engine, and then the tasks are executed by the “executor” in the strategies such as “hierarchical, grouping, and batch”.
[0305] AsFigure 22 As shown, the second aspect of the present application proposes a task scheduling processing device 300 for implementing the steps of the task scheduling processing method according to the first aspect of the present application, comprising:
[0306] The extraction module 301 is configured to extract the target service from the service execution request in response to the service execution request.
[0307] The submission module 302 is configured to start the target transaction, decompose the target service into a plurality of tasks, and submit the delay-sensitive tasks in the plurality of tasks to the target transaction, wherein the task state of the delay-sensitive tasks submitted to the target transaction is the first state.
[0308] The delivery module 303 is configured to deliver the delay-sensitive tasks in the target transaction to the fast channel queue for execution by the execution body in priority, and modify the first state to the second state after successful execution.
[0309] The processing module 304 is configured to release the target transaction when the task state of the delay-sensitive tasks in the target transaction is all modified to the second state.
[0310] In the above embodiment, the service execution request is initiated by a user, an internal module of the system or an external system, and is a request for triggering the task scheduling processing.
[0311] The target service is a specific service matter to be processed extracted from the service execution request.
[0312] The target transaction is a transaction unit started to ensure the consistency and integrity of the execution of the delay-sensitive tasks, and is used for unified management of the delay-sensitive tasks.
[0313] The delay-sensitive task is a task that requires extremely high execution response time and needs to be processed in priority.
[0314] The non-delay-sensitive task is a task that requires low execution response time and delay execution will not have a significant impact on the service.
[0315] The first state is the initial state of the delay-sensitive task after being submitted to the target transaction, indicating that the task enters transaction management but has not been executed or is waiting to be executed.
[0316] The fast channel queue is a queue specially storing and scheduling delay-sensitive tasks, and has a higher priority than ordinary queues, and is used to ensure that the tasks are called in priority.
[0317] The execution body is a specific undertaker of task execution.
[0318] The second state is the state changed by the delay-sensitive task after being successfully executed by the execution body, and is used to indicate that the task is successfully executed.
[0319] In the above embodiment, after the service execution request is issued, the target service is screened and extracted in the service execution request in response to the service execution request. Then the target transaction is started, the extracted target service is divided into a plurality of tasks, the delay-sensitive task is screened from the plurality of tasks, the delay-sensitive task is submitted to the target transaction, and thus the separation of the delay-sensitive task can be realized. The task state of the delay-sensitive task submitted to the target transaction is identified as a first state; and the delay-sensitive task in the target transaction is delivered to a fast priority channel queue, which is preferentially pushed to the execution body through the priority channel queue, so that the execution body can preferentially call and process without waiting for the non-delay-sensitive task, which is beneficial to shorten the response time of the delay-sensitive task and improve the timeliness of the delay-sensitive task. For the delay-sensitive task that has been successfully executed, the task state identifier is modified to a second state; through the task identifier, the completed delay-sensitive task and the uncompleted delay-sensitive task can be quickly identified, which can avoid omission of the delay-sensitive task on one hand and avoid repeated execution of the delay-sensitive task on the other hand. With the gradual completion of the delay-sensitive task in the target transaction, when all the delay-sensitive tasks in the target transaction are completed, that is, all the delay-sensitive task identifiers in the target transaction are modified to the second state, the target transaction is released; in this way, on one hand, the completion progress of the delay-sensitive task in the target transaction can be supervised in real time through the target transaction to avoid omission caused by scattered processing, and to ensure that the key task is covered without dead angle; on the other hand, only when all the delay-sensitive tasks are completed, the subsequent transaction release link is entered, which can guarantee the consistency of the completion of the delay-sensitive task in the target transaction from the process, and thus the risk of data deviation caused by different execution progress of the task can be avoided, which is beneficial to improve the integrity and accuracy of the business data.
[0320] As shown in Figure 23 The third aspect of the present application provides a task controller 400, which comprises a processor 402 and a memory 404, the memory 404 stores programs or instructions, and the processor 402 implements the steps of the task scheduling processing method of any one of the above embodiments when executing the programs or instructions in the memory. Therefore, the application construction device has all the beneficial effects of the task scheduling processing method of any one of the above embodiments.
[0321] The fourth aspect of the present application provides a readable storage medium, which stores programs or instructions, and the programs or instructions are executed by the processor to realize the steps of the task scheduling processing method of any one of the above embodiments. Therefore, the readable storage medium has all the beneficial effects of the task scheduling processing method of any one of the above embodiments.
[0322] The methods can be implemented in various ways, and the application(s) can be implemented by various means, including hardware, firmware, and / or software. For example, in a hardware implementation, the processors can be implemented within one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, micro-controllers, microprocessors, other electronic units designed to perform the functions described above, and / or a combination thereof.
[0323] A computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium can be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital video disc (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media, or electrical signals through a wire, digital or analog communication links, wireless communications links, and / or like.
[0324] In the claims, the specification, and the drawings of the application, terms such as "multiple", "two or more", "plurality", etc. mean two or more unless expressly specified otherwise by the context. The terms "above", "under", and the like, when used in this application, refer to an orientation or position as shown in the drawings, and are used for convenience to describe the present application and to more particularly explain certain processes, and are not to be construed as indicating or implying necessary or essential positions, orientations, or configurations, unless expressly so defined in the claims. The terms "connect", "mount", "attach", and the like, unless otherwise specified, mean an indirect or direct connection or attachment. This can include mechanical connection or attachment by way of an intermediate medium, which can be either fixed or moveable. The terms "connect" and "attach" are to be interpreted broadly to include a fixed connection, a detachable connection, or an integral connection, as well as a direct connection or an indirect connection by way of an intermediate medium. The specific meaning of the above terms in the present application can be understood by those skilled in the art according to the specific circumstances of the data.
[0325] In the claims, the specification, and the drawings of the application, the terms "one embodiment", "some embodiments", "certain embodiments", and the like, are not necessarily all referring to the same embodiments, although they can. The terms "one embodiment", "some embodiments", "certain embodiments", and the like, are intended to mean one or more embodiments, or one or more instances of an embodiment. In the claims, the specification, and the drawings of the application, the word "comprising" and variations such as "comprise" and "comprises" are not necessarily intended to exclude the presence of other elements or additional steps. The words "an" and "a" are not necessarily intended to exclude the presence of one or more other such elements or additional steps. The use of the term "or" in the claims is used to mean "and / or" unless explicitly indicated to the contrary by the context.
[0326] The above description is merely the preferred embodiment of this application, and is not intended to limit the application. Those skilled in the art can make various modifications and changes to the application without departing from the spirit and principles of the application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the application shall be included in the scope of protection of the application.
Claims
1. A task scheduling and processing method, characterized in that, include: In response to a business execution request, extract the target business from the business execution request; Start a target transaction, decompose the target business into multiple tasks, and submit the latency-sensitive tasks among the multiple tasks to the target transaction, wherein the task status of the latency-sensitive tasks submitted to the target transaction is the first state; The latency-sensitive task in the target transaction is passed to the fast channel queue for priority retrieval and execution by the executor, and the first state is changed to the second state after successful execution; If the task status of all delay-sensitive tasks in the target transaction is modified to the second state, the target transaction is terminated.
2. The task scheduling and processing method according to claim 1, characterized in that, Submitting the latency-sensitive tasks among the plurality of tasks to the target transaction includes: From the business information of the target business, determine the task type of each task, wherein the task type includes the latency-sensitive task; The latency-sensitive task is submitted to the target transaction, and the task status of the latency-sensitive task is set to the first state.
3. The task scheduling and processing method according to claim 1, characterized in that, The step of transferring the latency-sensitive task in the target transaction to the fast-channel queue for priority retrieval and execution by the executor, and modifying the first state to the second state after successful execution, includes: The delay-sensitive task in the target transaction is passed to the scheduler. The delay-sensitive task includes a task sequence number and a task version number. The scheduler performs version verification based on the task version number, and if the version verification passes, it sequentially changes the first state of the delay-sensitive task to the third state according to the task sequence number. The latency-sensitive task is passed to the fast-track queue and preferentially retrieved and executed by the executor. After successful execution, the third state is changed to the second state.
4. The task scheduling and processing method according to claim 1, characterized in that, The plurality of tasks includes the latency-sensitive tasks and the non-latency-sensitive tasks; After initiating the target transaction, decomposing the target business into multiple tasks, and submitting the latency-sensitive tasks among the multiple tasks to the target transaction, the task scheduling method further includes: The non-latency-sensitive tasks are assigned to the ordinary channel queue, and are preempted by multiple execution clusters.
5. The task scheduling and processing method according to claim 4, characterized in that, The step of allocating the non-latency-sensitive tasks to a regular channel queue, where multiple execution clusters preemptively handle the task, includes: The non-delay-sensitive tasks are assigned to the normal channel queue; In response to receiving a preemption request from the execution cluster, the order of the non-delay-sensitive tasks in the normal channel queue is randomly rearranged to obtain a rearranged queue; For the non-delay-sensitive tasks in the rearranged queue, preemption is performed according to the rearranged order. For non-delay-sensitive tasks that fail to be preempted, the next non-delay-sensitive task following the first one is preempted. For non-delay-sensitive tasks that are successfully preempted, a distributed lock is added to the non-delay-sensitive task, and the distributed lock prevents other execution clusters from preempting it. The non-delay-sensitive tasks that have been successfully preempted are retrieved into the execution cluster task queue of the execution cluster through the execution cluster.
6. The task scheduling and processing method according to claim 5, characterized in that, The non-delay-sensitive task has a task source identifier and an in-source task identifier; The step of randomly rearranging the order of the non-delay-sensitive tasks in the normal channel queue in response to receiving a preemption request from the execution cluster includes: In response to receiving the preemption request from the execution cluster, the non-delay-sensitive tasks in the normal channel queue are grouped according to the task source identifier; For each group, random rearrangement of groups is performed according to the task source identifier, and within each group, random rearrangement of non-delay-sensitive tasks is performed according to the task identifier within the source.
7. The task scheduling and processing method according to claim 5, characterized in that, After obtaining the successfully preempted non-delay-sensitive tasks into the execution cluster task queue through the execution cluster, the task scheduling method further includes: Count the number of consecutively preempted non-latency-sensitive tasks; If the number of consecutively successfully preempted non-delay-sensitive tasks reaches a first number, then the first count value is incremented by 1, the number of consecutively successfully preempted non-delay-sensitive tasks is cleared to zero, and the process returns to the step of counting the number of consecutively successfully preempted non-delay-sensitive tasks, wherein the initial value of the first count value is 0. If the first count value reaches the first count threshold, the execution cluster will be put into a dormant state for a first duration before continuing to preempt the non-latency-sensitive task.
8. The task scheduling and processing method according to claim 5, characterized in that, After obtaining the successfully preempted non-delay-sensitive tasks into the execution cluster task queue through the execution cluster, the task scheduling method further includes: Count the number of consecutively preempted non-latency-sensitive tasks; If the number of consecutively successfully preempted non-delay-sensitive tasks does not reach the first number, then the second count value is incremented by 1, the execution cluster is put into a sleep state for a second duration, and then the preemption of non-delay-sensitive tasks continues, and the process returns to the step of counting the number of consecutively successfully preempted non-delay-sensitive tasks, wherein the initial value of the second count value is 0. If the second count value reaches the second count threshold, the execution cluster will be put into a sleep state for a third duration before continuing to preempt the non-delay-sensitive task, wherein the third duration is longer than the second duration.
9. The task scheduling and processing method according to claim 5, characterized in that, The preemption of non-delay-sensitive tasks in the rearranged queue according to the rearranged order includes: If no non-delay-sensitive task is preempted in the rearranged queue, the execution cluster will be put into a sleep state for a fourth duration before continuing to preempt the non-delay-sensitive task.
10. The task scheduling and processing method according to claim 5, characterized in that, The execution entity cluster contains multiple execution entity pools; After obtaining the successfully preempted non-delay-sensitive tasks into the execution cluster task queue through the execution cluster, the task scheduling method further includes: The latency-sensitive task is obtained from the fast channel queue, and the non-latency-sensitive task is obtained from the execution cluster task queue, wherein the ratio of the number of latency-sensitive tasks obtained to the number of non-latency-sensitive tasks obtained is a predetermined ratio, and the predetermined ratio is greater than 1. Generate a set of tasks to be assigned, wherein the tasks to be assigned in the set include the latency-sensitive tasks and the non-latency-sensitive tasks; The set of tasks to be assigned is distributed to the multiple execution pools.
11. The task scheduling and processing method according to claim 10, characterized in that, The step of allocating the set of tasks to be assigned to the plurality of execution pools includes: The tasks to be assigned are grouped according to task type and task source identifier to obtain task groups to be assigned; For each group of tasks to be assigned, the tasks in the group are assigned to the plurality of execution pools.
12. The task scheduling and processing method according to claim 11, characterized in that, The multiple execution pools contain multiple execution pools with different priority levels; For each group of tasks to be assigned, the step of assigning the tasks in the group to the plurality of execution pools includes: Obtain the free capacity of each of the multiple priority level execution pools; For each group of tasks to be assigned, the tasks to be assigned in the group are traversed in the execution pool in descending order of priority, and the free capacity of the execution pool is matched with the tasks to be assigned in turn, until multiple target execution pools are selected from multiple execution pools. The tasks to be assigned are distributed to the multiple target execution pools to generate an execution pool task queue in the target execution pools.
13. The task scheduling and processing method according to claim 12, characterized in that, After assigning the tasks to be allocated to the plurality of target execution pools to generate execution pool task queues in the target execution pools, the task scheduling processing method further includes: The task queue of the execution pool is polled using the idle execution units in the target execution pool; If no task to be assigned is found in the task queue of the execution pool, the third count value is incremented by 1, and the task queue of the execution pool is polled again after the first time interval, wherein the initial value of the third count value is 0.
14. The task scheduling and processing method according to claim 13, characterized in that, After incrementing the third count value by 1 if no task to be assigned is found in the task queue of the execution pool, and polling the task queue of the execution pool again after the first time interval, the task scheduling processing method further includes: If the third count value reaches the third count threshold, the fourth count value is incremented by 1, and the task queue of the execution pool is polled again after the second time interval, wherein the second time interval is greater than the first time interval, and the initial value of the fourth count value is 0. If the fourth count value reaches the fourth count threshold, the task queue of the execution pool is polled again after the third time interval, where the third time interval is greater than the second time interval.
15. A task scheduling and processing device, characterized in that, The task scheduling processing device is used to implement the steps of the task scheduling processing method as described in any one of claims 1 to 14, including: The extraction module is used to extract the target business from the business execution request in response to the business execution request; The submission module is used to start a target transaction, decompose the target business into multiple tasks, and submit the latency-sensitive tasks among the multiple tasks to the target transaction, wherein the task status of the latency-sensitive tasks submitted to the target transaction is a first state. The delivery module is used to deliver the delay-sensitive task in the target transaction to the fast channel queue for priority retrieval and execution by the executor, and modify the first state to the second state after successful execution; The processing module terminates the target transaction when all the task states of the delay-sensitive tasks in the target transaction are modified to the second state.
16. A task controller, characterized in that, include: processor; A memory, wherein the memory stores a program or instructions executable on the processor, wherein the processor, when executing the program or instructions, implements the steps of the task scheduling processing method as described in any one of claims 1 to 14.
17. A readable storage medium having a program or instructions stored thereon, characterized in that, When the program or the instructions are executed by the processor, the steps of the task scheduling processing method as described in any one of claims 1 to 14 are implemented.