CN109992390B - Timed task scheduling method and timed task processing method - Google Patents

Timed task scheduling method and timed task processing method Download PDF

Info

Publication number
CN109992390B
CN109992390B CN201910326565.1A CN201910326565A CN109992390B CN 109992390 B CN109992390 B CN 109992390B CN 201910326565 A CN201910326565 A CN 201910326565A CN 109992390 B CN109992390 B CN 109992390B
Authority
CN
China
Prior art keywords
task
timing task
target timing
metadata
target
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.)
Active
Application number
CN201910326565.1A
Other languages
Chinese (zh)
Other versions
CN109992390A (en
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.)
Guangzhou Yurui Information Technology Co ltd
Original Assignee
Guangzhou Yurui Information Technology 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 Guangzhou Yurui Information Technology Co ltd filed Critical Guangzhou Yurui Information Technology Co ltd
Priority to CN201910326565.1A priority Critical patent/CN109992390B/en
Publication of CN109992390A publication Critical patent/CN109992390A/en
Application granted granted Critical
Publication of CN109992390B publication Critical patent/CN109992390B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • 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
    • G06F9/4887Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues involving deadlines, e.g. rate based, periodic
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/482Application

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a scheduling method and device of a timing task. The method comprises the following steps: acquiring the running period of each timing task in the database, and determining a target timing task from each timing task according to the running period; comparing the estimated running time of the target timing task with a preset time index value, and judging whether the target timing task is dependent on locking; when the estimated running time of the target timing task is smaller than a preset time index value and no dependent locking exists, determining the running mode of the target timing task; and sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode, wherein the metadata of the target timing task is used for indicating the scheduling end to call an execution server to execute the target timing task according to the metadata. By adopting the method, the scheduling and execution of the timing task can be decoupled, and the performance bottleneck of a service system is avoided.

Description

