Task scheduling method and device, storage medium and computer program product
By dividing tasks into time slices and using business attribute-driven splitting factors, tasks are split into a set of subtasks. These subtasks are then scheduled using static configuration parameters and business timeliness rules. This solves the problem of low task scheduling efficiency in existing technologies and enables efficient and flexible task processing.
Patent Information
- Application Number
- CN202511532699.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-24
- Publication Date
- 2026-01-20
AI Technical Summary
Existing task scheduling schemes lack custom scheduling strategies, making it impossible to dynamically adjust resource allocation based on task priority and business timeliness, which makes it difficult to achieve efficient parallel processing and results in low scheduling efficiency.
The time slice is divided by obtaining the business trigger time. Combining static and dynamic time slice division methods, the task is split by selecting the splitting factor based on business attribute characteristics. The sub-task set is then loaded into the thread pool for scheduling using static configuration parameters and business timeliness rules.
It achieves a balance between timeliness and flexibility in task scheduling, improves resource utilization and concurrent processing capabilities, breaks through the performance bottleneck of a single machine, and ensures the timely execution of high-priority tasks.
Smart Images

Figure CN121364930A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of task scheduling, in particular to a task scheduling method, device, storage medium and computer program product. BACKGROUND
[0002] The mainstream task scheduling scheme mainly realizes task distribution through the cooperation of a task scheduling platform and an executor, or, from the perspective of host power consumption optimization, selects suitable task execution nodes by predicting host power consumption to improve the energy efficiency of single-machine systems for task scheduling. In the cooperation scheme of the task scheduling platform and the executor, the scheduling platform only bears the task forwarding function and lacks self-defined scheduling strategies for different task types, and cannot dynamically adjust resource allocation according to task priority, business timeliness, etc. The scheme of selecting suitable task execution nodes by predicting host power consumption does not consider the space-time resource segmentation needs of tasks, and cannot dynamically allocate system resources to high-priority or high-timeliness tasks; at the same time, in the face of large data volume tasks, it lacks a splitting mechanism based on business attributes, and it is difficult to realize parallel processing of tasks, resulting in low scheduling efficiency.
[0003] Therefore, how to realize efficient and flexible scheduling of complex background tasks has become a technical problem that the present application needs to solve urgently.
[0004] The above content is only used to assist in understanding the technical solutions of the present application and does not represent the acknowledgement of the above content as prior art. SUMMARY
[0005] The main purpose of the present application is to provide a task scheduling method, device, storage medium and computer program product, aiming to solve the technical problem of how to realize efficient and flexible scheduling of complex background tasks.
[0006] To achieve the above purpose, the present application provides a task scheduling method, which comprises: obtaining a business trigger time, performing time slice division based on the business trigger time to obtain an initial task; the time slice division mode includes static time slice division and dynamic time slice division; selecting a splitting factor according to the business attribute characteristics of the initial task, and performing task splitting on the initial task based on the splitting factor to obtain a sub-task set; obtaining static configuration parameters of the sub-task set, and loading the sub-task set to a thread pool for task scheduling according to the static configuration parameters and a preset business timeliness rule.
[0007] In an embodiment, the step of obtaining a business trigger time, performing time slice division based on the business trigger time to obtain an initial task comprises: capture a trigger event generated by a service system, record a service trigger time and a service type of the trigger event; generate a static time slice sequence based on the service type and a preset fixed time slice size; or, retrieve historical execution time consumption data consistent with the service type, calculate a dynamic time slice size based on the historical execution time consumption data, and generate a dynamic time slice sequence; determine a time slice parameter set according to the static time slice sequence or the dynamic time slice sequence; determine a target time slice according to the time slice parameter set and the service trigger time, and create an initial task based on the target time slice.
[0008] In an embodiment, the step of creating an initial task based on the target time slice further comprises: if the time slice parameter set is determined according to the dynamic time slice sequence, record an actual time consumption of the initial task; update the historical execution time consumption data according to the actual time consumption.
[0009] In an embodiment, the step of selecting a split factor according to the service attribute characteristics of the initial task, and performing task splitting on the initial task based on the split factor to obtain a subtask set further comprises: read a preset single task data amount threshold, and compare the single task data amount threshold with a total amount of service data of the initial task; if the total amount of service data is greater than the single task data amount threshold, perform the step of selecting a split factor according to the service attribute characteristics of the initial task, and performing task splitting on the initial task based on the split factor to obtain a subtask set; if the total amount of service data is not greater than the single task data amount threshold, load the initial task to an idle thread pool, and perform task scheduling on the initial task.
[0010] In an embodiment, the step of selecting a split factor according to the service attribute characteristics of the initial task, and performing task splitting on the initial task based on the split factor to obtain a subtask set comprises: analyze the service type of the initial task, extract core attribute characteristics based on the service type to generate a service attribute characteristic list; select a split factor from the service attribute characteristic list according to the service data distribution characteristics of the initial task; calculate a split granularity parameter according to the split factor, and perform task splitting on the initial task according to the split granularity parameter to obtain an initial subtask set; traverse the initial subtask combination, check whether the task data volume of each initial subtask in the initial subtask set meets a preset single task data volume threshold value; If the task data volume of each initial subtask does not meet the preset single task data volume threshold value, increase the split bit number of the split factor to obtain an updated split factor; recompute the split granularity parameter using the updated split factor to perform task splitting on the initial subtasks until the task data volume of each initial subtask in the initial subtask set meets the preset single task data volume threshold value, and obtain a subtask set.
[0011] In an embodiment, the step of obtaining the static configuration parameters of the subtask set and loading the subtask set to a thread pool according to the static configuration parameters and a preset service timeliness rule for task scheduling comprises: loading the subtask set to the thread pool and obtaining the static configuration parameters of the subtask set, the static configuration parameters comprising a task priority and a maximum concurrency number; querying the number of idle threads in the thread pool that are not occupied, and if the number of idle threads is greater than zero, obtaining the task type and the number of tasks of the subtask set; determining a to-be-scheduled subtask set according to the task type, the number of tasks of the subtask set, and a preset service timeliness rule, and performing priority sorting on the to-be-scheduled subtask set according to the task priority; loading the to-be-scheduled subtask set after priority sorting to the idle thread pool in batches according to the maximum concurrency number and the number of idle threads to allocate thread resources, and executing the to-be-scheduled subtask set.
[0012] In an embodiment, the step of loading the to-be-scheduled subtask set after priority sorting to the idle thread pool in batches according to the maximum concurrency number and the number of idle threads to allocate thread resources, and executing the to-be-scheduled subtask set further comprises: querying whether there are idle threads in the thread pool; If there are idle threads in the thread pool, return to the execution step of determining a to-be-scheduled subtask set according to the task type and the number of tasks of the subtask set, and performing priority sorting on the to-be-scheduled subtask set according to the task priority.
[0013] In addition, to achieve the above-mentioned purposes, the present application also provides a task scheduling device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the task scheduling method as described above.
[0014] In addition, to achieve the above-mentioned purpose, the present application also provides a storage medium, which is a computer readable storage medium, and a computer program is stored on the storage medium, and the computer program is executed by a processor to implement the steps of the task scheduling method as described above.
[0015] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the steps of the task scheduling method as described above.
[0016] The one or more technical solutions provided by the present application have at least the following technical effects: The service trigger time is obtained, time slice division is performed based on the service trigger time, and an initial task is obtained; the time slice division mode includes static time slice division and dynamic time slice division; a splitting factor is selected according to a service attribute feature of the initial task, and the initial task is split based on the splitting factor to obtain a sub-task set; static configuration parameters of the sub-task set are obtained, and the sub-task set is loaded to a thread pool for task scheduling according to the static configuration parameters and a preset service timeliness rule. Firstly, the time slice division combines static and dynamic modes, the static time slice ensures stable scheduling of regular tasks, and the dynamic time slice avoids resource waste or scheduling delay, thereby improving resource utilization from the time dimension; further, the splitting factor based on the service attribute drives the large data volume task to be split into parallel sub-tasks, supports multi-host distributed processing, breaks through the single-machine performance bottleneck, and significantly improves the concurrent processing capability; finally, the static configuration parameters and the service timeliness rule are comprehensively used for task scheduling, so as to realize accurate matching of resources and tasks on the basis of maximizing resource utilization and ensuring task execution timeliness, and achieve the balance between timeliness and flexibility of task processing in a complex scenario. BRIEF DESCRIPTION OF DRAWINGS
[0017] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the principles of the application.
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.
[0019] Figure 1 A flowchart is provided for the first embodiment of the task scheduling method of the present application; Figure 2 A flowchart is provided for the second embodiment of the task scheduling method of the present application; Figure 3 A time slice division schematic diagram provided for the present application; Figure 4 A feasible implementation manner schematic diagram provided for the second embodiment of the present application; Figure 5 A flow schematic diagram provided for the third embodiment of the task scheduling method of the present application; Figure 6 A flow schematic diagram provided for the fifth embodiment of the task scheduling method of the present application; Figure 7 A feasible implementation manner schematic diagram provided for the fifth embodiment of the present application; Figure 8 A module structure schematic diagram of the task scheduling device of the embodiment of the present application; Figure 9 A device structure schematic diagram of the hardware running environment involved in the task scheduling method of the embodiment of the present application.
[0020] The object implementation, functional features and advantages of the present application will be further explained with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0021] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application, and are not used to limit the present application.
[0022] In order to better understand the technical solutions of the present application, the following will be described in detail in combination with the drawings of the specification and specific embodiments.
[0023] The main solution of the embodiment of the present application is: obtaining a service trigger time, performing time slice division based on the service trigger time to obtain an initial task; the time slice division manner includes static time slice division and dynamic time slice division; selecting a splitting factor according to the service attribute characteristics of the initial task, and performing task splitting on the initial task based on the splitting factor to obtain a sub-task set; obtaining the static configuration parameters of the sub-task set, and loading the sub-task set to a thread pool according to the static configuration parameters and a preset service timeliness rule to perform task scheduling.
[0024] The embodiment of the application considers that: since the mainstream task scheduling scheme mainly realizes task distribution through the cooperation of the task scheduling platform and the executor, or, from the perspective of host power consumption optimization, the appropriate task execution node is selected by predicting the host power consumption to improve the energy efficiency of the single machine system for task scheduling. In the cooperation scheme of the task scheduling platform and the executor, the scheduling platform only undertakes the task forwarding function, lacks the self-defined scheduling strategy for different task types, and cannot dynamically adjust the resource allocation according to the task priority, business timeliness and the like. The scheme of selecting the appropriate task execution node by predicting the host power consumption does not consider the space-time resource segmentation demand of the task, and cannot dynamically allocate the system resources to the high-priority or high-timeliness task; at the same time, in the face of large data volume tasks, the scheme lacks a splitting mechanism based on the business attribute, and it is difficult to realize the parallel processing of the tasks, resulting in low scheduling efficiency.
[0025] Therefore, the application provides a solution, acquires a business trigger time, performs time slice division based on the business trigger time to obtain an initial task; the time slice division mode includes static time slice division and dynamic time slice division; a splitting factor is selected according to the business attribute characteristics of the initial task, and the initial task is split based on the splitting factor to obtain a subtask set; static configuration parameters of the subtask set are acquired, and the subtask set is loaded to a thread pool to perform task scheduling according to the static configuration parameters and a preset business timeliness rule. First, the time slice division combines static and dynamic modes, the static time slice ensures the stable scheduling of the regular task, and the dynamic time slice avoids resource waste or scheduling delay, thereby improving the resource utilization from the time dimension; further, the splitting factor based on the business attribute drives the large data volume task to be split into parallel subtasks, supports multi-host distributed processing, breaks through the single machine performance bottleneck, and significantly improves the concurrent processing capability; finally, the static configuration parameters and the business timeliness rule are comprehensively used for task scheduling, the resource utilization is maximized and the task execution timeliness is guaranteed on the basis of maximizing the resource utilization, and the accurate matching of the resource and the task is realized, so that the timeliness and flexibility balance of the task processing in the complex scene is achieved.
[0026] It should be noted that the execution subject of the embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone and the like, or an electronic device, a task scheduling system and the like capable of realizing the above functions. The embodiment and the following embodiments are described below taking the task scheduling system as an example.
[0027] Based on this, the embodiment of the application provides a task scheduling method, referring to Figure 1 , Figure 1 The flowchart of the first embodiment of the task scheduling method of the application is shown in FIG. 1.
[0028] In this embodiment, the task scheduling method includes steps S10-S30. Step S10, obtaining a service trigger time, performing time slice division based on the service trigger time to obtain an initial task; the time slice division includes static time slice division and dynamic time slice division. It should be noted that, in the embodiments of the present application, the service trigger time refers to a specific time point for triggering task execution in a service process, for example, the time when a user submits an order, the time when a system starts a batch task at a fixed time, etc.
[0029] Time slice division refers to dividing a continuous time interval into multiple discrete time units, each time unit being referred to as a time slice, which is used to assign different tasks to control the timing and duration of task execution; static time slice division refers to a way of dividing time slices according to a fixed time length (such as 10 minutes, 1 hour), and the size of the divided time slices does not change during task execution; dynamic time slice division refers to a way of adaptively adjusting the size of the time slices according to the historical execution time consumption, business complexity and other factors of the task, and the size of the divided time slices can be dynamically adapted according to the changes in task attributes.
[0030] The initial task refers to the original task instance generated based on the time slice division result and has not been subjected to splitting processing.
[0031] It should be noted that the overall purpose of this step is to bind the service trigger time and the task execution resource through fine-grained time slice management, to ensure that the task can be scheduled and executed within a suitable time window, thereby improving the timeliness of task processing and resource utilization efficiency. The system first captures the service trigger time, and then encapsulates the corresponding business data as an initial task according to the time slice range to which the time point belongs, wherein the static time slice division is suitable for tasks with stable business rules and small time consumption fluctuations (such as reconciliation tasks at a fixed time period every day), and the dynamic time slice division is suitable for tasks with uncertain time consumption (such as transaction processing tasks in peak periods), and through the combination of the two ways, differentiated scheduling support for different types of tasks can be achieved.
[0032] In one possible implementation, the specific implementation of static time slice division is that the system presets a fixed time slice length (such as 5 minutes), divides one day into 288 time slices (24 hours x 60 minutes / 5 minutes), and when the service trigger time falls within a certain time slice interval (such as 09:00-09:05), the business data corresponding to the time slice is integrated into an initial task.
[0033] In a possible implementation, the specific implementation of dynamic time slicing is as follows: the system automatically adjusts the time slice size to 15 minutes (20% buffer time is reserved) according to the historical execution data of the same type of task (for example, the average time consumption of the type of task in the past 7 days is 12 minutes), if the time consumption of a task execution exceeds 15 minutes, the time slice size is updated to 20 minutes in the next scheduling, to adapt to the actual time consumption of the task.
[0034] In step S20, a splitting factor is selected according to the service attribute feature of the initial task, and the initial task is split into a task set based on the splitting factor. It should be noted that, in the embodiments of the present application, the service attribute feature refers to the service dimension information associated with the initial task, for example, the service type (such as payment, reconciliation, report generation) to which the task belongs, the user attribute (such as customer number, region) involved, and the data feature (such as transaction amount range, data format).
[0035] The splitting factor refers to a key dimension or rule for splitting the initial task into subtasks, for example, the last two digits of the customer number, the transaction region code, and the data batch number.
[0036] The task set refers to a set of multiple small-granularity tasks formed after the initial task is split, each subtask containing part of the data and execution logic of the original task.
[0037] It should be noted that the overall purpose of this step is to split the initial task by business attribute feature, to decompose the initial task with large data volume and high complexity into multiple small-granularity subtasks, to realize parallel processing and balanced allocation of resources, and to improve the processing capacity of the system for high-concurrency tasks. The system first analyzes the business attribute feature (such as data volume, business association) of the initial task, selects a suitable splitting factor (such as customer number, region), and then splits the initial task into multiple subtasks according to the rules of the splitting factor, each subtask can be independently allocated to different execution nodes or threads.
[0038] In a possible implementation, the selection of the splitting factor is based on the following factors: (1) data uniformity: the data volume difference of each subtask after splitting does not exceed a preset threshold; (2) business association: subtasks under the same splitting factor should have similar business logic; (3) execution efficiency: the average processing time consumption of the subtasks after splitting should be less than the maximum load capacity of a single thread of the system.
[0039] In a possible implementation, the specific rule of task splitting is that if the data volume of the initial task exceeds a preset threshold (such as 1 million records), the splitting process is triggered; the splitting factor is preferentially selected from unique identification attributes such as customer number and account ID, and if such attributes do not exist, the splitting factor is selected from classification attributes such as region code and transaction type; and the upper limit of the number of split subtasks is the maximum concurrency supported by the system (such as 100).
[0040] In step S30, the static configuration parameters of the subtask set are acquired, and the subtask set is loaded to the thread pool according to the static configuration parameters and a preset business timeliness rule for task scheduling.
[0041] It should be noted that in the embodiments of the present application, the static configuration parameters refer to parameters that are preset and do not change dynamically with business scenarios in the task scheduling process, including but not limited to task priority, maximum concurrency, execution timeout (the longest execution time allowed for a task), resource allocation ratio (such as allocation weight of CPU and memory), and the like. Among them, the task priority is determined according to the business triggering time, and the task with an earlier time slice will be executed preferentially.
[0042] The business timeliness rule refers to the task execution time constraint. At the current time 9:00, the task with an execution time of 9:00 needs to be processed.
[0043] The thread pool refers to a container for managing and reusing thread resources in the system. By pre-creating a certain number of threads, the performance overhead caused by frequent creation and destruction of threads is avoided, and efficient scheduling of tasks is achieved.
[0044] It should be noted that the overall purpose of this step is to comprehensively consider static configuration and dynamic rules, to reasonably distribute the subtask set to the thread pool for execution, so as to realize optimized utilization of resources and orderly scheduling of tasks. The system first acquires the static configuration parameters (such as priority and maximum concurrency) of the subtasks from the configuration center, and then combines the preset business timeliness rule to load the subtasks that have reached the execution time to the thread pool after sorting according to the priority. The thread pool dynamically allocates execution resources according to the current number of idle threads and the task priority, to ensure that tasks with high priority and high timeliness requirements are processed preferentially.
[0045] The embodiment provides a task scheduling method, time slice division combines static and dynamic modes, static time slices ensure stable scheduling of regular tasks, dynamic time slices avoid resource waste or scheduling delay, and resource utilization is improved from the time dimension; further, a splitting factor based on business attribute driving splits a large data volume task into parallel subtasks, supports multi-host distributed processing, breaks through the single machine performance bottleneck, and significantly improves the concurrent processing capability; finally, the task scheduling is performed by comprehensively considering the static configuration parameters and the business timeliness rules, the resource utilization is maximized and the task execution timeliness is guaranteed on the basis of realizing the accurate matching of resources and tasks, and the timeliness and flexibility balance of task processing in a complex scene is achieved.
[0046] Based on the first embodiment of the application, the second embodiment of the application is proposed. In the second embodiment of the application, the same or similar contents as the above-mentioned first embodiment can be referred to the above introduction, and will not be described in detail hereinafter.
[0047] On this basis, please refer to Figure 2 , Figure 2 for the process schematic diagram of the second embodiment of the application. As shown in Figure 2 , the step S10 of obtaining the business trigger time and performing time slice division based on the business trigger time to obtain the initial task can include steps S11-S15: Step S11, capturing the trigger event generated by the business system, recording the business trigger time and the business type of the trigger event; It should be noted that in the embodiments of the application, the business system refers to a computer system carrying specific business logic, such as an e-commerce transaction system, a bank core account system, etc.
[0048] The trigger event refers to a specific operation or state change in the business system that triggers the task scheduling demand, such as user order submission, timing batch running time arrival, data file uploading completion, etc.
[0049] The business type refers to the classification of the business category to which the trigger event belongs, such as "payment settlement", "log backup", "report generation", etc., different business types correspond to different processing logic and resource requirements.
[0050] It should be noted that the overall purpose of this step is to capture the trigger event and record the key information to provide basic data for subsequent time slice division and task creation, and to ensure the accurate association of task scheduling and business scenarios. The system captures the trigger event generated by the business system in real time through the event listening mechanism, then extracts the business trigger time and the business type from the event metadata, and stores these information in the to-be-processed event table of the task scheduling database, so as to be called by the subsequent process.
[0051] In a possible implementation, the capturing manner of the trigger event includes: (1) real-time listening: subscribing to the event stream of the business system through a message queue (such as Kafka), and immediately consuming and analyzing when the event is generated; (2) timing scanning: for the business system without a real-time notification mechanism, the trigger event is captured by querying the database change record (such as the newly added order table record) at a fixed time; and (3) API callback: the business system actively calls the interface of the scheduling system to submit the trigger event information after the event occurs.
[0052] In step S12, a static time slice sequence is generated based on the business type and a preset fixed time slice size. Alternatively, in step S13, historical execution time consumption data consistent with the business type is called, a dynamic time slice size is calculated based on the historical execution time consumption data, and a dynamic time slice sequence is generated. The preset fixed time slice size refers to a time slice length that is pre-configured for a specific business type and does not dynamically change with the task execution condition. This parameter is stored in a system configuration table. The static time slice sequence refers to a set of time intervals that are continuously divided according to the preset fixed time slice size.
[0053] It should be noted that the overall purpose of step S12 is to provide a standardized time slice division scheme for tasks with stable business types and small execution time consumption fluctuations, ensuring the predictability of task scheduling. The system first queries the corresponding preset fixed time slice size from the configuration table according to the business type, then continuously divides the time intervals with a fixed length starting from the system start time, forms a static time slice sequence, and assigns a unique identifier to each time slice.
[0054] The historical execution time consumption data refers to the actual execution time records of tasks consistent with the current business type in the past period of time, such as the execution time consumption of the "real-time transaction processing" task in the past 30 days. The dynamic time slice size refers to a time slice length that is calculated based on the historical execution time consumption data and can be dynamically adjusted according to the task execution condition. The dynamic time slice sequence refers to a set of time intervals that are continuously divided according to the dynamic time slice size, and the time slice length may vary with each calculation result.
[0055] It should be noted that the overall purpose of step S13 is to provide an adaptive time slice division scheme for tasks with large execution time consumption fluctuations of the business type, avoiding resource waste or task timeout caused by fixed time slices. The system first calls the historical execution time consumption data consistent with the current business type in the past N days (such as 30 days) from the task execution log library, then calculates the dynamic time slice size through statistical algorithms (such as weighted average, quantile), and finally continuously divides the time intervals backward from the business trigger time to form a dynamic time slice sequence.
[0056] In one possible implementation, the calculation method for the dynamic time slice size includes: weighted average method: calculating a weighted average of the historical time-consuming data of the past 7 days according to time decay weights (e.g., 0.5 for today, 0.3 for yesterday, and 0.2 for the day before yesterday), and then multiplying it by a buffer coefficient of 1.2; quantile method: taking the 90th quantile of the historical time-consuming data as the dynamic time slice size to ensure that 90% of the tasks can be completed within the time slice; trend prediction method: predicting the time consumption of the next task through a linear regression model and using the predicted value as the dynamic time slice size.
[0057] Step S14: Determine the time slice parameter set based on the static time slice sequence or the dynamic time slice sequence; A time slice parameter set refers to a collection of parameters used to describe the key attributes of a time slice, including at least the time slice identifier, start time, end time, and time slice size. Static time slice sequences and dynamic time slice sequences serve as the data sources for the time slice parameter set, corresponding to fixed and dynamically divided time slice intervals, respectively.
[0058] Step S15: Determine the target time slice based on the time slice parameter set and the service trigger time, and create an initial task based on the target time slice.
[0059] The target time slice refers to the time slice selected from the time slice parameter set to which the business trigger time belongs, that is, the time slice that meets the condition of "start time ≤ business trigger time < end time"; the initial task refers to the unsplit task created based on the target time slice, which contains the original business data and execution logic, and is the basic unit for subsequent task splitting and scheduling.
[0060] It should be noted that the overall purpose of this step is to accurately map the business-triggered event to the corresponding time slice and generate an initial task, thus binding the task with time resources. The system first queries the time slice parameter set for all target time slices (usually unique) that match the business-triggered time. Then, it extracts the parameters of the target time slice (such as start time and business type) and associates them with the original data corresponding to the business-triggered event (such as order ID and transaction amount). Finally, it calls the task creation interface to generate the initial task and stores it in the "initial task table" of the task pool.
[0061] like Figure 3 As shown, Figure 3 A schematic diagram illustrating the time slice division provided for this application. n For the business trigger time points, P1~P n For the divided time slices; P d The time slice size, supporting hours, minutes, and seconds as units, P d The larger the value, the more granular the task; it can be dynamically adjusted as needed. ns For the Pth nThe start time of each time slice, P ne For the Pth n The end time of each time slice; J k For task J, the nth task kn The earliest start time of execution is P ne Based on the strategy of creating tasks according to time slices, P ns ≤n <P ne Then, business data with an open time point of tn is allocated to time slice P. n Corresponding task J kn In the middle, task J kn Conditions for obtaining time slice scheduling: Time slice P n End time P ne Tasks with earlier time slices will be executed first, provided the task scheduling time is less than or equal to the task scheduling time.
[0062] In this embodiment, by capturing business-triggered events and recording key information, and combining static or dynamic time-slice partitioning strategies to generate time-slice sequences adapted to different business types, a precise time-slice parameter set and target time-slice are determined, and initial tasks are created, achieving a deep binding between task scheduling and business scenarios. Static time-slice partitioning ensures predictable scheduling of tasks with stable business patterns, while dynamic time-slice partitioning adaptively adjusts the time-slice size based on historical time consumption data, improving the adaptability of task execution granularity and effectively avoiding resource waste or task timeouts caused by fixed time-slices. The standardized integration of the time-slice parameter set and the precise matching of the target time-slice ensure efficient binding of business trigger times with time resources, providing a refined time dimension basis for subsequent task splitting and scheduling. Ultimately, through a dynamic and static time-slice management mechanism and precise task creation logic, the timeliness of task scheduling, the efficiency of resource utilization, and adaptability to various business scenarios are significantly improved.
[0063] In one possible implementation, such as Figure 4 As shown, Figure 4 This is a schematic diagram illustrating a feasible implementation method provided in the second embodiment of this application. Step S15 is followed by steps S16-S17: Step S16: If the time slice parameter set is determined according to the dynamic time slice sequence, then record the actual time consumed by the initial task; When the system determines that the time slice parameter set comes from the dynamic time slice sequence, it will automatically trigger the actual time consumption recording mechanism. After the initial task is completed, the start time and end time are extracted from the task execution log, the time difference is calculated as the actual time consumption, and the metadata such as the task's business type and time slice identifier are associated and stored in the time consumption database.
[0064] Step S17: Update the historical execution time data according to the actual execution time.
[0065] By integrating new actual time consumption into historical data, the calculation of dynamic time slice size is based on the latest execution, thereby improving the accuracy of time slice division and the rationality of resource allocation. The system regularly or in real time reads the actual time consumption, classifies and summarizes according to the business type, updates the statistical indicators (such as average value, quantile) of historical execution time consumption data, and eliminates expired data (such as records exceeding 30 days), to ensure the timeliness and representativeness of historical data.
[0066] In one possible implementation, the update strategy of historical execution time consumption data includes: real-time incremental update: updating the statistical indicators of historical data of the corresponding business type immediately after generating a new actual time consumption record; timing batch update: batch summarizing the actual time consumption data of the previous day at dawn every day, and updating the sliding window (such as the average value of the last 7 days and 30 days) of historical data; outlier filtering: filtering abnormal time consumption data (such as extremely long time consumption caused by system failure) by IQR (interquartile range) method before updating, to avoid affecting the statistical results.
[0067] Based on the first and / or second embodiments of the present application, the third embodiment of the present application is proposed. In the third embodiment of the present application, the same or similar contents as the above embodiments can be referred to the above introduction, and will not be described in detail hereinafter.
[0068] On this basis, please refer to Figure 5 , Figure 5 is the process flow diagram of the third embodiment of the present application. As shown in Figure 5 , before the step S20 of selecting a splitting factor according to the business attribute characteristics of the initial task, and performing task splitting on the initial task based on the splitting factor to obtain a task set, the steps S01-S03 are further included: Step S01, reading a preset single task data amount threshold, and comparing the single task data amount threshold and the total amount of business data of the initial task; The preset single task data amount threshold refers to the maximum data amount critical value preset by the system for judging whether the initial task needs to be split, which can be configured according to factors such as business type and server performance.
[0069] The total amount of business data of the initial task refers to the total size of the business data contained in the initial task, such as the number of transaction records, file size, etc.; the comparison refers to the operation of the system to judge whether the total amount of business data exceeds the single task data amount threshold through numerical comparison.
[0070] It should be noted that the purpose of comparison is to realize dynamic decision of task processing mode by setting data amount threshold and comparing with actual business data amount, avoid low execution efficiency or high resource occupation caused by large data amount of single task, and avoid unnecessary waste caused by unnecessary splitting of small data amount task. The system first reads the preset single task data amount threshold (such as threshold table stored according to business type) from the configuration center, then extracts the total amount of business data from the metadata of the initial task, determines whether the task needs to be split through numerical comparison, and provides judgment basis for subsequent process.
[0071] In a possible implementation, the preset manner of single task data amount threshold includes: business type configuration: different threshold values are set for different business types (such as payment and account), for example, the payment task threshold is 500,000 and the report task threshold is 2,000,000; dynamic adjustment mechanism: the system regularly updates the threshold according to the historical task execution efficiency (such as average time consumption for processing 1,000,000 records), and automatically reduces the single task data amount threshold when the average time consumption exceeds the preset threshold (such as 30 minutes); user customization: the administrator manually adjusts the threshold of a specific business type through the operation and maintenance interface.
[0072] Step S02, if the total amount of business data is greater than the single task data amount threshold, then execute the following steps: select a splitting factor according to the business attribute characteristics of the initial task, and perform task splitting on the initial task based on the splitting factor to obtain a subtask set; The business attribute characteristics refer to the business dimension information associated with the initial task, such as the business type (such as payment and customer management) to which the task belongs, data characteristics (such as customer number and transaction area), etc.; the splitting factor refers to the key dimension or rule used to split the initial task, such as the last two digits of the customer number, the transaction date, the area code, etc.; the task splitting refers to the process of dividing the business data of the initial task into multiple independent subtasks according to the splitting factor; the subtask set refers to the set of multiple small-granularity tasks formed after splitting, each subtask containing part of the original data and independent execution logic.
[0073] It should be noted that the overall purpose of business splitting is to split large data amount tasks according to business attribute characteristics, decompose them into multiple subtasks that can be executed in parallel, and improve system resource utilization and task processing efficiency. The system first analyzes the business attribute characteristics (such as data distribution uniformity and business correlation) of the initial task, selects a suitable splitting factor (such as the last two digits of the customer number), then uniformly distributes the business data to multiple subtasks according to the splitting rule, ensures that the data amount of each subtask is close to and does not exceed the single task data amount threshold, and finally forms a set of subtasks that can be independently scheduled.
[0074] In a possible implementation, the selection strategy of the split factor includes: data uniformity priority: selecting a split factor that minimizes the difference in data volume of each subtask, for example, the last two digits of a customer number can uniformly split the data into 100 subtasks; business relevance priority: for tasks that need to be processed according to business logic grouping (such as regional statistical reports), selecting the region code as the split factor; dynamic adaptation: if the data volume of the subtasks after splitting still exceeds the threshold, automatically increasing the dimension of the split factor (such as the last three digits of the customer number) until the condition is met.
[0075] In step S03, if the total amount of business data is not greater than the single-task data volume threshold, the initial task is loaded to the idle thread pool, and task scheduling is performed on the initial task.
[0076] The idle thread pool refers to a thread pool in which there are currently available thread resources in the system, that is, the number of threads that are not occupied in the thread pool is greater than 0; task scheduling refers to an operation of allocating an initial task to an idle thread and controlling the execution process of the initial task, including thread allocation, execution state monitoring, result recycling, and the like.
[0077] It should be noted that the overall purpose of this step is to directly schedule the initial task with a small data volume, avoid the additional overhead caused by the splitting process, and improve the real-time performance of task processing. The system first checks the thread pool resource state, confirms that there is an idle thread, loads the initial task to the task queue of the thread pool, allocates an execution thread according to the task priority and thread idle condition, and monitors the task execution process to ensure that the task is completed within a specified time.
[0078] In this embodiment, by presetting the single-task data volume threshold and comparing it with the total amount of business data of the initial task, dynamic decision of the task processing mode is realized. When the total amount of business data exceeds the threshold, a split factor is selected according to the business attribute characteristics to split the task to obtain a subtask set, otherwise the initial task is directly loaded to the idle thread pool for scheduling, effectively balancing the task processing efficiency and resource overhead. The threshold comparison mechanism avoids unnecessary splitting of small data volume tasks and reduces process redundancy; the splitting strategy based on the business attribute characteristics ensures uniform splitting of large data volume tasks, and the combination of multi-host concurrent execution improves the system resource utilization and task processing rate; and the direct scheduling of the idle thread pool ensures the rapid response of the small data volume task. The three work together to enable the system to dynamically adapt the processing strategy according to the task data volume, to realize fine allocation and efficient use of resources when facing multiple types of high-concurrency tasks, and to significantly improve the flexibility and scalability of task scheduling.
[0079] Based on the above embodiments of the application, a fourth embodiment of the application is proposed. In the fourth embodiment of the application, the same or similar contents as the above embodiments can be referred to the above introduction, and will not be described in detail hereinafter.
[0080] In this embodiment, the step S20 of selecting a split factor according to the service attribute characteristics of the initial task and performing task splitting on the initial task based on the split factor to obtain a subtask set can include steps S21-S26: In step S21, the service type of the initial task is parsed, and core attribute characteristics are extracted based on the service type to generate a service attribute characteristic list. The core attribute characteristics refer to key data dimensions that are strongly associated with the service type, such as customer number, transaction date, region code, etc., and are the basis for task splitting. The service attribute characteristic list refers to a set of core attribute characteristics extracted by the system from the initial task metadata based on the service type, stored in a structured form (such as a list, array), for subsequent selection of a split factor.
[0081] By parsing the service type and extracting the core attribute characteristics, accurate dimension basis is provided for task splitting, ensuring that the splitting strategy is deeply adapted to the business scenario. The system first parses the service type through task metadata, then extracts core attribute characteristics by calling a pre-set "business-attribute mapping table", and finally generates a service attribute characteristic list containing multiple candidate dimensions.
[0082] In step S22, a split factor is selected from the service attribute characteristic list according to the service data distribution characteristics of the initial task. The service data distribution characteristics refer to the distribution of the initial task business data in each core attribute dimension, including data uniformity, concentration, dispersion, etc. statistical characteristics, such as "the last two digits of the customer number are uniformly distributed" and "the transaction region is concentrated in the East China region".
[0083] The split factor refers to the specific dimension or rule selected from the service attribute characteristic list for task splitting, such as "the last two digits of the customer number" and "transaction date". The selection of the split factor refers to the process of the system selecting the optimal splitting dimension from the list according to the service data distribution characteristics.
[0084] By analyzing the data distribution characteristics to select an appropriate split factor, it is ensured that the data volume of the split subtasks is uniform, avoiding slow execution of some subtasks due to data skew. The system first performs data distribution analysis (such as calculating the standard deviation, quantile) on each attribute in the service attribute characteristic list, and preferentially selects uniformly distributed attributes as the split factor. If there are multiple uniformly distributed attributes, further filtering is performed in combination with business relevance (such as "customer number" and account data strong association) to finally determine the unique split factor.
[0085] In step S23, a split granularity parameter is calculated according to the split factor, and the initial task is split according to the split granularity parameter to obtain an initial subtask set. The split granularity parameter refers to a parameter for controlling the degree of task split, including the number of split subtasks, the estimated data volume range of each subtask, the number of split dimensions (such as the last two / three digits of the customer number), etc. The initial subtask set refers to the subtask set formed after the initial task is first split according to the split factor and the split granularity parameter. Each subtask contains part of the business data and independent execution logic, but there may be cases where the data volume exceeds the threshold.
[0086] By calculating the split granularity parameter and performing the first split, the initial task is decomposed into parallelizable subtasks, providing a basis for subsequent fine-tuning. The system calculates the split granularity parameter according to the type of the split factor (such as character type, numerical type), for example, "last two digits of customer number" corresponds to 100 possible values (00-99), so the split granularity parameter is set to "subtask number = 100". Then, according to the value of the split factor, the business data is allocated to the corresponding subtask, forming the initial subtask set.
[0087] In one possible implementation, the calculation method of the split granularity parameter includes: for a character type split factor (such as the last two digits of the customer number), the number of subtasks is calculated as the product of the number of possible values per digit: 10 x 10 = 100.
[0088] Step S24, traversing the initial subtask set, checking whether the task data volume of each initial subtask in the initial subtask set meets the preset single task data volume threshold; Traversing the initial subtask set means that the system sequentially accesses each subtask in the initial subtask set and checks its data volume one by one. The task data volume refers to the number of business data records or data size contained in a single subtask.
[0089] The preset single task data volume threshold refers to the maximum data volume allowed for a single subtask, which is used to determine whether the subtask needs to be further split.
[0090] By checking whether the data volume of the initial subtask meets the threshold requirement, it is ensured that the split subtask will not cause execution timeout or high resource occupation due to excessive data volume. The system traverses the initial subtask set, calls the data volume statistical interface to obtain the actual data volume of each subtask, compares it with the preset threshold, and records the subtask information that does not meet the standard.
[0091] Step S25, if the task data volume of each initial subtask does not meet the preset single task data volume threshold, the number of split digits of the split factor is increased to obtain an updated split factor; Splitting bit refers to the length of characters or the number of numerical bits used for splitting in the splitting factor, for example, the splitting bit of "the last two digits of the customer number" is 2. The updated splitting factor refers to the new splitting factor formed after increasing the splitting bit, for example, adjusting "the last two digits of the customer number" to "the last three digits of the customer number", the splitting bit is increased from 2 to 3.
[0092] By dynamically increasing the splitting bit, the splitting granularity is refined to ensure that the data volume of the subtask exceeding the threshold is reduced below the threshold. When the system detects that the data volume of the initial subtask does not meet the threshold, it automatically increases the splitting bit of the splitting factor to re-split.
[0093] Step S26, the updated splitting factor is used to recalculate the splitting granularity parameter to perform task splitting on the initial subtask until the task data volume of each initial subtask in the initial subtask set meets the preset single task data volume threshold, and a subtask set is obtained.
[0094] Recalculating the splitting granularity parameter means re-determining parameters such as the number of subtasks and the data volume range based on the updated splitting factor, for example, "the last four digits of the customer number" corresponds to 10000 subtasks; the subtask set refers to the final task set after multiple splitting adjustments, all of which meet the single task data volume threshold, which can be directly used for subsequent scheduling and execution.
[0095] By iteratively adjusting the splitting factor and recalculating the parameters, it is ensured that the data volume of all subtasks meets the threshold requirement, and the refinement and standardization of task splitting are realized. The system uses the updated splitting factor (such as the last four digits of the customer number) to recalculate the splitting granularity parameter (such as the number of subtasks = 10000), and performs secondary splitting on the initial subtask exceeding the threshold, and checks again whether the data volume meets the standard. If there are still subtasks that do not meet the standard, repeat the splitting until all subtasks meet the threshold, and finally generate an executable subtask set.
[0096] In the embodiment, the fine and adaptive splitting of large data volume tasks is realized by analyzing the service type to extract core attribute features, selecting a splitting factor in combination with data distribution characteristics, dynamically adjusting the splitting granularity parameter, and iteratively optimizing the subtask data volume. Among them, the splitting factor is selected based on the service attribute feature list and the data distribution characteristics, which ensures the depth adaptation of the splitting dimension and the business scenario; by calculating the splitting granularity parameter and checking the subtask data volume threshold, the problem of excessive or insufficient splitting is avoided; and the iterative mechanism of dynamically increasing the number of splitting bits can flexibly adjust the splitting fineness according to the actual data volume, and ensure that all subtask data volumes meet the preset threshold. This process not only solves the problem of resource waste or execution timeout caused by fixed task splitting granularity and uneven data distribution in the prior art, but also makes the subtasks have uniform data distribution and adaptive processing granularity through the double consideration of business attributes and data characteristics, providing an efficient basis for subsequent multi-host concurrent scheduling, and finally improving the processing efficiency and resource utilization of the system for high-concurrency and large-data-volume tasks.
[0097] Based on the above embodiments of the application, the fifth embodiment of the application is proposed. In the fifth embodiment of the application, the same or similar contents as the above embodiments can be referred to the above introduction, and will not be described in detail hereinafter.
[0098] On this basis, please refer to Figure 6 , Figure 6 is the flowchart of the fifth embodiment of the application. As shown in Figure 6 , the step S30 of obtaining the static configuration parameters of the subtask set and loading the subtask set to the thread pool for task scheduling according to the static configuration parameters and the preset business timeliness rule includes steps S31-S34: Step S31, loading the subtask set to the thread pool and obtaining the static configuration parameters of the subtask set, the static configuration parameters including task priority and maximum concurrency; The split subtask set is loaded into the thread pool, and the key static configuration parameters are obtained to provide basic data for subsequent scheduling decision. The system first adds the subtask set to the task queue of the thread pool through the thread pool management module, and then reads the static configuration parameters corresponding to the subtask set from the configuration center, to ensure that the scheduling process meets the preset resource constraints and business rules.
[0099] Step S32, querying the number of idle threads in the thread pool that are not occupied, if the number of idle threads is greater than zero, obtaining the task type and task quantity of the subtask set; The number of idle threads refers to the total number of threads in the thread pool that are not currently occupied, that is, the total capacity of the thread pool minus the number of threads executing tasks; the task type refers to the business category to which the sub-task set belongs; and the task quantity refers to the total number of sub-tasks included in the sub-task set.
[0100] The number of idle threads is queried to determine the availability of system resources, and the basic information of the sub-task set is obtained when the resources are sufficient, thereby providing a basis for subsequent scheduling range determination. The system queries the number of idle threads in real time through a thread pool state monitoring interface, and if the number is greater than 0 (for example, the current number of idle threads is 5), the task type and the task quantity are extracted from the metadata of the sub-task set, thereby ensuring that the subsequent scheduling decision matches the task characteristics.
[0101] In step S33, the task type and the task quantity of the sub-task set are determined according to the task type, the task quantity of the sub-task set, and a preset business timeliness rule, and the priority of the to-be-scheduled sub-task set is sorted according to the task priority. The to-be-scheduled sub-task set refers to a subset of sub-tasks that meet the business timeliness rule and can be immediately scheduled, for example, at the current time 9:00, tasks with an execution time of 9:00 need to be processed.
[0102] The priority sorting refers to sorting according to the order of time slices, and tasks with earlier time slices are executed preferentially.
[0103] For example, in a specific embodiment, there are 100 sub-tasks in the sub-task set, 50 of which have an execution time of 9:00. When the execution time is reached, the tasks that reach the execution time are selected from the sub-task set to obtain the to-be-scheduled sub-task set. The 50 sub-tasks in the to-be-scheduled sub-task set are divided into different time slices, and the to-be-scheduled sub-task set is sorted according to the task priority of the task with the earlier time slice.
[0104] In step S34, the to-be-scheduled sub-task set sorted by priority is loaded into the idle thread pool in batches according to the maximum concurrency and the number of idle threads to allocate thread resources, and the to-be-scheduled sub-task set is executed.
[0105] The batch loading refers to the process of splitting the to-be-scheduled sub-task set sorted by priority into multiple batches according to the number of idle threads and the maximum concurrency, and allocating thread resources in batches; the thread resource refers to the idle thread in the thread pool that can be used to execute tasks, including thread ID, memory allocation, CPU time slice, etc.; and the execution of the to-be-scheduled sub-task set refers to the operation of starting task execution and monitoring the process after the thread pool allocates sub-tasks to idle threads.
[0106] According to the system resource constraint, the thread is reasonably allocated, and resource overload or waste is avoided. The system first calculates the number of subtasks that can be loaded in each batch, then loads the subtasks to the idle thread pool in batches according to the priority sorting result, allocates thread resources and starts execution, and records the number of executed tasks to ensure that the maximum concurrency limit is not exceeded.
[0107] In the embodiment, by loading the subtask set to the thread pool and obtaining the static configuration parameters, and dynamically screening the tasks to be dispatched according to the number of idle threads, fine resource allocation and priority control of task scheduling are realized. Among them, loading static configuration parameters provides rigid constraints for scheduling to avoid resource overload; querying the number of idle threads ensures that resource allocation is based on real-time system load to avoid invalid scheduling; screening and prioritizing the subtask set to be dispatched based on business timeliness rules ensures that urgent tasks have priority to obtain resources; and loading tasks in batches according to the maximum concurrency and the number of idle threads realizes the elastic allocation of resources, which fully utilizes idle threads and prevents high concurrency from causing system congestion. Under the synergistic action of the four steps, the system can balance between static configuration and dynamic resources, ensure the timeliness of high-priority tasks, improve resource utilization through batch scheduling, and effectively solve the problems of rigid resource allocation and delayed response to urgent tasks in traditional scheduling.
[0108] In a possible implementation, with reference to Figure 7 , Figure 7 A feasible implementation scheme of the fifth embodiment of the application is provided. As shown in Figure 7 , the subtask set to be dispatched is loaded to the idle thread pool according to the maximum concurrency and the number of idle threads to allocate thread resources, and the step S34 of executing the subtask set to be dispatched further includes steps S35-S36: Step S35, querying whether there is an idle thread in the thread pool; Querying whether there is an idle thread in the thread pool means that the system checks whether there is an unoccupied thread resource through the thread pool management interface, which is a key condition for determining whether to continue scheduling.
[0109] Real-time monitoring of thread pool resource status ensures timely subsequent task scheduling when there is an idle thread, avoiding resource idling. The system queries the number of idle threads in the thread pool through periodic polling or event triggering, and if the number is greater than 0, the loop scheduling logic is triggered; if it is equal to 0, the next query is waited.
[0110] Step S36, if there is an idle thread in the thread pool, return to the step of determining the subtask set to be dispatched according to the task type and the number of tasks in the subtask set, and prioritizing the subtask set to be dispatched according to the task priority.
[0111] The system reselects a new to-be-scheduled subtask set (for example, 10 tasks meeting the time limit requirement are selected from the remaining 50 tasks) according to the task type, task quantity and business time limit rule of the subtask set, and reorders the tasks according to the task priority, to prepare for the thread allocation of the next batch, so as to avoid resource waste caused by incomplete single scheduling.
[0112] In a possible implementation, the termination condition of the cycle scheduling includes: the to-be-scheduled subtask set is empty: all subtasks are executed completely; the number of idle threads in the thread pool is 0 for a preset time (for example, 5 minutes): it is determined that the system resource is insufficient, the scheduling is suspended, and a log is recorded; the maximum number of scheduling is reached: to avoid infinite loop (for example, the maximum cycle is set to 100 times, and after exceeding, the cycle is forcibly terminated and an alarm is given).
[0113] The application also provides a task scheduling device, please refer to Figure 8 The task scheduling device comprises: A time slice division module 10 is configured to obtain a business trigger time, perform time slice division based on the business trigger time, and obtain an initial task; the time slice division includes static time slice division and dynamic time slice division; A task splitting module 20 is configured to select a splitting factor according to a business attribute feature of the initial task, and split the initial task based on the splitting factor to obtain a subtask set; A scheduling module 30 is configured to obtain a static configuration parameter of the subtask set, load the subtask set to a thread pool based on the static configuration parameter and a preset business time limit rule to perform task scheduling.
[0114] The task scheduling device provided by the application adopts the task scheduling method in the above embodiments, and can solve the technical problem of task scheduling. Compared with the prior art, the task scheduling device provided by the application has the same beneficial effects as the task scheduling method provided by the above embodiments, and other technical features in the task scheduling device are the same as the features disclosed in the above embodiments, which will not be repeated here.
[0115] The application provides a task scheduling device, which comprises at least one processor and a memory connected with the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the task scheduling method in the above embodiment one.
[0116] The following refers to Figure 9The diagram illustrates a structural schematic of a task scheduling device suitable for implementing embodiments of this application. The task scheduling device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 9 The task scheduling device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0117] like Figure 9 As shown, the task scheduling device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in the read-only memory 1002 or a program loaded from the storage device 1003 into the random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the task scheduling device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the task scheduling device to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows task scheduling devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0118] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for executing the method shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network through a communication device, or installed from the storage device 1003, or installed from the read-only memory 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiments disclosed in the present application are executed.
[0119] The task scheduling device provided by the present application adopts the task scheduling method in the above-mentioned embodiments, and can solve the technical problem of task scheduling. Compared with the prior art, the task scheduling device provided by the present application has the same beneficial effects as the task scheduling method provided by the above-mentioned embodiments, and other technical features in the task scheduling device are the same as the features disclosed in the previous embodiment method, which will not be repeated here.
[0120] It should be understood that various parts of the present application can be realized by hardware, software, firmware or a combination thereof. In the description of the above-mentioned embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0121] The above is merely specific embodiments of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
[0122] The present application provides a computer readable storage medium having stored thereon computer readable program instructions (i.e. computer program) for executing the task scheduling method in the above-mentioned embodiments.
[0123] The computer readable storage medium provided in the present application may, for example, be a U disk, but is not limited to an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system or device, or any combination thereof. More specific examples of the computer readable storage medium can include, but are not limited to, an electric connection with one or more conductive wires, a portable computer disk, a hard disk, a random access memory (RAM), a read only memory (ROM), an erasable programmable read only memory (EPROM or flash memory), an optical fiber, a portable compact disk read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present embodiment, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer readable storage medium can be transmitted in any suitable medium, including but not limited to an electric wire, an optical cable, an RF (Radio Frequency), and the like, or any suitable combination thereof.
[0124] The above computer readable storage medium can be contained in the task scheduling device, or can exist separately without being assembled into the task scheduling device.
[0125] The above computer readable storage medium carries one or more programs, which, when executed by the task scheduling device, cause the task scheduling device to perform task scheduling.
[0126] The computer program code for performing the operations of the present application can be written in one or more programming languages or combinations thereof, including an object-oriented programming language such as Java, Smalltalk, C++, or a conventional procedural programming language such as "C" language or similar programming languages. The program code can be executed entirely on a user computer, partially on a user computer, as an independent software package, partially on a user computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, through the Internet using an Internet service provider).
[0127] The flowcharts and block diagrams in the drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks can sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations thereof, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or combinations of hardware and software.
[0128] The modules involved in the embodiments of the present application can be implemented in software or in hardware. In some cases, the names of the modules do not limit the modules themselves.
[0129] The readable storage medium provided by the present application is a computer readable storage medium, which stores computer readable program instructions (i.e. computer programs) for executing the above task scheduling method, and can solve the technical problem of task scheduling. Compared with the prior art, the computer readable storage medium provided by the present application has the same beneficial effects as the task scheduling method provided by the above embodiments, which will not be repeated here.
[0130] The present application also provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the task scheduling method as described above.
[0131] The computer program product provided by the present application can solve the technical problem of task scheduling. Compared with the prior art, the computer program product provided by the present application has the same beneficial effects as the task scheduling method provided by the above embodiments, which will not be repeated here.
[0132] The above only describes some embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structural transformation made by using the content of the present application specification and drawings, or direct / indirect application in other related technical fields is included in the patent protection scope of the present application.
Claims
1. A task scheduling method, characterized by, The task scheduling method comprises: obtaining a service trigger time, performing time slice division based on the service trigger time to obtain an initial task; the time slice division mode comprises static time slice division and dynamic time slice division; selecting a splitting factor according to the service attribute characteristics of the initial task, and performing task splitting on the initial task based on the splitting factor to obtain a subtask set; obtaining static configuration parameters of the subtask set, and loading the subtask set to a thread pool according to the static configuration parameters and a preset service timeliness rule to perform task scheduling.
2. The task scheduling method of claim 1, wherein, The step of obtaining a service trigger time, performing time slice division based on the service trigger time to obtain an initial task comprises: capturing a trigger event generated by a service system, recording a service trigger time and a service type of the trigger event; generating a static time slice sequence based on the service type and a preset fixed time slice size; or, calling historical execution time consumption data consistent with the service type, calculating a dynamic time slice size based on the historical execution time consumption data, and generating a dynamic time slice sequence; determining a time slice parameter set according to the static time slice sequence or the dynamic time slice sequence; determining a target time slice according to the time slice parameter set and the service trigger time, and creating an initial task based on the target time slice.
3. The task scheduling method of claim 2, wherein, The step of creating an initial task based on the target time slice further comprises: if the time slice parameter set is determined according to the dynamic time slice sequence, recording an actual time consumption of the initial task; updating the historical execution time consumption data according to the actual time consumption.
4. The task scheduling method of claim 1, wherein, The step of selecting a splitting factor according to the service attribute characteristics of the initial task, and performing task splitting on the initial task based on the splitting factor to obtain a subtask set further comprises: reading a preset single task data amount threshold, comparing the single task data amount threshold and a total amount of service data of the initial task; if the total amount of service data is greater than the single task data amount threshold, performing the step of selecting a splitting factor according to the service attribute characteristics of the initial task, and performing task splitting on the initial task based on the splitting factor to obtain a subtask set; if the total amount of service data is not greater than the single task data amount threshold, loading the initial task to an idle thread pool, and performing task scheduling on the initial task.
5. The task scheduling method of claim 1, wherein, The step of selecting a splitting factor according to the service attribute characteristics of the initial task, and performing task splitting on the initial task based on the splitting factor to obtain a subtask set comprises: analyzing a service type of the initial task, extracting core attribute characteristics based on the service type to generate a service attribute characteristic list; selecting a splitting factor from the service attribute characteristic list according to a service data distribution characteristic of the initial task; calculating a splitting granularity parameter according to the splitting factor, and performing task splitting on the initial task according to the splitting granularity parameter to obtain an initial subtask set; traversing the initial subtask set, checking whether a task data amount of each initial subtask in the initial subtask set meets a preset single task data amount threshold; If the task data volume of each initial subtask does not meet the preset single-task data volume threshold, the splitting bit number of the splitting factor is increased to obtain an updated splitting factor; The splitting granularity parameter is recalculated using the updated splitting factor to perform task splitting on the initial subtasks until the task data volume of each initial subtask in the initial subtask set meets the preset single-task data volume threshold, and a subtask set is obtained.
6. The task scheduling method of claim 1, wherein, The step of obtaining the static configuration parameters of the subtask set and loading the subtask set to a thread pool for task scheduling according to the static configuration parameters and a preset service timeliness rule comprises: The subtask set is loaded to the thread pool, and the static configuration parameters of the subtask set are obtained, the static configuration parameters comprising a task priority and a maximum concurrency number; The number of idle threads in the thread pool that are not occupied is queried, and if the number of idle threads is greater than zero, the task type and the number of tasks of the subtask set are obtained; The task type, the number of tasks of the subtask set, and a preset service timeliness rule are used to determine a to-be-scheduled subtask set, and the to-be-scheduled subtask set is prioritized according to the task priority; The prioritized to-be-scheduled subtask set is loaded to the idle thread pool in batches according to the maximum concurrency number and the number of idle threads to allocate thread resources, and the to-be-scheduled subtask set is executed.
7. The task scheduling method of claim 6, wherein, The step of loading the prioritized to-be-scheduled subtask set to the idle thread pool in batches according to the maximum concurrency number and the number of idle threads to allocate thread resources, and executing the to-be-scheduled subtask set further comprises: It is queried whether there are idle threads in the thread pool; If there are idle threads in the thread pool, the step of determining a to-be-scheduled subtask set according to the task type and the number of tasks of the subtask set, and prioritizing the to-be-scheduled subtask set according to the task priority is returned.
8. A task scheduling device, characterized by comprising: The device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the task scheduling method according to any one of claims 1 to 7.
9. A storage medium, characterized by The storage medium is a computer-readable storage medium, and the storage medium stores a computer program, the computer program being executed by a processor to implement the steps of the task scheduling method according to any one of claims 1 to 7.
10. A computer program product, characterised in that, The computer program product comprises a computer program, the computer program being executed by a processor to implement the steps of the task scheduling method according to any one of claims 1 to 7.
