CN117573325A - Task scheduling method and device, equipment and storage medium - Google Patents

Task scheduling method and device, equipment and storage medium Download PDF

Info

Publication number
CN117573325A
CN117573325A CN202311643410.3A CN202311643410A CN117573325A CN 117573325 A CN117573325 A CN 117573325A CN 202311643410 A CN202311643410 A CN 202311643410A CN 117573325 A CN117573325 A CN 117573325A
Authority
CN
China
Prior art keywords
task
scheduling
target
execution
pointer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311643410.3A
Other languages
Chinese (zh)
Inventor
余乔
虞川
彭信荣
敖荣徽
杨琛文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Unicom Guangdong Industrial Internet Co Ltd
Original Assignee
China Unicom Guangdong Industrial Internet Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Unicom Guangdong Industrial Internet Co Ltd filed Critical China Unicom Guangdong Industrial Internet Co Ltd
Priority to CN202311643410.3A priority Critical patent/CN117573325A/en
Publication of CN117573325A publication Critical patent/CN117573325A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the application discloses a task scheduling method, a device, equipment and a storage medium, wherein the method comprises the following steps: pushing a target task into a task list in a task scheduling queue based on the execution time of the target task in the waiting queue, wherein the waiting queue comprises target tasks to be scheduled, the task scheduling queue comprises a scheduling time wheel, the scheduling time wheel is divided into a plurality of scheduling intervals in a closed loop mode, and each scheduling interval comprises a task list; submitting target tasks in the task list in each scheduling interval to a thread pool for scheduling according to the sequence through a scheduling time wheel; and sending the target task to an execution client corresponding to the target task based on the thread pool. The flexibility of task scheduling is improved, and the reliability of the whole task scheduling system is improved.

Description