Timed task scheduling method and timed task processing method
Technical Field
The present application relates to the field of computer data processing technologies, and in particular, to a method and an apparatus for scheduling a timing task, and a method and an apparatus for processing a timing task.
Background
In the enterprise of the internet, related operations with regularity are executed in each WEB application system, and the operations with regularity and periodicity are defined as timed tasks in the industry. In the web application system of an enterprise, with the continuous increase of application services, the number of timing tasks is also increased, and the complexity is also increased; the traditional timing tasks are independently operated at different hosts, along with the increase of the amount of the timing tasks, resources required for operating the timing tasks are correspondingly increased, a performance bottleneck can be caused by the certain amount of the tasks, the amount of the tasks is accumulated, and the execution accuracy and the frequency of the timing tasks are caused to be in failure.
Disclosure of Invention
In view of the foregoing, it is necessary to provide a method and an apparatus for scheduling a timed task, and a method and an apparatus for processing a timed task.
A timing task scheduling method comprises the following steps:
reading the operation period of each timing task in a database, and determining a target timing task from each timing task according to the operation period;
comparing the estimated running time of the target timing task with a preset time index value, and judging whether the target timing task is dependent on locking;
when the estimated running time of the target timing task is smaller than the preset time index value and no dependency locking exists, determining the running mode of the target timing task;
sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode; and the metadata of the target timing task is used for indicating the scheduling end to call an execution server to execute the target timing task according to the metadata.
In one embodiment, the step of determining whether there is a dependent lock on the target timed task includes:
reading metadata of the target timing task, and determining a first task identifier and a dependency state of a dependent task of the target timing task from the metadata;
reading the running state of the timing task corresponding to the first task identifier;
and if the running state is not matched with the dependency state, judging that the target timing task has dependency locking.
In one embodiment, the step of sending the metadata of the target timed task to a task queue of a scheduling end corresponding to an operation mode includes:
acquiring a second task identifier of the target timing task;
performing hash operation on the second task identifier to obtain a hash value of the second task identifier;
and determining a target scheduling end from scheduling ends corresponding to the running mode of the target timing task according to the hash value, and sending the metadata of the target task to a task queue of the target scheduling end.
A timed task scheduling apparatus, said apparatus comprising:
the method comprises the steps that a main control end reads the operation period of each timing task in a database, and a target timing task is determined from each timing task according to the operation period;
the main control end compares the estimated running time of the target timing task with a preset time index value, and judges whether the target timing task is dependent on locking;
when the estimated running time of the target timing task is smaller than the preset time index value and is not dependent on locking, the main control end determines the running mode of the target timing task;
the main control end sends the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode;
and the scheduling end queries a task queue, and when the metadata of the target timing task is queried from the task queue, the scheduling end calls an execution server to execute the target timing task according to the metadata.
The timing task scheduling method and the device determine the current target timing task by reading the running period of each timing task in the database, when the estimated running time of the target timing task is smaller than the preset time index value and no dependent locking exists, sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode of the target timing task, the timing task is dispatched to different dispatching ends, the dispatching end calls an execution server to execute the target timing task, the dispatching of the timing task and the execution of the timing task are decoupled by utilizing a task queue, the processing work of the timing task among multiple servers and multiple systems is realized, the processing of the timing task is not influenced by the performance of the single machine, and the generation of performance bottleneck and the reduction of the execution accuracy and the frequency of the timing task are effectively avoided.
A method of timed task processing, the method comprising:
inquiring a task queue;
when the metadata of the target timing task is inquired from the task queue, an execution server is called to execute the target timing task according to the metadata; the estimated running time of the target timing task is smaller than a preset time index value and is not dependent on locking; and the metadata of the target timing task is sent to the task queue by the main control end according to the running mode of the target timing task.
In one embodiment, the mode of operation includes a native run code type;
the step of calling an execution server to execute the target timing task according to the metadata comprises the following steps:
determining a first execution server from the metadata, and pulling a program code corresponding to the target timing task from the main control end;
sending the program code to the first execution server, the program code for instructing the first execution server to run the program code;
and receiving result data returned by the first execution server.
In one embodiment, the operation mode comprises a calling interface operation type;
the step of calling an execution server to execute the target timing task according to the metadata comprises the following steps:
determining a second execution server from the metadata, and triggering a calling interface of the second execution server;
and receiving result data returned by the second execution server through the calling interface.
A timed task processing apparatus, the apparatus comprising:
the task queue query module is used for querying a task queue;
the timing task execution module is used for calling an execution server to execute the target timing task according to the metadata when the metadata of the target timing task is inquired from the task queue; the estimated running time of the target timing task is smaller than a preset time index value and is not dependent on locking; and the metadata of the target timing task is sent to the task queue by the main control end according to the running mode of the target timing task.
According to the timed task processing method and device, after the main control end sends the target timed task to the task queue corresponding to the running mode according to the running mode of the target timed task, the metadata of the target timed task in the task queue is inquired, the execution server is called according to the metadata to execute the target timed task, the timed task is dispatched to different dispatching ends, the dispatching end calls the execution server to execute the target timed task, the dispatching of the timed task and the execution of the timed task are decoupled by using the task queue, the processing work of the timed task among multiple servers and multiple systems is realized, the processing of the timed task is not affected by the performance of a single machine, and the generation of performance bottleneck and the reduction of the execution accuracy and the frequency of the timed task are effectively avoided.
A method for processing a timed task, the method comprising:
the method comprises the steps that a main control end reads the operation period of each timing task in a database, and a target timing task is determined from each timing task according to the operation period;
the main control end compares the estimated running time of the target timing task with a preset time index value, and judges whether the target timing task is dependent on locking;
when the estimated running time of the target timing task is smaller than the preset time index value and is not dependent on locking, the main control end determines the running mode of the target timing task;
the main control end sends the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode;
and the scheduling end queries a task queue, and when the metadata of the target timing task is queried from the task queue, the scheduling end calls an execution server to execute the target timing task according to the metadata.
In one embodiment, the mode of operation includes a native run code type;
the step of the scheduling terminal calling the execution server to execute the target timing task according to the metadata comprises the following steps:
the scheduling end determines a first execution server from the metadata and pulls a program code corresponding to the target timing task from the main control end;
the scheduling end sends the program code to the first execution server, and the program code is used for indicating the first execution server to run the program code;
and the scheduling end receives result data returned by the first execution server.
The timing task processing method determines the current target timing task by reading the running period of each timing task in the database, when the estimated running time of the target timing task is smaller than the preset time index value and no dependent locking exists, sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode of the target timing task, the timing task is dispatched to different dispatching ends, the dispatching end calls an execution server to execute the target timing task, the dispatching of the timing task and the execution of the timing task are decoupled by utilizing a task queue, the processing work of the timing task among multiple servers and multiple systems is realized, the processing of the timing task is not influenced by the performance of the single machine, and the generation of performance bottleneck and the reduction of the execution accuracy and the frequency of the timing task are effectively avoided.
Drawings
FIG. 1 is a diagram illustrating an exemplary implementation of a method for processing a timed task;
FIG. 2 is a flowchart illustrating a method for scheduling a timed task according to an embodiment;
FIG. 3 is a flow diagram illustrating a method for processing a timed task according to one embodiment;
FIG. 4 is a flowchart illustrating a method for processing a timed task according to another embodiment;
FIG. 5 is a block diagram of a device for scheduling timed tasks according to an embodiment;
FIG. 6 is a block diagram showing the structure of a timed task processing apparatus according to an embodiment;
FIG. 7 is a block diagram showing the construction of a timed task scheduler in another embodiment;
FIG. 8 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The timed task scheduling method or the timed task processing method provided by the application can be applied to the application environment shown in fig. 1. The main control end 110 communicates with a plurality of scheduling ends 120 through a network, the scheduling ends 120 communicate with a plurality of different execution servers 130 through the network, and the main control end 110, the scheduling ends 120 and the execution servers 130 form a distributed stateless cluster architecture system. The main control terminal 110 reads the operation cycle of each timing task in the database, determines the current target timing task, when the estimated running time of the target timing task is smaller than the preset time index value and no dependent locking exists, sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode of the target timing task, inquiring the task queue at every moment by the scheduling end, when the metadata of the target timing task is inquired from the task queue, the scheduling end calls the execution server 130 to execute the target timing task according to the metadata, so that the scheduling of the timing task and the execution of the timing task are decoupled by using the task queue, the processing work of the timing task among multiple servers and multiple systems is realized, the processing of the timing task is not affected by the performance of the single machine, and the generation of performance bottleneck and the reduction of the execution accuracy and frequency of the timing task are effectively avoided. The main control end 110, the dispatching end 120 and the execution server 130 can be implemented by independent servers or a server cluster composed of a plurality of servers.
In an embodiment, as shown in fig. 2, a method for scheduling a timed task is provided, which is described by taking the method as an example applied to the master control end in fig. 1, and includes the following steps:
step S210: and reading the running period of each timing task in the database, and determining a target timing task from each timing task according to the running period.
In this step, the main control end can start a concurrent process every minute, and the running period of each timing task in the database is read through the concurrent process, so that the target timing task which needs to run at the current moment is determined according to the running period of each timing task in the database;
specifically, the main control end may store the operation period of each timing task in the database in advance, where the definition mode of the operation period of the timing task may adopt an expression supporting Linux crossbar, so as to implement seamless migration of the timing task supported and deployed in the Linux crossbar.
Step S220: and comparing the estimated running time of the target timing task with a preset time index value, and judging whether the target timing task is dependent on locking.
In this step, the preset time length index value may include a maximum running time length of the timing task, which is set by the user, of the service system by default, and a time interval of a running period of the timing task; the dependency locking means that when the running state of other timing tasks having a dependency relationship with the target timing task is in running, the target timing task has dependency locking;
because the timing tasks are periodically operated, if a certain timing task is started in the previous period and is not operated, the timing task is executed again in the current period, the same timing task is overlapped and operated at different time points, so that the front and back congestion of the timing task is often caused, and the task accumulation pressure is generated on a service system; therefore, after the target timing task needing to be operated at the current moment is determined, the main control end obtains the estimated operation time of the target timing task from the metadata of the target timing task, and the estimated operation time is compared with the preset duration index value, so that the overlapping operation of the timing tasks is effectively avoided, and the accumulation of the task amount is avoided. Meanwhile, the main control end judges whether the target timing task is dependent on locking or not, so that some tasks with sequential execution can be mutually restricted, the design of relevance mutual exclusion between the timing task and the timing task is realized, and the problem of singleness of the timing task is effectively solved.
Step S230: and when the estimated running time of the target timing task is smaller than the preset time index value and no dependency locking exists, determining the running mode of the target timing task.
The timing task operation mode comprises two types, one is that the timing task is triggered to be executed by the WEB application through calling the WEB application interface, and the other is that the timing task is executed by executing the relevant program code on the server where the WEB application is located. When the estimated running time of the target timing task is smaller than a preset time index value and no dependent locking exists, the target timing task meets the running condition, and the main control end can read the metadata of the target timing task and determine the running mode of the target timing task; when the estimated running time of the target timing task is greater than the preset time index value or the target timing task is dependent on locking, the target timing task is considered to be not in accordance with the running condition, and the main control end discards the running of the target timing task.
Step S240: sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode; and the metadata of the target timing task is used for indicating the scheduling end to call the execution server to execute the target timing task according to the metadata.
The execution server is a server where WEB applications which actually complete the timing task function are located; corresponding to different operation modes, the scheduling end is also divided into two scheduling ends with different classifications; specifically, after the operation mode of the target timing task is determined, the main control end sends metadata of the target timing task to a task queue of a scheduling end corresponding to the operation mode, the scheduling end inquires the task queue in real time, and after the scheduling end inquires the metadata of the target timing task in the task queue, an execution server where the WEB application is located is called to execute the target timing task according to the metadata.
In the timing task scheduling method, the current target timing task is determined by reading the running period of each timing task in the database, when the estimated running time of the target timing task is smaller than the preset time index value and no dependent locking exists, sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode of the target timing task, the timing task is dispatched to different dispatching ends, the dispatching end calls an execution server to execute a target timing task, the dispatching of the timing task and the execution of the timing task are decoupled by utilizing a task queue, the processing work of the timing task among multiple servers and multiple systems is realized, the processing of the timing task is not influenced by the performance of a single machine, the generation of performance bottleneck and the reduction of the execution accuracy and frequency of the timing task are effectively avoided, and the expansion and contraction capacity of a scheduling end can be increased or reduced according to the performance requirement; meanwhile, the estimated running time of the target timing task is compared with the preset time index value, and whether the target timing task is dependent and locked or not is judged, so that the congestion problem before and after the running of the timing task is effectively solved, the design of running relevance mutual exclusion among different timing tasks can be realized, and the problem of singleness of the timing task is solved.
In one embodiment, the step of determining whether there is a dependent lock on the target timed task comprises: reading metadata of the target timing task, and determining a first task identifier and a dependency state of a dependent task of the target timing task from the metadata; reading the running state of the timing task corresponding to the first task identifier; and if the running state is not matched with the dependency state, judging that the target timing task has dependency locking.
The dependency locking means that when the running state of other timing tasks having a dependency relationship with the target timing task is not in the dependency state, the target timing task has dependency locking, for example, assuming that the timing task a has a dependency relationship with the timing task B, the timing task a needs to run in the running end state of the timing task B, that is, the dependent task of the timing task a is the timing task B, the dependency state is non-running, when the main control end determines the timing task a as the target timing task, the main control end obtains the identifier of the timing task B having a dependency relationship with the timing task a from the metadata of the timing task a and determines the last running state of the timing task B according to the identifier, if the last running state of the timing task B is non-running, the running state of the timing task B matches with the dependency state, determining that the timing task A is independent of locking; and if the last running state of the timing task B is running, the running state of the timing task B is not matched with the dependency state, and the timing task A is determined to have dependency locking. In this embodiment, the main control end determines a task identifier of a related timing task from metadata of a target timing task, obtains a latest running state of the timing task through the task identifier, and determines that the target timing task has dependency locking when the latest running state of the timing task is in running; by carrying out dependency judgment on the target timing task and the timing task having a dependency relationship with the target timing task, mutual restriction of the timing tasks with sequential execution is realized, the design of running association mutual exclusion between the timing tasks and the timing tasks is realized, and the problem of singleness of the timing tasks is effectively solved.
In one embodiment, the step of sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode includes: acquiring a second task identifier of the target timing task; performing hash operation on the second task identifier to obtain a hash value of the second task identifier; and determining a target scheduling end from scheduling ends corresponding to the running mode of the target timing task according to the hash value, and sending the metadata of the target task to a task queue of the target scheduling end.
In this embodiment, when the main control end sends the target timing task to the scheduling end corresponding to the target timing task operation mode, according to the hash value of the task identifier of the target timing task, the scheduling end corresponding to the hash value of the task identifier is determined from the multiple scheduling ends corresponding to the target timing task operation mode, and the metadata of the target timing task is sent to the task queue of the scheduling end, so that the timing task is scheduled to different scheduling ends for processing, the multi-server multi-system processing of the timing task is realized, the accumulation of the task amount of the same scheduling end is avoided, and the processing of the timing task is not affected by the performance of a single machine.
In an embodiment, before the step of reading the operation period of each timing task in the database, the main control end may obtain metadata of each timing task, where the metadata may include the operation period of the timing task, basic description information, estimated operation duration, task identifier of the dependent task, scheduling information, and operation mode. The definition mode of the operation period can adopt an expression supporting Linux Crontab; the basic description information comprises basic information such as a project to which the timing task belongs, and an API interface is provided to interface with a project management service system so as to support other service systems to inquire the basic information of the timing task; and the scheduling information records an execution server where the WEB application running the timing task is located. The centralized and unified management of the timing task information is realized by pre-storing the metadata of the timing task into the database.
In an embodiment, as shown in fig. 3, a method for processing a timed task is provided, which is described by taking the method as an example applied to the scheduling end in fig. 1, and includes the following steps:
step S310: inquiring a task queue;
step S320: when the metadata of the target timing task is inquired from the task queue, the execution server is called to execute the target timing task according to the metadata; the estimated running time of the target timing task is smaller than a preset time index value and is not dependent on locking; and the metadata of the target timing task is sent to the task queue by the main control end according to the running mode of the target timing task.
The scheduling end inquires whether the metadata of the executable target timing task exists in the task queue in real time, and after the main control end sends the metadata of the target timing task to the task queue of the scheduling end, the scheduling end inquires the metadata of the target timing task and schedules an execution server where the WEB application running the target timing task is located to execute the target timing task so as to realize the function of the timing task.
According to the timed task processing method, after the main control end sends the target timed task to the task queue corresponding to the running mode according to the running mode of the target timed task, the metadata of the target timed task in the task queue is inquired, the execution server is called according to the metadata to execute the target timed task, the timed task is scheduled to different scheduling ends, the scheduling end calls the execution server to execute the target timed task, the scheduling of the timed task and the execution of the timed task are decoupled by using the task queue, the processing work of the timed task among multiple servers and multiple systems is realized, the processing of the timed task is not influenced by the performance of a single machine, the generation of performance bottleneck and the reduction of the execution accuracy and the frequency of the timed task are effectively avoided, and the expansion and contraction of the scheduling ends according to the performance requirements can be realized.
In one embodiment, the mode of operation includes a native run code type; the step of calling the execution server to execute the target timing task according to the metadata comprises the following steps: determining a first execution server from the metadata, and pulling a program code corresponding to the target timing task from the main control end; sending a program code to a first execution server, wherein the program code is used for indicating the first execution server to run the program code; and receiving result data returned by the first execution server.
After inquiring metadata of executable timing tasks in the task queue, the scheduling end determines a target execution server where a WEB application running the timing tasks is located from the metadata, pulls a program code corresponding to the target timing tasks from the main control end, sends the pulled program code to the target execution server, runs the program code to realize the function of the target timing tasks after the target execution server receives the program code and the metadata, and transmits result data obtained after the program code runs to the scheduling end. The main control end can upload program codes corresponding to the timing tasks in advance so that the scheduling end can pull the program codes. The embodiment provides processing schemes for different types of timing tasks, realizes the function of the timing tasks by remotely deploying and operating program codes, effectively improves the processing efficiency of the timing tasks, and avoids the accumulation of the timing tasks.
In one embodiment, the mode of operation includes calling an interface operation type; the step of calling the execution server to execute the target timing task according to the metadata comprises the following steps: determining a second execution server from the metadata, and triggering a calling interface of the second execution server; and receiving result data returned by the second execution server through the calling interface.
In this embodiment, after inquiring metadata of an executable timing task in a task queue, a scheduling end determines an execution server where a WEB application running the timing task is located from the metadata, triggers the execution server to run a target timing task through a call interface to realize a function of the target timing task, returns result data through the call interface after the execution server runs, and receives the result data through the call interface.
In an embodiment, as shown in fig. 4, a method for processing a timed task is provided, which takes an interaction between a master control end and a scheduling end as an example to explain, and includes the following steps:
step S410: the main control end reads the operation period of each timing task in the database and determines a target timing task from each timing task according to the operation period;
step S420: the main control end compares the estimated running time of the target timing task with a preset time index value, and judges whether the target timing task is dependent on locking;
step S430: when the estimated running time of the target timing task is smaller than a preset time index value and no dependency locking exists, the main control end determines the running mode of the target timing task;
step S440: the main control end sends the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode;
step S450: and the scheduling end inquires the task queue, and when the metadata of the target timing task is inquired from the task queue, the scheduling end calls the execution server to execute the target timing task according to the metadata.
According to the timed task scheduling method, the current target timed task is determined by reading the running period of each timed task in the database, when the estimated running time of the target timed task is smaller than the preset time index value and no dependency locking exists, the metadata of the target timed task is sent to the task queue of the scheduling end corresponding to the running mode of the target timed task, the timed task is scheduled to different scheduling ends, the scheduling end calls the execution server to execute the target timed task, the scheduling of the timed task and the execution of the timed task are decoupled by using the task queue, the processing work of the timed task among multiple servers and multiple systems is realized, the processing of the timed task is not influenced by the performance of a single machine, and the generation of performance bottleneck and the reduction of the execution accuracy and the frequency of the timed task are effectively avoided. Meanwhile, the estimated running time of the target timing task is compared with the preset time index value, and whether the target timing task is dependent and locked or not is judged, so that the congestion problem before and after the running of the timing task is effectively solved, the design of running relevance mutual exclusion among different timing tasks can be realized, and the problem of singleness of the timing task is solved.
In one embodiment, the mode of operation includes a native run code type; the step that the scheduling terminal calls the execution server to execute the target timing task according to the metadata comprises the following steps: the scheduling end determines a first execution server from the metadata and pulls a program code corresponding to the target timing task from the main control end; the scheduling end sends the program code to the first execution server, and the program code is used for indicating the first execution server to run the program code; and the scheduling end receives result data returned by the first execution server.
In this embodiment, after querying metadata of a timing task executable in a task queue, a scheduling end determines an execution server where a WEB application running the timing task is located from the metadata, and pulls a program code corresponding to a target timing task from a main control end, so that the pulled program code is sent to the execution server, and after receiving the program code and the metadata, the execution server runs the program code to implement a function of the target timing task, and transmits result data obtained after the program code runs to the scheduling end. The main control end can upload program codes corresponding to the timing tasks in advance so that the scheduling end can pull the program codes.
It should be understood that although the steps in the flowcharts of fig. 2 to 4 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-4 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
In an embodiment, as shown in fig. 5, a timing task scheduling device is provided, and in this embodiment, taking a side of a main control end as an example for description, the timing task scheduling device includes: a target timed task obtaining module 510, an operation condition judging module 520, an operation mode determining module 530 and a timed task sending module 540, wherein:
a target timing task obtaining module 510, configured to read an operation period of each timing task in the database, and determine a target timing task from each timing task according to the operation period;
the running condition judging module 520 is configured to compare the estimated running time of the target timing task with a preset time index value, and judge whether the target timing task is dependent on locking;
an operation mode determining module 530, configured to determine an operation mode of the target timing task when the estimated operation duration of the target timing task is smaller than a preset duration index value and no dependency locking exists;
a timed task sending module 540, configured to send metadata of the target timed task to a task queue of a scheduling end corresponding to the running mode; and the metadata of the target timing task is used for indicating the scheduling end to call the execution server to execute the target timing task according to the metadata.
In one embodiment, the running condition determining module 520 is configured to read metadata of the target timed task, and determine a first task identifier and a dependency status of a dependent task of the target timed task from the metadata; reading the running state of the timing task corresponding to the first task identifier; and when the running state is not matched with the dependency state, judging that the target timing task has dependency locking.
In one embodiment, the timed task sending module 540 is configured to obtain a second task identifier of the target timed task; performing hash operation on the second task identifier to obtain a hash value of the second task identifier; and determining a target scheduling end from scheduling ends corresponding to the running mode of the target timing task according to the hash value, and sending the metadata of the target task to a task queue of the target scheduling end.
In an embodiment, as shown in fig. 6, a timed task processing device is provided, and in this embodiment, a scheduling side is taken as an example for explanation, and the timed task scheduling device includes: a task queue query module 610 and a timed task execution module 620, wherein:
a task queue query module 610, configured to query a task queue;
the timed task execution module 620 is configured to, when the metadata of the target timed task is queried in the task queue, invoke the execution server to execute the target timed task according to the metadata; the estimated running time of the target timing task is smaller than a preset time index value and is not dependent on locking; and the metadata of the target timing task is sent to the task queue by the main control end according to the running mode of the target timing task.
In one embodiment, the mode of operation includes a native run code type; a timed task executing module 620, configured to determine a first execution server from the metadata, and pull a program code corresponding to the target timed task from the main control end; sending a program code to a first execution server, wherein the program code is used for indicating the first execution server to run the program code; and receiving result data returned by the first execution server.
In one embodiment, the mode of operation includes calling an interface operation type; a timing task execution module 620, configured to determine a second execution server from the metadata, and trigger a call interface of the second execution server; and receiving result data returned by the second execution server through the calling interface.
In one embodiment, as shown in fig. 7, a timed task processing device is provided, and in this embodiment, an example of interaction between a master controller and a dispatcher is described, where the timed task processing device includes: a target timed task obtaining module 510, an operation condition judging module 520, an operation mode determining module 530, a timed task sending module 540, a task queue querying module 610 and a timed task executing module 620, wherein:
a target timing task obtaining module 510, configured to read an operation period of each timing task in the database, and determine a target timing task from each timing task according to the operation period;
a target timing task obtaining module 510, configured to read an operation period of each timing task in the database, and determine a target timing task from each timing task according to the operation period;
the running condition judging module 520 is configured to compare the estimated running time of the target timing task with a preset time index value, and judge whether the target timing task is dependent on locking;
an operation mode determining module 530, configured to determine an operation mode of the target timing task when the estimated operation duration of the target timing task is smaller than a preset duration index value and no dependency locking exists;
a timed task sending module 540, configured to send metadata of the target timed task to a task queue of a scheduling end corresponding to the running mode;
a task queue query module 610, configured to query a task queue;
and the timed task executing module 620 is configured to, when the metadata of the target timed task is queried in the task queue, invoke the execution server to execute the target timed task according to the metadata.
For specific limitations of the scheduled task scheduling device and the scheduled task processing device, reference may be made to the above limitations of the scheduled task scheduling method and the scheduled task processing method, which are not described herein again. The modules in the above-mentioned timed task scheduling device or timed task processing device can be wholly or partially implemented by software, hardware and their combination. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 8. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing metadata of the timed task. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a timed task scheduling method or a timed task processing method.
Those skilled in the art will appreciate that the architecture shown in fig. 8 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, there is provided a computer device comprising a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program:
reading the running period of each timing task in the database, and determining a target timing task from each timing task according to the running period;
comparing the estimated running time of the target timing task with a preset time index value, and judging whether the target timing task is dependent on locking;
when the estimated running time of the target timing task is smaller than a preset time index value and no dependency locking exists, determining a running mode of the target timing task;
sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode; and the metadata of the target timing task is used for indicating the scheduling end to call the execution server to execute the target timing task according to the metadata.
In one embodiment, when the processor executes the computer program to implement the step of determining whether the dependency lock exists in the target timing task, the following steps are specifically implemented: reading metadata of the target timing task, and determining a first task identifier and a dependency state of a dependent task of the target timing task from the metadata; reading the running state of the timing task corresponding to the first task identifier; and if the running state is not matched with the dependency state, judging that the target timing task has dependency locking.
In an embodiment, when the processor executes the computer program and further performs the step of sending the metadata of the target timing task to the task queue of the scheduling end corresponding to the running mode, the following steps are specifically performed: acquiring a second task identifier of the target timing task; performing hash operation on the second task identifier to obtain a hash value of the second task identifier; and determining a target scheduling end from scheduling ends corresponding to the running mode of the target timing task according to the hash value, and sending the metadata of the target task to a task queue of the target scheduling end.
In one embodiment, there is provided a computer device comprising a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program:
inquiring a task queue;
when the metadata of the target timing task is inquired from the task queue, the execution server is called to execute the target timing task according to the metadata; the estimated running time of the target timing task is smaller than a preset time index value and is not dependent on locking; and the metadata of the target timing task is sent to the task queue by the main control end according to the running mode of the target timing task.
In one embodiment, the mode of operation includes a native run code type; when the processor executes the computer program to realize the step of calling the execution server to execute the target timing task according to the metadata, the following steps are specifically realized: determining a first execution server from the metadata, and pulling a program code corresponding to the target timing task from the main control end; sending a program code to a first execution server, wherein the program code is used for indicating the first execution server to run the program code; and receiving result data returned by the first execution server.
In one embodiment, the mode of operation includes calling an interface operation type; when the processor executes the computer program to realize the step of calling the execution server to execute the target timing task according to the metadata, the following steps are specifically realized: determining a second execution server from the metadata, and triggering a calling interface of the second execution server; and receiving result data returned by the second execution server through the calling interface.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
reading the running period of each timing task in the database, and determining a target timing task from each timing task according to the running period;
comparing the estimated running time of the target timing task with a preset time index value, and judging whether the target timing task is dependent on locking;
when the estimated running time of the target timing task is smaller than a preset time index value and no dependency locking exists, determining a running mode of the target timing task;
sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode; and the metadata of the target timing task is used for indicating the scheduling end to call the execution server to execute the target timing task according to the metadata.
In one embodiment, when the computer program is executed by the processor to implement the step of determining whether the dependency lock exists in the target timing task, the following steps are specifically implemented: reading metadata of the target timing task, and determining a first task identifier and a dependency state of a dependent task of the target timing task from the metadata; reading the running state of the timing task corresponding to the first task identifier; and if the running state is not matched with the dependency state, judging that the target timing task has dependency locking.
In one embodiment, when the computer program is executed by the processor to implement the step of sending the metadata of the target timing task to the task queue of the scheduling end corresponding to the running mode, the following steps are specifically implemented: acquiring a second task identifier of the target timing task; performing hash operation on the second task identifier to obtain a hash value of the second task identifier; and determining a target scheduling end from scheduling ends corresponding to the running mode of the target timing task according to the hash value, and sending the metadata of the target task to a task queue of the target scheduling end.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
inquiring a task queue;
when the metadata of the target timing task is inquired from the task queue, the execution server is called to execute the target timing task according to the metadata; the estimated running time of the target timing task is smaller than a preset time index value and is not dependent on locking; and the metadata of the target timing task is sent to the task queue by the main control end according to the running mode of the target timing task.
In one embodiment, the mode of operation includes a native run code type; when the computer program is executed by the processor to realize the step of calling the execution server to execute the target timing task according to the metadata, the specific steps are as follows: determining a first execution server from the metadata, and pulling a program code corresponding to the target timing task from the main control end; sending a program code to a first execution server, wherein the program code is used for indicating the first execution server to run the program code; and receiving result data returned by the first execution server.
In one embodiment, the mode of operation includes calling an interface operation type; when the computer program is executed by the processor to realize the step of calling the execution server to execute the target timing task according to the metadata, the following steps are specifically realized: determining a second execution server from the metadata, and triggering a calling interface of the second execution server; and receiving result data returned by the second execution server through the calling interface.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (11)

1. A timing task scheduling method is characterized by comprising the following steps:
reading the operation period of each timing task in a database, and determining a target timing task from each timing task according to the operation period;
comparing the estimated running time of the target timing task with a preset time index value, and judging whether the target timing task is dependent on locking;
when the estimated running time of the target timing task is smaller than the preset time index value and no dependency locking exists, determining the running mode of the target timing task; the operation mode comprises calling an interface operation type;
sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode; the metadata of the target timing task is used for indicating the scheduling end to determine a second execution server from the metadata, trigger a call interface of the second execution server, and receive result data returned by the second execution server through the call interface.
2. The method of claim 1, wherein the step of determining whether the target timed task has a dependent lock comprises:
reading metadata of the target timing task, and determining a first task identifier and a dependency state of a dependent task of the target timing task from the metadata;
reading the running state of the timing task corresponding to the first task identifier;
and if the running state is not matched with the dependency state, judging that the target timing task has dependency locking.
3. The method according to claim 1, wherein the step of sending the metadata of the target timed task to a task queue of a scheduling end corresponding to an operation mode comprises:
acquiring a second task identifier of the target timing task;
performing hash operation on the second task identifier to obtain a hash value of the second task identifier;
and determining a target scheduling end from scheduling ends corresponding to the running mode of the target timing task according to the hash value, and sending the metadata of the target task to a task queue of the target scheduling end.
4. A method for processing a timed task, the method comprising:
inquiring a task queue;
when the metadata of the target timing task is inquired from the task queue, an execution server is called to execute the target timing task according to the metadata; the estimated running time of the target timing task is smaller than a preset time index value and is not dependent on locking; the metadata of the target timing task is sent to the task queue by the main control end according to the running mode of the target timing task;
the operation mode comprises an interface calling operation type, and the step of calling the execution server to execute the target timing task according to the metadata comprises the following steps:
determining a second execution server from the metadata, and triggering a calling interface of the second execution server;
and receiving result data returned by the second execution server through the calling interface.
5. The timed task processing method according to claim 4, wherein said operating mode includes a native operating code type;
the step of calling an execution server to execute the target timing task according to the metadata comprises the following steps:
determining a first execution server from the metadata, and pulling a program code corresponding to the target timing task from the main control end;
sending the program code to the first execution server, the program code for instructing the first execution server to run the program code;
and receiving result data returned by the first execution server.
6. A method for processing a timed task, the method comprising:
the method comprises the steps that a main control end reads the operation period of each timing task in a database, and a target timing task is determined from each timing task according to the operation period;
the main control end compares the estimated running time of the target timing task with a preset time index value, and judges whether the target timing task is dependent on locking;
when the estimated running time of the target timing task is smaller than the preset time index value and is not dependent on locking, the main control end determines the running mode of the target timing task; the operation mode comprises calling an interface operation type;
the main control end sends the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode;
and the scheduling end inquires a task queue, and when metadata of a target timing task is inquired from the task queue, the scheduling end determines a second execution server from the metadata, triggers a calling interface of the second execution server, and receives result data returned by the second execution server through the calling interface.
7. The timed task processing method according to claim 6, wherein said execution mode includes a native execution code type;
the step of the scheduling terminal calling the execution server to execute the target timing task according to the metadata comprises the following steps:
the scheduling end determines a first execution server from the metadata and pulls a program code corresponding to the target timing task from the main control end;
the scheduling end sends the program code to the first execution server, and the program code is used for indicating the first execution server to run the program code;
and the scheduling end receives result data returned by the first execution server.
8. A timed task scheduling apparatus, characterized in that said apparatus comprises:
the target timing task acquisition module is used for reading the operation period of each timing task in the database and determining the target timing task from each timing task according to the operation period;
the running condition judging module is used for comparing the estimated running time of the target timing task with a preset time index value and judging whether the target timing task is dependent on locking;
the operation mode determination module is used for determining the operation mode of the target timing task when the estimated operation time of the target timing task is smaller than the preset time index value and no dependency locking exists; the operation mode comprises calling an interface operation type;
the timing task sending module is used for sending the metadata of the target timing task to a task queue of a scheduling end corresponding to the running mode; the metadata of the target timing task is used for indicating the scheduling end to determine a second execution server from the metadata, trigger a call interface of the second execution server, and receive result data returned by the second execution server through the call interface.
9. A timed task processing apparatus, characterized in that it comprises:
the task queue query module is used for querying a task queue;
the timing task execution module is used for calling an execution server to execute the target timing task according to the metadata when the metadata of the target timing task is inquired in the task queue; the estimated running time of the target timing task is smaller than a preset time index value and is not dependent on locking; the metadata of the target timing task is sent to the task queue by the main control end according to the running mode of the target timing task;
the operation mode comprises a calling interface operation type, and the timing task execution module is also used for determining a second execution server from the metadata and triggering a calling interface of the second execution server; and receiving result data returned by the second execution server through the calling interface.
10. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
11. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN201910326565.1A 2019-04-23 2019-04-23 Timed task scheduling method and timed task processing method Active CN109992390B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910326565.1A CN109992390B (en) 2019-04-23 2019-04-23 Timed task scheduling method and timed task processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910326565.1A CN109992390B (en) 2019-04-23 2019-04-23 Timed task scheduling method and timed task processing method