Task scheduling method and device, equipment and storage medium
Technical Field
The embodiment of the application relates to a distributed task technology, and relates to a task scheduling method, a device, equipment and a storage medium.
Background
In a distributed system, when tasks need to be issued to a plurality of subordinate executors for execution, it is generally necessary to schedule all tasks by a server.
In the prior art, when a task is scheduled, it is common to place a task in a scheduling queue after the task is generated, and to sequentially process the scheduling work of each task.
However, in the actual implementation process, when the situations of delay, failure and the like occur, the task cannot be scheduled in time, the scheme in the prior art is poor in flexibility, and the task scheduling strategy cannot be flexibly adjusted, so that the reliability of the whole task scheduling system is low.
Disclosure of Invention
In view of this, the task scheduling method, device, equipment and storage medium provided in the embodiments of the present application can improve flexibility of task scheduling and improve reliability of the whole task scheduling system. The task scheduling method, the device, the equipment and the storage medium provided by the embodiment of the application are realized as follows:
the task scheduling method provided by the embodiment of the application is applied to a server and comprises the following steps:
pushing a target task into a task list in a task scheduling queue based on the execution time of the target task in the waiting queue, wherein the waiting queue comprises target tasks to be scheduled, the task scheduling queue comprises a scheduling time wheel, the scheduling time wheel is divided into a plurality of scheduling intervals in a closed loop mode, and each scheduling interval comprises a task list;
Submitting target tasks in the task list in each scheduling interval to a thread pool for scheduling according to the sequence through a scheduling time wheel;
and sending the target task to an execution client corresponding to the target task based on the thread pool.
In some embodiments, pushing the target task into the task list in the task scheduling queue based on the execution time of the target task in the waiting queue includes:
determining a target scheduling interval based on the execution time of the target task in the waiting queue, wherein the target scheduling interval is one of a plurality of scheduling intervals;
pushing the target task into a task list in the target scheduling interval.
In some embodiments, determining the target scheduling interval based on the execution time of the target task in the wait queue includes:
calculating pointer offset and/or pointer step number according to the execution time of the target task in the waiting queue;
the target scheduling interval is determined based on the pointer offset and/or the number of pointer steps.
In some embodiments, submitting target tasks within the task list in each scheduling interval to the thread pool schedule sequentially by the scheduling time wheel includes:
starting from an initial position through a pointer of a scheduling time wheel, stepping according to a preset clockwise direction, and determining whether a target task needing to be scheduled in the current period exists in a task list in a target scheduling interval when the pointer is stepped to the target scheduling interval;
If yes, submitting the target task to the thread pool for scheduling.
In some embodiments, determining whether there is a target task in the task list within the target scheduling interval that needs to be scheduled within the current period includes:
determining the execution period of each task in a task list of a target scheduling interval;
if the execution cycle of the task is smaller than or equal to the stepping cycle number of the pointer, the task is used as a target task to be scheduled in the current cycle, and the stepping cycle number of the pointer is used for indicating the stepping cycle number of the pointer from the initial position to the current position.
In some embodiments, when the pointer of the schedule-time wheel is stepped to a next interval of the target schedule interval, the method further comprises:
determining the time of the next round according to the period duration of the scheduling time wheel, wherein the time of the next round represents the time required by the pointer of the scheduling time wheel to step to the target scheduling interval again;
and dormancy is carried out on the threads of the task queues in the target scheduling interval until the next round of time.
In some embodiments, the method further comprises:
determining the execution position of the canceling task based on the task list position of the target task which is required to cancel the canceling task in the canceling queue;
pushing the canceling task into a task scheduling queue, and deleting the target task in the execution position of the canceling task.
The task scheduling device provided by the embodiment of the application is applied to a server, and comprises: the device comprises a pushing module, a scheduling module and a issuing module;
the pushing module is used for pushing the target task into a task list in a task scheduling queue based on the execution time of the target task in the waiting queue, the waiting queue comprises the target task to be scheduled, the task scheduling queue comprises a scheduling time wheel, the scheduling time wheel is divided into a plurality of scheduling intervals in a closed loop mode, and each scheduling interval comprises a task list;
the scheduling module is used for sequentially submitting target tasks in the task list in each scheduling interval to the thread pool for scheduling through the scheduling time wheel;
and the issuing module is used for sending the target task to the execution client corresponding to the target task based on the thread pool.
In some embodiments, the pushing module is specifically configured to determine a target scheduling interval based on an execution time of a target task in the waiting queue, where the target scheduling interval is one of a plurality of scheduling intervals; pushing the target task into a task list in the target scheduling interval.
In some embodiments, the pushing module is further configured to calculate a pointer offset and/or a pointer step number according to an execution time of the target task in the waiting queue; the target scheduling interval is determined based on the pointer offset and/or the number of pointer steps.
In some embodiments, the scheduling module is specifically configured to step from an initial position according to a preset clockwise direction through a pointer of a scheduling time wheel, and determine whether a target task to be scheduled in the current period exists in a task list in a target scheduling interval when the pointer steps to the target scheduling interval; if yes, submitting the target task to the thread pool for scheduling.
In some embodiments, the scheduling module is specifically configured to determine an execution period of each task in the task list of the target scheduling interval; if the execution cycle of the task is smaller than or equal to the stepping cycle number of the pointer, the task is used as a target task to be scheduled in the current cycle, and the stepping cycle number of the pointer is used for indicating the stepping cycle number of the pointer from the initial position to the current position.
In some embodiments, the scheduling module is further configured to determine a next round of time according to a period duration of the scheduled time round, where the next round of time represents a time required for the pointer of the scheduled time round to step to the target scheduling interval again; and dormancy is carried out on the threads of the task queues in the target scheduling interval until the next round of time.
In some embodiments, the pushing module is further configured to determine an execution position of the cancellation task based on a task list position where a target task that is required to be cancelled by the cancellation task in the cancellation queue is located; pushing the canceling task into a task scheduling queue, and deleting the target task in the execution position of the canceling task.
The computer device provided by the embodiment of the application comprises a memory and a processor, wherein the memory stores a computer program capable of running on the processor, and the processor executes the program to realize the method of the embodiment of the application.
The computer readable storage medium provided in the embodiments of the present application stores a computer program thereon, which when executed by a processor implements the method provided in the embodiments of the present application.
In the task scheduling method, the device, the equipment and the storage medium provided by the embodiment of the application, the target task can be pushed into a task list in a task scheduling queue based on the execution time of the target task in the waiting queue, the waiting queue comprises the target task to be scheduled, the task scheduling queue comprises a scheduling time wheel, the scheduling time wheel is divided into a plurality of scheduling intervals in a closed loop mode, and each scheduling interval comprises the task list; submitting target tasks in the task list in each scheduling interval to a thread pool for scheduling according to the sequence through a scheduling time wheel; and sending the target task to an execution client corresponding to the target task based on the thread pool. The scheduling time wheel is based on the fact that each target task can be submitted to threads to be scheduled and distributed more flexibly and systematically, so that different tasks can be issued to different execution clients more flexibly, and the execution efficiency of the tasks and the reliability of the whole task scheduling system are improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and, together with the description, serve to explain the technical aspects of the application.
Fig. 1 is an application scenario schematic diagram of a task scheduling method provided in an embodiment of the present application;
fig. 2 is a flow chart of a task scheduling method provided in an embodiment of the present application;
FIG. 3 is another flow chart of a task scheduling method provided in an embodiment of the present application;
FIG. 4 is another flow chart of a task scheduling method provided in an embodiment of the present application;
fig. 5 is an exhibition diagram of a scheduling time wheel in the task scheduling method provided in the embodiment of the present application;
FIG. 6 is another flow chart of a task scheduling method provided in an embodiment of the present application;
FIG. 7 is another flow chart of a task scheduling method provided in an embodiment of the present application;
FIG. 8 is another flow chart of a task scheduling method provided in an embodiment of the present application;
FIG. 9 is another flow chart of a task scheduling method provided in an embodiment of the present application;
FIG. 10 is a schematic diagram of an overall architecture based on scheduling between a server and a client provided in an embodiment of the present application;
FIG. 11 is a schematic flow chart of task scheduling execution provided in an embodiment of the present application;
fig. 12 is a schematic structural diagram of a task scheduling device provided in an embodiment of the present application;
fig. 13 is a schematic structural diagram of a computer device provided in an embodiment of the present application.
Detailed Description
For the purposes, technical solutions and advantages of the embodiments of the present application to be more apparent, the specific technical solutions of the present application will be described in further detail below with reference to the accompanying drawings in the embodiments of the present application. The following examples are illustrative of the present application, but are not intended to limit the scope of the present application.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
It should be noted that the term "first/second/third" in reference to the embodiments of the present application is used to distinguish similar or different objects, and does not represent a specific ordering of the objects, it being understood that the "first/second/third" may be interchanged with a specific order or sequence, as permitted, to enable the embodiments of the present application described herein to be implemented in an order other than that illustrated or described herein.
In view of this, the embodiment of the application provides a task scheduling method, which is applied to a server. Fig. 1 is a schematic application scenario of a task scheduling method provided in the embodiment of the present application, referring to fig. 1, the scenario may include a server 110 and a plurality of clients 120, where the server 110 may be a computer device that performs task scheduling in a cloud, for example: cloud servers, etc., and the client 120 may be a terminal electronic device for performing task execution, and may include, but is not limited to, a mobile phone, a wearable device (e.g., smart watch, smart bracelet, smart glasses, etc.), a tablet computer, a notebook computer, a vehicle-mounted terminal, a PC (Personal Computer ), etc. In this actual implementation, the server 110 may be communicatively connected to the plurality of clients 120, and the functions implemented by the method may be implemented by a processor in the server 110 calling program code, where the program code may be stored in a computer storage medium, and it is visible that the server includes at least the processor and the storage medium.
In performing task processing, the server 110 specifically performs task scheduling work, that is, work of a scheduler, and specifically may determine that each task is allocated to a specific executor for execution. The client 120 specifically performs task execution, that is, the task of the executor, specifically, may execute the task after receiving the corresponding task.
It should be noted that the scenario may specifically be a task scheduling system.
The following explains a specific implementation procedure of the task scheduling method provided in the embodiment of the present application based on the specific application scenario described above.
Fig. 2 is a flow chart of a task scheduling method provided in an embodiment of the present application, referring to fig. 2, the task scheduling method includes:
s210: pushing the target task into a task list in a task scheduling queue based on the execution time of the target task in the waiting queue.
The waiting queue comprises target tasks to be scheduled, the task scheduling queue comprises a scheduling time wheel, the scheduling time wheel is divided into a plurality of scheduling intervals in a closed loop mode, and each scheduling interval comprises a task list.
It should be noted that the method may be specifically applied to a server in the above scenario, and the method may be implemented when the server performs a scheduling task as a scheduler.
The waiting queue may specifically be a queue for pushing tasks into the task scheduling queue, and after generating new target tasks to be scheduled, the target tasks may be stored in the waiting queue, and pushed into the task scheduling queue by the waiting queue in order.
The target tasks may include a plurality of target tasks, and different target tasks may execute different scheduling schemes to implement corresponding scheduling tasks.
The task scheduling queue can be specifically represented in a manner of a scheduling time wheel, wherein the scheduling time wheel can specifically comprise a closed annular area and a pointer which is arranged in the middle of the annular area and can rotate, a plurality of scheduling intervals are divided in a closed loop in the closed annular area, the pointer can rotate according to a certain rotation direction when scheduling is carried out, and different scheduling intervals can be pointed at different times.
Each scheduling interval may correspond to a task list, and the task list may store tasks included in the corresponding scheduling interval.
In the pushing process of the target task, the target task can be pushed into a specific task list in the task scheduling queue from the waiting queue.
It should be noted that, in the actual implementation process, the waiting queue may include a plurality of target tasks, the step S210 may be executed for each target task in turn, so as to implement push-in work of each target task, and different target tasks may be pushed into different task lists in the task scheduling queue.
S220: and submitting the target tasks in the task list in each scheduling interval to the thread pool for scheduling according to the sequence through the scheduling time wheel.
Optionally, the order of submitting the tasks to the thread pool may be determined specifically by a scheduling time wheel, and during the working process of the scheduling time wheel, the order may be determined specifically by rotation of a pointer, and the target tasks in the task list in each scheduling interval may be submitted to the thread pool in turn for scheduling.
The pointer sequentially passes through each scheduling interval in the rotating process, and if a target task of the period exists in the passing scheduling interval, the target task can be submitted to a thread pool; accordingly, for each scheduling interval, a target task may be submitted to the thread pool in a similar manner, thereby implementing the task scheduling work.
S230: and sending the target task to an execution client corresponding to the target task based on the thread pool.
Optionally, the thread pool may specifically allocate the obtained target task to each executor for execution, that is, may issue the target task to an execution client corresponding to the target task.
In the task scheduling method provided by the embodiment of the application, the target task can be pushed into a task list in a task scheduling queue based on the execution time of the target task in the waiting queue, the waiting queue comprises the target task to be scheduled, the task scheduling queue comprises a scheduling time wheel, the scheduling time wheel is divided into a plurality of scheduling intervals in a closed loop mode, and each scheduling interval comprises a task list; submitting target tasks in the task list in each scheduling interval to a thread pool for scheduling according to the sequence through a scheduling time wheel; and sending the target task to an execution client corresponding to the target task based on the thread pool. The scheduling time wheel is based on the fact that each target task can be submitted to threads to be scheduled and distributed more flexibly and systematically, so that different tasks can be issued to different execution clients more flexibly, and the execution efficiency of the tasks and the reliability of the whole task scheduling system are improved.
The following specifically explains a specific implementation process of pushing a task list in the task scheduling method provided in the embodiment of the present application.
Fig. 3 is another flow chart of a task scheduling method provided in an embodiment of the present application, please refer to fig. 3, which pushes a target task into a task list in a task scheduling queue based on an execution time of the target task in the waiting queue, including:
s310: and determining a target scheduling interval based on the execution time of the target task in the waiting queue.
Wherein the target scheduling interval is one of a plurality of scheduling intervals.
Alternatively, for each target task stored in the waiting queue, there may be corresponding attribute information, where the attribute information may characterize a certain attribute of the target task, for example: the execution time of the target task may be determined, which refers in particular to the execution time of performing a scheduling job on the target task.
The target scheduling interval to which the target task specifically should be pushed may be calculated based on the execution time, for example: if there are N scheduling intervals in the scheduling time wheel, determining which scheduling interval is in the target task based on the execution time of the target task, and taking the scheduling interval as the target scheduling interval.
It should be noted that, for a timing task, the execution time is fixed; for non-timed tasks, the execution time is not fixed, and the time it can execute can be determined based on the saturation level of the current thread pool, thereby being the execution time of the task.
For each target task in the waiting queue, the execution time of the target task can be determined in the mode, so that the target scheduling interval corresponding to each target task is determined.
S320: pushing the target task into a task list in the target scheduling interval.
Optionally, after determining the target scheduling interval corresponding to the target task, the target task may be pushed into the task list in the target scheduling interval.
For the task list in each scheduling interval, after the target task is pushed in, the relevant attribute information of the target task may be stored together.
In the task scheduling method provided by the embodiment of the application, the target scheduling interval can be determined based on the execution time of the target task in the waiting queue; pushing the target task into a task list in the target scheduling interval. The target scheduling interval can be determined more accurately based on the execution time, and further scheduling of target tasks can be achieved more flexibly and accurately.
The following specifically explains a specific calculation process for determining a target scheduling interval in the task scheduling method provided in the embodiment of the present application.
Fig. 4 is another flow chart of a task scheduling method provided in an embodiment of the present application, referring to fig. 4, determining a target scheduling interval based on an execution time of a target task in a waiting queue includes:
s410: and calculating the pointer offset and/or the pointer step number according to the execution time of the target task in the waiting queue.
It should be noted that, the duration to be executed may be determined based on the current time and the execution time of the target task in the waiting queue, and further, the corresponding pointer offset may be determined according to the duration to be executed, where the pointer offset specifically refers to an angle offset from the current time to the execution time of the target task, and the angle may be calculated in an accumulated manner, for example: if offset by one turn, 360 degrees; if the offset is two turns, the offset is 720 degrees, etc.
After determining the pointer offset, the number of pointer steps may be determined based on the pointer offset, for example: if each step is 10 degrees, the offset of 360 degrees corresponds to 36 steps, and the like, so that the pointer step number can be determined.
S420: the target scheduling interval is determined based on the pointer offset and/or the number of pointer steps.
Optionally, after determining the needle offset and the number of pointer steps, the target scheduling interval may be determined based on both.
When calculating the target scheduling interval, any one of the pointer offset and the pointer step number can be selected to be used for calculation, and the other one is used for verification, so that a more accurate result is obtained, and the specific process of determining the target scheduling interval based on the pointer offset and the pointer step number is explained below respectively:
(1) Adopting pointer offset;
the pointer offset may specifically be an offset angle, and may be divided based on the pointer offset and the offset period (i.e., 360 degrees of one revolution).
The integer part is the period of the pointer rotation, the remainder part is the offset angle in the period, and the corresponding target scheduling interval can be determined.
For example, if the pointer offset is 530 degrees, the period of the pointer rotation is the 2 nd period (i.e. 1 complete period has already been performed), and the offset angle in the period is 170 degrees, so as to determine the target scheduling interval according to the number of scheduling intervals of the scheduling time wheel and the angle range occupied by each scheduling interval.
(2) Adopting the pointer step number;
the number of pointer steps may be specifically the number of pointer steps, and may be divided based on the number of pointer steps and the step number period (i.e., the number of steps required to make one turn, for example, 36 steps).
The integer part is the period of the pointer rotation, the remainder part is the step number in the period, and the corresponding target scheduling interval can be determined.
Taking 36 steps of the pointer in one period as an example, if the number of steps of the pointer is 80 steps, the period of rotation of the pointer is the 3 rd period (i.e. 2 complete periods have already been performed), the number of steps in the period is 8 steps, and then the target scheduling interval is determined according to the number of scheduling intervals of the scheduling time wheel and the number of steps required for reaching each scheduling interval in the period.
After the target scheduling interval is determined based on the above manner, the target task may be pushed into the target scheduling interval.
In the task scheduling method provided by the embodiment of the application, the pointer offset and/or the pointer step number can be calculated according to the execution time of the target task in the waiting queue; the target scheduling interval is determined based on the pointer offset and/or the number of pointer steps. The method can more accurately and rapidly determine the target scheduling interval by calculating the pointer offset and the pointer step number, and further can improve the efficiency of task scheduling.
The scheduled time wheel provided in the embodiment of the present application is specifically explained below.
Fig. 5 is a display diagram of a scheduling time wheel in the task scheduling method provided in the embodiment of the present application, referring to fig. 5, the scheduling time wheel includes: pointer 510 and closed ring area 520, wherein the closed ring area is divided into a plurality of sub-areas, each sub-area (area 1-area N in fig. 5) is a scheduling interval, in each scheduling interval, a task list can be extended, that is, a cell extended by each sub-area in fig. 5, only the task list in area 1 is shown in fig. 5, in an actual structure, each area may have a corresponding task list, each task list may push a target task, and when a task list pushes a plurality of target tasks, the task periods of the target tasks may be different.
In implementing task scheduling, the pointer 510 may start from an initial position in a preset clockwise direction, for example: clockwise, anticlockwise, etc., each step points to a sub-region, and when pointing to the sub-region, the target task in the cycle can be submitted from the task list in the scheduling interval to the thread pool.
In the cell in which each task list is represented, attribute information of a target task in the task list may be stored, for example: the execution period, task target, corresponding executor identifier, etc. are not particularly limited herein, and corresponding attribute information may be set according to actual requirements.
Pushing the target task from the wait queue into the task list of the scheduled time wheel and submitting the target task in the task list to the thread pool may be implemented based on the above-described structure.
The implementation of the task submission to the thread pool in the embodiments of the present application is explained below based on the specific structure of the scheduled time wheel explained in fig. 5.
Fig. 6 is another flow chart of a task scheduling method provided in the embodiment of the present application, referring to fig. 6, a task scheduling time wheel sequentially submits target tasks in a task list in each scheduling interval to a thread pool for scheduling, where the task scheduling method includes:
s610: and starting from the initial position through a pointer of the scheduling time wheel, stepping according to a preset clockwise direction, and determining whether a target task needing to be scheduled in the current period exists in a task list in the target scheduling interval when the pointer is stepped to the target scheduling interval.
Optionally, in conjunction with fig. 5 and fig. 6, it may be obtained that, during the working process of the scheduling time wheel, the corresponding scheduling interval may be determined by rotation of the pointer, so as to find a corresponding target task from the task list in the corresponding scheduling interval, and then submit the target task to the thread pool.
When the pointer of the scheduling time wheel points to the corresponding scheduling interval, whether a target task needing to be scheduled in the current period exists in the task list in the scheduling interval can be determined, and the process can be specifically determined by the execution period in the attribute information of the target task.
When the scheduling interval corresponding to the target task is determined in the foregoing calculation process, the remainder portion obtained by division calculation corresponds to the scheduling interval, and the integer portion corresponds to the execution period thereof.
S620: if yes, submitting the target task to the thread pool for scheduling.
Optionally, the scheduling time wheel is in a continuous working state, after determining that a target task to be scheduled in the current period exists, the target task can be submitted to the thread pool for scheduling, and then the pointer points to the next scheduling interval to execute the same judgment as time goes by, and then determining whether to submit the target task in the next scheduling interval to the thread pool for scheduling.
In the task scheduling method provided by the embodiment of the application, the pointer of the scheduling time wheel can be used for starting from the initial position and stepping according to the preset clockwise direction, and when the pointer is stepped to the target scheduling interval, whether the target task needing to be scheduled in the current period exists in the task list in the target scheduling interval is determined; if yes, submitting the target task to the thread pool for scheduling. The scheduling time wheel is based on the fact that each target task can be submitted to threads to be scheduled and distributed more flexibly and systematically, so that different tasks can be issued to different execution clients more flexibly, and the execution efficiency of the tasks and the reliability of the whole task scheduling system are improved.
The following specifically explains a specific implementation process of determining whether a target task to be scheduled in the present period exists in the task scheduling method provided in the embodiment of the present application.
Fig. 7 is another flow chart of the task scheduling method provided in the embodiment of the present application, referring to fig. 7, determining whether a target task to be scheduled in the current period exists in a task list in a target scheduling interval includes:
s710: and determining the execution period of each task in the task list of the target scheduling interval.
Optionally, each task in the task list has corresponding attribute information, and based on the attribute information, an execution period of each task may be determined, where the execution period may specifically be one attribute information calculated in a process of pushing the target task into the task list.
For example, taking the push target task as an example, taking the pointer going 36 steps in one period as an example, if the number of pointer steps is 80 steps, 80/36=2bi8 is calculated by division, that is, the period of the pointer rotation is the 3 rd period (that is, 2 complete periods have already been performed), so the execution period of the target task is the 3 rd period.
Based on the above manner, the execution period of each target task in the task list can be determined.
S720: if the execution cycle of the task is smaller than or equal to the stepping cycle number of the pointer, the task is used as a target task to be scheduled in the cycle.
Wherein the number of step cycles of the pointer is used to indicate the number of steps the pointer has stepped from the initial position to the current position.
Alternatively, after determining the execution period of each task, a determination may be made as to whether there is a task execution period that is less than or equal to the number of step periods of the pointer.
For the stepping cycle number of the pointer, if the pointer just starts to rotate, the cycle is 1, and after the pointer rotates 360 degrees, the cycle is 2; when the pointer rotates through 720 degrees, the period is 3, and the stepping period number of the pointer can be determined according to the stepping number of the pointer from the initial position to the current position.
For example, if the execution cycle of the task is 2 and the stepping cycle number of the pointer is 3, the task may be used as a target task to be scheduled in the present cycle; if the execution period of the task is 3 and the stepping period number of the pointer is 3, the task can be used as a target task to be scheduled in the period; if the execution cycle of the task is 4 and the stepping cycle number of the pointer is 3, the task cannot be used as a target task to be scheduled in the current cycle.
In the task scheduling method provided by the embodiment of the application, the execution period of each task in the task list of the target scheduling interval can be determined; if the execution cycle of the task is smaller than or equal to the stepping cycle number of the pointer, the task is used as a target task to be scheduled in the cycle. The target task to be scheduled in the period can be more accurately scheduled through the period judgment, so that the conditions of missed call, repeated call and the like are avoided, and the reliability of the whole task scheduling system is improved.
Another implementation procedure in the task scheduling method provided in the embodiment of the present application is specifically explained below.
Fig. 8 is another flow chart of a task scheduling method provided in the embodiment of the present application, referring to fig. 8, when a pointer of a scheduling time wheel is stepped to a next interval of a target scheduling interval, the method further includes:
s810: and determining the time of the next round according to the period duration of the scheduling time round.
Wherein the next round of time represents the time required for the pointer of the scheduled time round to step again to the target scheduling interval.
The period of the schedule time wheel specifically refers to the time required for the pointer in the schedule time wheel to rotate 360 degrees from the initial position back to the initial position.
If the time lengths of the execution scheduling of each scheduling interval are equal, the cycle time length of the scheduling time wheel can be calculated based on the following modes:
the cycle duration of the schedule time wheel = the number of schedule intervals x the duration of execution of the schedule intervals;
for example: if the number of the scheduling intervals in the scheduling time wheel is N, the time length of each scheduling interval for executing scheduling is H, and the period time length of the scheduling time wheel is determined to be N multiplied by H.
The calculation may be performed when the pointer of the scheduling time wheel is stepped to a next section of the target scheduling section, and the next round time may be calculated based on the calculation result and the current time.
S820: and dormancy is carried out on the threads of the task queues in the target scheduling interval until the next round of time.
Alternatively, when task scheduling is performed, each task queue may include a thread, and the target task may be submitted to the thread pool through each thread.
After the pointer of the scheduling time wheel is stepped to the next interval of the target scheduling interval, the corresponding task scheduling is not needed in the target scheduling interval, so that the thread of the task queue in the target scheduling interval can be dormant until the next round of time is reached.
In the task scheduling method provided by the embodiment of the application, the time of the next round can be determined according to the period duration of the scheduling time round; and dormancy is carried out on the threads of the task queues in the target scheduling interval until the next round of time. The thread dormancy method can save the calculation power of the whole task scheduling system by dormancy, and can enable the thread in the dormancy state to work normally more accurately by calculation of the next time, so that the stability and reliability of the whole system are ensured.
A further possible implementation manner of the task scheduling method provided in the embodiment of the present application is specifically explained below.
Fig. 9 is another flow chart of a task scheduling method provided in an embodiment of the present application, referring to fig. 9, the method further includes:
s910: and determining the execution position of the canceling task based on the task list position of the target task which is required to be canceled by the canceling task in the canceling queue.
Optionally, the cancellation queue is similar to the waiting queue, and is a queue capable of pushing tasks to the task scheduling queue, where the cancellation queue stores cancellation tasks, and the cancellation tasks may be specifically tasks for deleting target tasks.
The canceling task may include a target object that is to be executed correspondingly, and the target object is a target task that needs to be deleted, and the execution position of the canceling task may be determined based on the task list position where the target task is located.
For example: if the target task is in the task list in the second scheduling interval, the task list in the second scheduling interval is the execution position of the cancellation task.
S920: pushing the canceling task into a task scheduling queue, and deleting the target task in the execution position of the canceling task.
Optionally, after determining the execution position of the cancellation task, the cancellation task may be pushed into the task scheduling queue, and the task scheduling queue deletes the corresponding target task from the execution position of the cancellation task, where it needs to be noted that, when deleting the task, the identifier of the deleted target task may be determined, and then deleting the target task based on the identifier, so as to avoid deleting other tasks in the same task list by mistake.
In the task scheduling method provided in the embodiment of the present application, the execution position of the canceling task may be determined based on the task list position where the target task to be canceled is located, where the canceling task is required to be canceled, in the canceling queue; pushing the canceling task into a task scheduling queue, and deleting the target task in the execution position of the canceling task. The target task can be deleted by setting the cancel queue, so that the flexibility of the whole task scheduling system is further improved.
The following specifically explains a specific implementation case of task scheduling in an application scenario provided in the embodiments of the present application.
Fig. 10 is a schematic diagram of an overall architecture based on scheduling between a server and a client, which is provided in an embodiment of the present application, referring to fig. 10, after monitoring and arranging tasks and load balancing processing of a reverse proxy cluster on a server side, each target task may be input into a waiting queue, and then each target task is issued to a cluster of an executing client based on the waiting queue, a scheduling time wheel and a thread pool, and each executing client executes a corresponding task, for example: timed tasks, fixed frequency execution tasks, scheduled tasks, etc.
In addition, in the task scheduling process, the task can be grabbed.
The following specifically explains the implementation procedure of task scheduling execution provided in the embodiment of the present application.
Fig. 11 is a schematic flow chart of task scheduling execution provided in the embodiment of the present application, and referring to fig. 11, the process may be specifically implemented by a task scheduler in a server, and specifically may implement preparation work for scheduling by performing data exchange with a work database.
The following operations may be performed in sequence: receiving inquiry task information issued by a working database, and inquiring a task which needs to be executed recently; generating an execution record, writing the execution record into a working database, and writing the execution record into the working database; pushing the tasks in the waiting queue into a scheduling time wheel, and triggering the tasks to the point; and calculating the next scheduling time, synchronizing to the working database, and updating task information to the working database.
In the task query process, task information which can be registered in the query system comprises information such as a type, parameters, scheduling rules and the like of a defined task, and the task which needs to be executed recently is filtered out.
In the process of generating the execution record, the task can be decided to be distributed to which nodes to execute according to the scheduling rule and configuration of the task. The task scheduling system selects the most suitable node to execute the task by considering factors such as the load condition of the node, the network condition and the like. An execution record is generated for the task to be executed, including parameters of the task, execution time, etc.
In the task issuing process, the tasks can be distributed to task executors on the selected nodes according to the generated execution records and task information. When distributing the task, the task scheduling system can transmit relevant information of the task to a task executor, including parameters, execution time and the like of the task.
In the process of updating the task, after the task is executed, the task scheduling system calculates the next scheduling time and updates the execution state of the task, and returns the execution result to the task initiator, and the task initiator can inquire the execution result of the task through the task scheduling system.
When the server executes the scheduling work, the task can be distributed to a plurality of nodes in the cluster for execution, and the parallel processing and load balancing of the task are realized. It uses a distributed scheduling algorithm to determine on which node a task is executed to achieve efficient scheduling and execution of the task. During execution, task execution nodes can be dynamically increased or decreased, and the scale of the cluster can be automatically adjusted according to actual load conditions. The size of the cluster can be adjusted through configuration according to the number and the complexity of the tasks so as to meet the requirements of task execution. When the task is executed, the execution condition of the task can be monitored, and when the task fails to execute, automatic retry is performed. By storing the pre-scheduling log, the reliability and stability of the task are ensured. And, support multiple task scheduling strategies, including fixed time interval, expression of the planning task list, etc., can dispose scheduling time and frequency of task flexibly according to characteristic and demand of task. And a management page can be set, so that the execution condition of the task, the task scheduling strategy configuration and the like can be conveniently checked and managed. Through the visual interface, the user can intuitively know the state and the execution condition of the task, and management and monitoring are convenient.
Correspondingly, when the client executes the task, the client is responsible for receiving the task distributed by the task scheduling system and executing the task on the designated node. It is capable of executing different task logic including computation, data processing, file manipulation, etc., depending on the type and configuration of the task. And the task is distributed to a plurality of nodes in the cluster to be executed, so that the parallel processing of the task is realized. It uses a distributed scheduling algorithm to determine on which node a task is executed to achieve efficient scheduling and execution of the task. The executor in the client has a fault tolerance mechanism and can monitor the execution condition of the task. Once the task fails to execute, it will automatically retry to ensure the reliability and stability of the task. The executor can update the execution state of the task in real time, including the states of start, running, success, failure and the like of the task. Through task state management, a user can conveniently know the execution condition and the result of the task. The executor records the execution log of the task, including the input, output, execution time and other information of the task. The logs can be used for fault detection, performance analysis, task monitoring and the like. The executor has good expansibility, and can be customized and expanded according to actual requirements. The user may customize the logic and behavior of the task executor to meet specific business needs.
When the task scheduling system is used for executing task scheduling work, the task can be distributed to the most suitable node for execution according to the type, parameters, scheduling rules and other information of the task through the intelligent scheduling algorithm of the task scheduling system, so that the possibility of manual intervention and misoperation is reduced. The concurrent execution of tasks can be realized, and the processing capacity of the system is improved. By distributing the tasks to task executors on a plurality of nodes for parallel execution, the system resources can be fully utilized, the task processing speed is increased, and the response capability of the system is improved. The system has the functions of task monitoring and management. The task scheduling system can monitor the execution condition of the task in real time, record the execution log and the state of the task, and facilitate the tracking and the investigation of the task by a developer. Meanwhile, the task scheduling system also supports operations such as retry of the task and the like, and ensures reliable execution of the task. Flexible task configuration and expansion capabilities are provided. The execution logic of the task can be flexibly configured according to the type, parameters and scheduling rules of the user-defined task in actual demands.
It should be understood that, although the steps in the flowcharts described above are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described above may include a plurality of sub-steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of execution of the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with at least a part of the sub-steps or stages of other steps or other steps.
Based on the foregoing embodiments, the embodiments of the present application provide a task scheduling device, where the task scheduling device includes each module included, and each unit included in each module may be implemented by a processor; of course, the method can also be realized by a specific logic circuit; in an implementation, the processor may be a Central Processing Unit (CPU), a Microprocessor (MPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), or the like.
Fig. 12 is a schematic structural diagram of a task scheduling device provided in an embodiment of the present application, and referring to fig. 12, the task scheduling device provided in an embodiment of the present application is applied to a server, where the device includes: a push module 210, a dispatch module 220, and a send-out module 230;
the pushing module 210 is configured to push a target task into a task list in a task scheduling queue based on execution time of the target task in the waiting queue, where the waiting queue includes a target task to be scheduled, and the task scheduling queue includes a scheduling time wheel, where the scheduling time wheel is divided into a plurality of scheduling intervals in a closed loop, and each scheduling interval includes a task list;
the scheduling module 220 is configured to sequentially submit target tasks in the task list in each scheduling interval to the thread pool for scheduling through a scheduling time wheel;
The issuing module 230 is configured to send the target task to an execution client corresponding to the target task based on the thread pool.
In some embodiments, the pushing module 210 is specifically configured to determine a target scheduling interval based on an execution time of the target task in the waiting queue, where the target scheduling interval is one of a plurality of scheduling intervals; pushing the target task into a task list in the target scheduling interval.
In some embodiments, the pushing module 210 is further configured to calculate a pointer offset and/or a pointer step number according to an execution time of the target task in the waiting queue; the target scheduling interval is determined based on the pointer offset and/or the number of pointer steps.
In some embodiments, the scheduling module 220 is specifically configured to, starting from an initial position through a pointer of a scheduling time wheel, step in a preset clockwise direction, and determine whether a target task to be scheduled in the current period exists in a task list in a target scheduling interval when the pointer steps to the target scheduling interval; if yes, submitting the target task to the thread pool for scheduling.
In some embodiments, the scheduling module 220 is specifically configured to determine an execution period of each task in the task list of the target scheduling interval; if the execution cycle of the task is smaller than or equal to the stepping cycle number of the pointer, the task is used as a target task to be scheduled in the current cycle, and the stepping cycle number of the pointer is used for indicating the stepping cycle number of the pointer from the initial position to the current position.
In some embodiments, the scheduling module 220 is further configured to determine a next round of time according to the period duration of the scheduled time round, where the next round of time represents a time required for the pointer of the scheduled time round to step to the target scheduling interval again; and dormancy is carried out on the threads of the task queues in the target scheduling interval until the next round of time.
In some embodiments, the pushing module 210 is further configured to determine an execution position of the cancellation task based on a task list position where a target task that is required to be cancelled by the cancellation task in the cancellation queue is located; pushing the canceling task into a task scheduling queue, and deleting the target task in the execution position of the canceling task.
The description of the apparatus embodiments above is similar to that of the method embodiments above, with similar advantageous effects as the method embodiments. For technical details not disclosed in the device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.
It should be noted that, in the embodiment of the present application, the division of the modules by the task scheduling device shown in fig. 12 is schematic, and is merely a logic function division, and there may be another division manner in actual implementation. In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units. Or in a combination of software and hardware.
It should be noted that, in the embodiment of the present application, if the method is implemented in the form of a software functional module, and sold or used as a separate product, the method may also be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially or part contributing to the related art, and the computer software product may be stored in a storage medium, including several instructions for causing an electronic device to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read Only Memory (ROM), a magnetic disk, an optical disk, or other various media capable of storing program codes. Thus, embodiments of the present application are not limited to any specific combination of hardware and software.
Fig. 13 is a schematic structural diagram of a computer device provided in an embodiment of the present application, and referring to fig. 13, an embodiment of the present application provides a computer device, which may be the server, and an internal structure diagram of the computer device may be shown in fig. 13. The computer device includes a processor 320, memory, and a network interface 340 connected by a system bus 310. Wherein the processor 320 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium 331, an internal memory 332. The nonvolatile storage medium 331 stores an operating system, computer programs, and databases. The internal memory 332 provides an environment for the operation of the operating system and computer programs in the nonvolatile storage medium 331. The database of the computer device is for storing data. The network interface 340 of the computer device is for communicating with an external terminal through a network connection. Which when executed by the processor 320, performs the above-described methods.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method provided in the above embodiments.
The present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the steps of the method provided by the method embodiments described above.
It will be appreciated by those skilled in the art that the structure shown in fig. 13 is merely a block diagram of a portion of the structure associated with the present application and is not limiting of the computer device to which the present application applies, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, the task scheduler provided herein may be implemented in the form of a computer program that is executable on a computer device as shown in fig. 13. The memory of the computer device may store the various program modules that make up the apparatus. The computer program of each program module causes a processor to perform the steps in the methods of each embodiment of the present application described in the present specification.
It should be noted here that: the description of the storage medium and apparatus embodiments above is similar to that of the method embodiments described above, with similar benefits as the method embodiments. For technical details not disclosed in the storage medium, storage medium and device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" or "some embodiments" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" or "in some embodiments" in various places throughout this specification are not necessarily referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in various embodiments of the present application, the sequence numbers of the foregoing processes do not mean the order of execution, and the order of execution of the processes should be determined by the functions and internal logic thereof, and should not constitute any limitation on the implementation process of the embodiments of the present application. The foregoing embodiment numbers of the present application are merely for describing, and do not represent advantages or disadvantages of the embodiments. The foregoing description of various embodiments is intended to highlight differences between the various embodiments, which may be the same or similar to each other by reference, and is not repeated herein for the sake of brevity.
The term "and/or" is herein merely an association relation describing associated objects, meaning that there may be three relations, e.g. object a and/or object B, may represent: there are three cases where object a alone exists, object a and object B together, and object B alone exists.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments are merely illustrative, and the division of the modules is merely a logical function division, and other divisions may be implemented in practice, such as: multiple modules or components may be combined, or may be integrated into another system, or some features may be omitted, or not performed. In addition, the various components shown or discussed may be coupled or directly coupled or communicatively coupled to each other via some interface, whether indirectly coupled or communicatively coupled to devices or modules, whether electrically, mechanically, or otherwise.
The modules described above as separate components may or may not be physically separate, and components shown as modules may or may not be physical modules; can be located in one place or distributed to a plurality of network units; some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in each embodiment of the present application may be integrated in one processing unit, or each module may be separately used as one unit, or two or more modules may be integrated in one unit; the integrated modules may be implemented in hardware or in hardware plus software functional units.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by hardware related to program instructions, and the foregoing program may be stored in a computer readable storage medium, where the program, when executed, performs steps including the above method embodiments; and the aforementioned storage medium includes: a mobile storage device, a Read Only Memory (ROM), a magnetic disk or an optical disk, or the like, which can store program codes.
Alternatively, the integrated units described above may be stored in a computer readable storage medium if implemented in the form of software functional modules and sold or used as a stand-alone product. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially or part contributing to the related art, and the computer software product may be stored in a storage medium, including several instructions for causing an electronic device to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a removable storage device, a ROM, a magnetic disk, or an optical disk.
The methods disclosed in the several method embodiments provided in the present application may be arbitrarily combined without collision to obtain a new method embodiment.
The features disclosed in the several product embodiments provided in the present application may be combined arbitrarily without conflict to obtain new product embodiments.
The features disclosed in the several method or apparatus embodiments provided in the present application may be arbitrarily combined without conflict to obtain new method embodiments or apparatus embodiments.
The foregoing is merely an embodiment 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 about changes or substitutions within the technical scope of the present application, and the changes and substitutions are intended to be covered in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for task scheduling, applied to a server, the method comprising:
pushing a target task into a task list in a task scheduling queue based on the execution time of the target task in the waiting queue, wherein the waiting queue comprises target tasks to be scheduled, the task scheduling queue comprises a scheduling time wheel, the scheduling time wheel is divided into a plurality of scheduling intervals in a closed loop mode, and the task list is included in each scheduling interval;
submitting target tasks in the task list in each scheduling interval to a thread pool for scheduling according to the sequence through the scheduling time wheel;
and sending the target task to an execution client corresponding to the target task based on the thread pool.
2. The task scheduling method according to claim 1, wherein pushing the target task into the task list in the task scheduling queue based on the execution time of the target task in the waiting queue includes:
Determining a target scheduling interval based on the execution time of a target task in a waiting queue, wherein the target scheduling interval is one of a plurality of scheduling intervals;
pushing the target task into a task list in the target scheduling interval.
3. The task scheduling method according to claim 2, wherein the determining the target scheduling interval based on the execution time of the target task in the waiting queue includes:
calculating pointer offset and/or pointer step number according to the execution time of the target task in the waiting queue;
and determining a target scheduling interval based on the pointer offset and/or the pointer step number.
4. The task scheduling method according to claim 1, wherein the sequentially submitting the target tasks in the task list in each scheduling interval to the thread pool for scheduling through the scheduling time wheel includes:
starting from an initial position through a pointer of the scheduling time wheel, stepping according to a preset clockwise direction, and determining whether a target task needing to be scheduled in the current period exists in a task list in a target scheduling interval when the pointer is stepped to the target scheduling interval;
if yes, submitting the target task to the thread pool for scheduling.
5. The task scheduling method according to claim 4, wherein the determining whether there is a target task to be scheduled in the current period in the task list in the target scheduling interval includes:
determining the execution period of each task in a task list of the target scheduling interval;
and if the execution cycle of the task is smaller than or equal to the stepping cycle number of the pointer, taking the task as a target task to be scheduled in the cycle, wherein the stepping cycle number of the pointer is used for indicating the stepping cycle number of the pointer from the initial position to the current position.
6. The task scheduling method of claim 4, wherein when the pointer of the scheduling time wheel is stepped to a next interval of the target scheduling interval, the method further comprises:
determining the next round of time according to the period duration of the scheduling time wheel, wherein the next round of time represents the time required by the pointer of the scheduling time wheel to step to the target scheduling interval again;
and dormancy is carried out on the threads of the task queues in the target scheduling interval until the next round of time.
7. The task scheduling method according to claim 1, characterized in that the method further comprises:
Determining the execution position of a canceling task based on the task list position of a target task which is required to cancel the canceling task in a canceling queue;
pushing the canceling task into a task scheduling queue, and deleting the target task in the execution position of the canceling task.
8. A task scheduling device, applied to a server, comprising: the device comprises a pushing module, a scheduling module and a issuing module;
the pushing module is used for pushing the target task into a task list in a task scheduling queue based on the execution time of the target task in the waiting queue, the waiting queue comprises the target task to be scheduled, the task scheduling queue comprises a scheduling time wheel, the scheduling time wheel is divided into a plurality of scheduling intervals in a closed loop mode, and the task list is included in each scheduling interval;
the scheduling module is used for sequentially submitting target tasks in the task list in each scheduling interval to a thread pool for scheduling through the scheduling time wheel in sequence;
and the issuing module is used for sending the target task to an execution client corresponding to the target task based on the thread pool.
9. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that the processor implements the steps of the method of any of claims 1 to 7 when the program is executed.
10. A computer readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the method according to any one of claims 1 to 7.
CN202311643410.3A 2023-12-01 2023-12-01 Task scheduling method and device, equipment and storage medium Pending CN117573325A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311643410.3A CN117573325A (en) 2023-12-01 2023-12-01 Task scheduling method and device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311643410.3A CN117573325A (en) 2023-12-01 2023-12-01 Task scheduling method and device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117573325A true CN117573325A (en) 2024-02-20