Publications (2)

Publication Number Publication Date
CN109992390A CN109992390A (en) 2019-07-09
CN109992390B true CN109992390B (en) 2021-05-18

Family

ID=67134979

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910326565.1A Active CN109992390B (en) 2019-04-23 2019-04-23 Timed task scheduling method and timed task processing method

Country Status (1)

Country Link
CN (1) CN109992390B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113672358A (en) * 2020-05-15 2021-11-19 北京沃东天骏信息技术有限公司 Timing task processing method, device and system, electronic equipment and storage medium
CN113975815B (en) * 2021-11-04 2022-12-23 上海鱼尔网络科技有限公司 Task transfer method, system, device, equipment and storage medium
CN118043780A (en) * 2022-06-20 2024-05-14 北京小米移动软件有限公司 Timing task management method, device, electronic equipment and storage medium
CN116431318A (en) * 2023-06-13 2023-07-14 云账户技术(天津)有限公司 Timing task processing method and device, electronic equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8893130B2 (en) * 2007-03-26 2014-11-18 Raytheon Company Task scheduling method and system
CN103365708B (en) * 2012-04-06 2017-03-22 阿里巴巴集团控股有限公司 Method and device for scheduling tasks
CN104965754A (en) * 2015-03-31 2015-10-07 腾讯科技(深圳)有限公司 Task scheduling method and task scheduling apparatus
CN108287751B (en) * 2017-01-09 2022-02-01 阿里巴巴集团控股有限公司 Task execution method and device and distributed system
CN108958915A (en) * 2018-06-28 2018-12-07 中国建设银行股份有限公司 Timed task executes method and device
CN109558239A (en) * 2018-10-26 2019-04-02 北京中关村科金技术有限公司 A kind of method for scheduling task, device, system, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
定时任务调度服务系统设计与实现;范云飞;《中国优秀硕士学位论文全文数据库信息科技辑》;20100415(第4期);第I138-79 *

Also Published As

Publication number Publication date
CN109992390A (en) 2019-07-09

Similar Documents

Publication Publication Date Title
CN109992390B (en) Timed task scheduling method and timed task processing method
CN112099958B (en) Distributed multi-task management method and device, computer equipment and storage medium
CN108845884B (en) Physical resource allocation method, device, computer equipment and storage medium
CN108563502B (en) Task scheduling method and device
CN110612705A (en) Method for service deployment under server-free architecture and function management platform
US11119911B2 (en) Garbage collection method and device
CN110895484A (en) Task scheduling method and device
CN110750343B (en) Cluster system timing task scheduling control method and cluster system
CN112905339B (en) Task scheduling execution method, device and system
CN108763046B (en) Thread running monitoring method, device, computer equipment and storage medium
CN111078733A (en) Batch task processing method and device, computer equipment and storage medium
CN111708586A (en) Application starting configuration item loading method and device, computer equipment and storage medium
CN110895486B (en) Distributed task scheduling system
CN112860386A (en) Method for switching nodes in distributed master-slave system
CN115617497A (en) Thread processing method, scheduling component, monitoring component, server and storage medium
CN109697112B (en) Distributed intensive one-stop operating system and implementation method
CN113849320A (en) Development method, control method and computing device
CN113608838A (en) Deployment method and device of application image file, computer equipment and storage medium
CN110457614B (en) Data increment updating method and device for reducing data concurrency and computer equipment
CN112965817A (en) Resource management method and device and electronic equipment
CN112070585A (en) Order state unified management method and device, computer equipment and storage medium
CN116701063A (en) Persistence method, device and system for internal memory state data for data language of digital networking
CN114221863B (en) Intelligent node election method for distributed cluster
CN110688211A (en) Distributed job scheduling method
CN114172903B (en) Node capacity expansion method, device, equipment and medium of slm scheduling system

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
GR01 Patent grant
GR01 Patent grant