Family

ID=89888038

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311643410.3A Pending CN117573325A (en) 2023-12-01 2023-12-01 Task scheduling method and device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117573325A (en)

Similar Documents

Publication Publication Date Title
JP5011028B2 (en) Storage system, management apparatus, scheduling method, program, recording medium
US10459915B2 (en) Managing queries
CN110032438B (en) Delayed task execution method and device and electronic equipment
CN110554909A (en) task scheduling processing method and device and computer equipment
CN114416308A (en) Task scheduling method and device, computer equipment and storage medium
CN112099800B (en) Code data processing method, device and server
CN110502545B (en) Data storage method, device, equipment and computer readable storage medium
JP2015191523A (en) Configuration management apparatus, configuration management system, and configuration management program
WO2007038445A2 (en) Clustered computer system
CN111813517B (en) Task queue allocation method and device, computer equipment and medium
CN112470126A (en) Enhanced performance of function as a service
CN114416324A (en) Task triggering method and device, computer equipment and storage medium
CN106874079A (en) A kind of method and device of tasks carrying
CN110609967B (en) List generation method and device and storage medium
CN111026524A (en) Method and device for processing delay task, computer equipment and storage medium
CN117573325A (en) Task scheduling method and device, equipment and storage medium
CN113986642A (en) Task monitoring system, method and device, electronic equipment and storage medium
CN116302455A (en) Timing task processing method and device, storage medium and computer equipment
CN115002187B (en) Binding relation processing method and related equipment
CN115098232A (en) Task scheduling method, device and equipment
CN114692585A (en) Table service processing method and system
CN110674214B (en) Big data synchronization method, device, computer equipment and storage medium
CN110532108A (en) Processing method, device, server and the system of resume delivery task
CN108959501B (en) Method and device for deleting ES index
CN110865877A (en) Task request response method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination