CN113238849A - Timed task processing method and device, storage medium and electronic equipment - Google Patents

Timed task processing method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN113238849A
CN113238849A CN202110603563.XA CN202110603563A CN113238849A CN 113238849 A CN113238849 A CN 113238849A CN 202110603563 A CN202110603563 A CN 202110603563A CN 113238849 A CN113238849 A CN 113238849A
Authority
CN
China
Prior art keywords
task
processed
timed
timing
timed task
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
CN202110603563.XA
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.)
Hangzhou Netease Cloud Music Technology Co Ltd
Original Assignee
Hangzhou Netease Cloud Music 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 Hangzhou Netease Cloud Music Technology Co Ltd filed Critical Hangzhou Netease Cloud Music Technology Co Ltd
Priority to CN202110603563.XA priority Critical patent/CN113238849A/en
Publication of CN113238849A publication Critical patent/CN113238849A/en
Pending legal-status Critical Current

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
    • 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
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/10Office automation; Time management
    • G06Q10/109Time management, e.g. calendars, reminders, meetings or time accounting

Abstract

The embodiment of the disclosure relates to a timing task processing method, a timing task processing device, a storage medium and electronic equipment, and relates to the technical field of data processing. The timing task processing method comprises the following steps: acquiring a timing task to be processed from a timing task database; determining the expected waiting time of the timing task to be processed; adding the timing task to be processed with the expected waiting time smaller than the preset time threshold value to a timing task queue corresponding to the type of the timing task to be processed; when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, prompting a service party to execute the to-be-processed timed task according to a trigger rule corresponding to the queue type of the timed task queue. When a large number of timing tasks to be processed need to be triggered and prompted at the same time, a business side can be triggered to execute the timing tasks on time and with high quality.

Description

Timed task processing method and device, storage medium and electronic equipment
Technical Field
Embodiments of the present disclosure relate to the field of data processing technologies, and in particular, to a timed task processing method, a timed task processing apparatus, a computer storage medium, and an electronic device.
Background
The timing task is a task type common in various business scenarios, and generally includes execution time and task content of the timing task.
In general, the timed task server may obtain a timed task in a service scenario of a service party, determine the obtained timed task as a to-be-processed timed task, and when the execution time of the to-be-processed timed task is reached, the timed task server may prompt the service party to execute the to-be-processed timed task.
With the increasing complexity of the timing task in the business scenario, for example, a large number of to-be-processed timing tasks need to be executed at the same time, or the to-be-processed timing tasks need to be executed on time, and the like, a business side puts higher demands on the timing task server side.
Disclosure of Invention
However, the existing timing task processing scheme has the problems that the timing task to be processed is not timely triggered, a large number of timing tasks to be processed need to be triggered simultaneously, and a system easily breaks down, so that a business party cannot be prompted timely to execute the timing task.
Therefore, a scheme is needed to ensure that the timed task server can timely, stably and efficiently trigger and prompt the service party to execute the to-be-processed timed task.
In this context, embodiments of the present disclosure are intended to provide a timed task processing method, a timed task processing apparatus, a computer-readable storage medium, and an electronic device.
According to a first aspect of the embodiments of the present disclosure, there is provided a method for processing a timed task, where the method is applied to a timed task server, and the method includes:
acquiring a timing task to be processed from a timing task database;
determining the expected waiting time of the timing task to be processed, wherein the expected waiting time is the time difference between the execution time of the timing task to be processed and the current time;
adding the timing task to be processed with the expected waiting time smaller than the preset time threshold value to a timing task queue corresponding to the type of the timing task to be processed;
and when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, prompting a service party to execute the to-be-processed timed tasks according to a trigger rule corresponding to the queue type of the timed task queue.
In an optional implementation manner, the timed task queue is configured based on a service scenario, one task queue corresponds to one service scenario, one task queue supports multiple timed task types in the same service scenario, and one timed task type corresponds to one independent and isolated timed task queue.
In an optional embodiment, the method further comprises:
storing the timing task to be processed in a local database;
after adding the to-be-processed timed task with the expected waiting time smaller than the preset time threshold to the timed task queue corresponding to the to-be-processed timed task, the method further comprises the following steps:
and removing the timing tasks to be processed, which have been added to the timing task queue and the expected waiting time of which is less than a preset time threshold value, from the local database.
In an optional embodiment, after removing the pending timed task whose expected waiting time is less than a preset time threshold from the local database, the method further comprises:
scanning each to-be-processed timing task in the local database according to a preset period;
and when the expected waiting time of the timing task to be processed is less than a preset time threshold, adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed.
In an optional implementation manner, the timing task queue includes a first type of timing task queue, and the prompting, according to a trigger rule corresponding to a queue type of the timing task queue, the service party to execute the to-be-processed timing task includes:
determining a triggering sequence of a plurality of to-be-processed timed tasks reaching the execution time in the first type of timed task queue;
and sequentially prompting the service party to execute the timing tasks to be processed according to the trigger sequence.
In an optional implementation manner, the timing task queue includes a second type of timing task queue, and the prompting, according to a trigger rule corresponding to a queue type of the timing task queue, the service party to execute the to-be-processed timing task includes:
determining task priorities of a plurality of to-be-processed timed tasks reaching the execution time in the second type timed task queue;
and sequentially prompting a service party to execute the timing tasks to be processed according to the sequence of the task priority corresponding to each timing task to be processed from high to low.
In an optional implementation manner, the timing task queue includes a third type of timing task queue, and the prompting, according to a trigger rule corresponding to a queue type of the timing task queue, the service party to execute the to-be-processed timing task includes:
and selecting any one of the to-be-processed timing tasks as the to-be-processed timing task, and prompting a service party to execute the to-be-processed timing task.
In an optional embodiment, the method further comprises:
when the calling operation of the timing task database is detected, the timing task to be processed and the task type of the timing task to be processed are obtained;
and storing the to-be-processed timed task in the timed task database, and generating a new event in a log file of the timed task database.
In an optional implementation manner, the acquiring a to-be-processed timing task includes:
monitoring a log file of the timed task database;
and when a new event is generated in the log file, acquiring a to-be-processed timed task from the timed task database according to the new event.
In an optional implementation manner, the adding, to a timing task queue corresponding to the to-be-processed timing task, the to-be-processed timing task whose expected waiting time is less than a preset time threshold includes:
determining the task type of the timing task to be processed;
determining a timing task queue corresponding to the task type;
and adding the timing task to be processed to a timing task queue corresponding to the task type.
In an optional implementation manner, the configuring the task queue at the timed task server, and adding the to-be-processed timed task whose expected waiting time is less than a preset time threshold to the timed task queue corresponding to the to-be-processed timed task includes:
determining a timing task queue corresponding to the timing task to be processed;
determining the timing task server configured with the timing task queue corresponding to the timing task to be processed;
and adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed in the timing task server.
In an optional implementation manner, the number of the timed task servers configured with the timed task queue corresponding to the to-be-processed timed task includes a plurality of, and the method further includes:
when the execution time of the timing task to be processed is reached, each timing task server side obtains a processing identifier of the timing task to be processed;
the prompting service party executes the timing task to be processed, and the method comprises the following steps:
and the target timed task server prompts a service party to execute the to-be-processed timed task, wherein the target timed task server is the only one timed task server which successfully acquires the processing identifier from the plurality of timed task servers configured with the timed task queue corresponding to the to-be-processed timed task.
In an optional implementation manner, the prompting the service party to execute the to-be-processed timing task includes:
generating prompt information about the timing task to be processed;
sending prompt information about the timing task to be processed to the service party; alternatively, the first and second electrodes may be,
and sending the timing task to be processed to the service party.
In an optional implementation manner, the configuring the task queue at the service side, and adding the to-be-processed timed task whose expected waiting time is less than the preset time threshold to the timed task queue corresponding to the to-be-processed timed task includes:
determining a timing task queue corresponding to the timing task to be processed;
and adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed in the service side server.
In an optional implementation manner, the prompting the service party to execute the to-be-processed timing task includes:
and calling a message consumption method of the service party to execute the to-be-processed timing task.
According to a second aspect of the embodiments of the present disclosure, there is provided a timed task processing device, which is applied to a timed task server, the device including:
the acquisition module is configured to acquire the timing task to be processed from the timing task database;
a determining module configured to determine an expected waiting time of the timing task to be processed, where the expected waiting time is a time difference between an execution time of the timing task to be processed and a current time;
the adding module is configured to add the timing task to be processed with the expected waiting time smaller than a preset time threshold value to a timing task queue corresponding to the timing task to be processed;
and the triggering module is configured to prompt a service party to execute the to-be-processed timed task according to a triggering rule corresponding to the queue type of the timed task queue when the to-be-processed timed tasks in the timed task queue simultaneously reach the execution time.
In an optional implementation manner, the timed task queue is configured based on a service scenario, one task queue corresponds to one service scenario, one task queue supports multiple timed task types in the same service scenario, and one timed task type corresponds to one independent and isolated timed task queue.
In an alternative embodiment, the apparatus further comprises:
the storage module is configured to store the timing task to be processed in a local database;
a removal module configured to remove from the local database pending timed tasks that have been added to the timed task queue for which the expected wait time is less than a preset time threshold.
In an alternative embodiment, the apparatus further comprises:
the scanning module is configured to scan each to-be-processed timing task in the local database according to a preset period;
the adding module is configured to add the timing task to be processed to a timing task queue corresponding to the timing task to be processed when the expected waiting time of the timing task to be processed is less than a preset time threshold.
In an optional implementation manner, the timed task queue includes a first type of timed task queue, and the trigger module is configured to:
determining a triggering sequence of a plurality of to-be-processed timed tasks reaching the execution time in the first type of timed task queue;
and sequentially prompting the service party to execute the timing tasks to be processed according to the trigger sequence.
In an optional implementation manner, the timed task queue includes a second type timed task queue, and the trigger module is configured to:
determining task priorities of a plurality of to-be-processed timed tasks reaching the execution time in the second type timed task queue;
and sequentially prompting a service party to execute the timing tasks to be processed according to the sequence of the task priority corresponding to each timing task to be processed from high to low.
In an optional implementation manner, the timed task queue includes a third type of timed task queue, and the trigger module is configured to:
and selecting any one of the to-be-processed timing tasks as the to-be-processed timing task, and prompting a service party to execute the to-be-processed timing task.
In an alternative embodiment, the apparatus further comprises:
the acquisition module is configured to obtain the timing task to be processed and the task type of the timing task to be processed when the calling operation of the timing task database is detected;
and the processing module is configured to store the to-be-processed timed task in the timed task database and generate a new event in a log file of the timed task database.
In an optional embodiment, the obtaining module is configured to:
monitoring a log file of the timed task database;
and when a new event is generated in the log file, acquiring a to-be-processed timed task from the timed task database according to the new event.
In an optional embodiment, the adding module is configured to:
determining the task type of the timing task to be processed;
determining a timing task queue corresponding to the task type;
and adding the timing task to be processed to a timing task queue corresponding to the task type.
In an optional implementation manner, the task queue is configured at the timed task server, and the adding module is configured to:
determining a timing task queue corresponding to the timing task to be processed;
determining the timing task server configured with the timing task queue corresponding to the timing task to be processed;
and adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed in the timing task server.
In an optional implementation manner, the number of the timed task servers configured with the timed task queue corresponding to the to-be-processed timed task includes a plurality of, and the apparatus further includes:
when the execution time of the timing task to be processed is reached, each timing task server side obtains a processing identifier of the timing task to be processed;
and the trigger module of the target timed task server is configured to prompt a service party to execute the to-be-processed timed task, and the target timed task server is the only one timed task server which successfully acquires the processing identifier from the plurality of timed task servers configured with the timed task queue corresponding to the to-be-processed timed task.
In an optional embodiment, the triggering module is configured to:
generating prompt information about the timing task to be processed;
sending prompt information about the timing task to be processed to the service party; alternatively, the first and second electrodes may be,
and sending the timing task to be processed to the service party.
In an optional implementation manner, the task queue is configured at a service side of a business, and the adding module is configured to:
determining a timing task queue corresponding to the timing task to be processed;
and adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed in the service side server.
In an optional embodiment, the triggering module is configured to:
and calling the message consumption device of the service party to execute the to-be-processed timing task.
According to a third aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements any one of the methods described above.
According to a fourth aspect of the disclosed embodiments, there is provided an electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform any of the methods described above via execution of the executable instructions.
According to the method, the device, the computer-readable storage medium and the electronic equipment of the embodiment of the disclosure, for the acquired to-be-processed timed task, the to-be-processed timed task with the expected waiting time smaller than the preset time threshold can be added to the timed task queue corresponding to the type of the to-be-processed timed task, so that the timed task queue maintains the to-be-processed timed task which needs to be triggered to prompt a service party to execute, the data processing amount of the timed task queue is reduced, and queue blocking is prevented; when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, the business party is prompted to execute the to-be-processed timed tasks according to the trigger rule corresponding to the queue type of the timed task queue, so that the conditions that the triggering delay occurs and the business party cannot be triggered to execute the timed tasks can be avoided when a large number of to-be-processed timed tasks are triggered at the same time, and the timed tasks of the business party are ensured to be executed on time.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present disclosure will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
FIG. 1 shows a schematic diagram of a system architecture according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram illustrating an implementation environment of a timed task processing method according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram illustrating an implementation environment of a timed task processing method according to an embodiment of the present disclosure;
FIG. 4 illustrates a flow diagram of a method of timed task processing according to an embodiment of the present disclosure;
FIG. 5 illustrates a flow diagram of a method of timed task processing according to an embodiment of the present disclosure;
FIG. 6 illustrates a flow diagram of a method of timed task processing according to an embodiment of the present disclosure;
FIG. 7 shows a schematic diagram of a timed task processing apparatus according to an embodiment of the present disclosure;
fig. 8 shows a block diagram of an electronic device according to an embodiment of the disclosure.
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Detailed Description
The principles and spirit of the present disclosure will be described with reference to a number of exemplary embodiments. It is understood that these embodiments are given solely for the purpose of enabling those skilled in the art to better understand and to practice the present disclosure, and are not intended to limit the scope of the present disclosure in any way. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
As will be appreciated by one skilled in the art, embodiments of the present disclosure may be embodied as a system, apparatus, device, method, or computer program product. Accordingly, the present disclosure may be embodied in the form of: entirely hardware, entirely software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
According to the embodiment of the disclosure, a timed task processing method and device, a computer readable storage medium and an electronic device are provided.
In this document, any number of elements in the drawings is by way of example and not by way of limitation, and any nomenclature is used solely for differentiation and not by way of limitation.
The principles and spirit of the present disclosure are explained in detail below with reference to several representative embodiments of the present disclosure.
Summary of The Invention
The disclosure finds that, in a process of triggering and prompting a service party to execute a timing task, a delay triggering situation occurs in an existing timing task server, and particularly, when a plurality of to-be-processed timing tasks need to be triggered at the same time, the concurrency triggering capability of the timing task server is poor, the execution time of the timing task of the service party is delayed, and when the service scenes of the service party are more and the to-be-processed timing tasks need to be triggered simultaneously under different service scenes, internal resources can be seized by the timing task server for triggering the to-be-processed timing tasks, so that the timing task server easily fails to trigger and prompt the service party to execute the to-be-processed timing tasks.
It should be noted that, in the embodiment of the present disclosure, a service party is a user of a timed task server, a service scenario of the same service party may include at least one service scenario, the service scenario is an abstraction of service (task) types with similar features, and each service scenario may include multiple service types or timed task types. For example, the business party is a music library management team or a live broadcast management team of a music platform; the business scenes of the song library management team can comprise a common task scene, a priority task scene and a duplication task scene, wherein the timing task types in the common task scene can comprise song release timing tasks, the timing task types in the priority task scene can comprise album release timing tasks, and the timing task types in the duplication task scene can comprise: an album information changing task, a song information changing task, a singer information changing task, and the like.
In order to support rich service scenes, three types of timing task queues can be provided based on the common characteristics of task types under different service scenes, and the trigger rule of each type of timing task queue is set according to the characteristics of the task types, so that one task queue corresponds to one service scene, and the service requirements of different service scenes can be met.
In view of the above, the basic idea of the present disclosure is: a timing task processing method, a timing task processing device, a computer readable storage medium and electronic equipment are provided, and a timing task to be processed can be obtained from a timing task database; determining the expected waiting time of the timing tasks to be processed, adding the timing tasks to be processed with the expected waiting time being less than the preset time threshold value to a timing task queue corresponding to the type of the timing tasks to be processed, and prompting a business party to execute the timing tasks to be processed according to a trigger rule corresponding to the queue type of the timing task queue when a plurality of timing tasks to be processed in the timing task queue reach the execution time at the same time. The expected waiting time is a time difference value between the execution time of the timing task to be processed and the current time, and the preset time threshold is a time condition for judging whether the acquired timing task to be processed needs to be added to the timing task queue. In the process of processing the timing task, the business party can be triggered and prompted to execute the timing task in more accurate time, and simultaneously, in the process of triggering a large number of timing tasks to be processed in a business scene, the conditions of triggering delay and incapability of triggering can be avoided, the timing task execution opportunity of the business party is prevented from being delayed, the business party executes the timing task on time, and the use experience of a business party service user is ensured.
Having described the general principles of the present disclosure, various non-limiting embodiments of the present disclosure are described in detail below.
Application scene overview
It should be noted that the following application scenarios are merely illustrated to facilitate understanding of the spirit and principles of the present disclosure, and embodiments of the present disclosure are not limited in this respect. Rather, embodiments of the present disclosure may be applied to any scenario where applicable.
In the embodiment of the present disclosure, a service party is a user of a timed task server, a service scenario of the same service party may include at least one service, a service scenario is an abstraction of service (task) types with similar features, and each service scenario may include multiple service types or timed task types. For example, the business party is a music library management team or a live broadcast management team of a music platform; the business scenes of the song library management team can comprise a common task scene, a priority task scene and a duplication task scene, wherein the timing task types in the common task scene can comprise song release timing tasks, the timing task types in the priority task scene can comprise album release timing tasks, and the timing task types in the duplication task scene can comprise: an album information changing task, a song information changing task, a singer information changing task, and the like.
According to the embodiment of the disclosure, after the timed task server obtains the to-be-processed timed task, the to-be-processed timed task can be added to the timed task queue corresponding to the type of the to-be-processed timed task, and when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, the service party is prompted to execute the to-be-processed timed task according to the trigger rule corresponding to the queue type of the timed task queue. The situation that the timing task server cannot trigger the service party to execute the timing task to be processed or the situation that the service party is delayed to be triggered to execute the timing task to be processed is avoided, and the service party is ensured to execute the timing task to be processed on time.
Exemplary method
The exemplary embodiment of the present disclosure first provides a timed task processing method. Fig. 1 shows a system architecture diagram of an environment in which the method operates. As shown in fig. 1, the system architecture 100 may include: a timed task server 110 and at least one business side server 120 of a business side.
In general, the timed task server 110 and the service side server 120 may interact; the timed task server 110 may obtain a to-be-processed timed task established by the service party in response to a call operation of the service party server 120, after obtaining the to-be-processed timed task, the timed task server 110 may determine an expected waiting time of the to-be-processed timed task, add the to-be-processed timed task whose expected waiting time is less than a preset time threshold to a timed task queue corresponding to a type of the to-be-processed timed task, and trigger and prompt the service party server 120 to process the to-be-processed timed task according to a trigger rule corresponding to the queue type of the timed task queue when a plurality of to-be-processed timed tasks in the timed task queue reach an execution time at the same time, so that the service party server 120 executes the to-be-processed timed task.
It is understood that the present exemplary embodiment does not limit the number of the timed task servers, and the timed task server 110 and the business side server 120 in the system architecture 100 may be a timed task server cluster, respectively. For the convenience of system management, dedicated timing task servers 110 may be configured for different service side servers 120 to process timing tasks of the corresponding service side servers 120.
It should be noted that, in the embodiment of the present disclosure, the timed task server may include a first timed task server and a second timed task server, and when the timed task server includes the first timed task server and the second timed task server, the first timed task server, the second timed task server, and the service side server may have two deployment forms:
in a first timing task service end deployment form, a first timing task service end, a second timing task service end and a service side service end are independently deployed, wherein the first timing task service end can acquire a timing task to be processed from a timing task database, determine expected waiting time of the timing task to be processed, determine a timing task type to be processed of the timing task to be processed, the expected waiting time of which is less than a preset time threshold, determine a timing task queue corresponding to the timing task type to be processed, and the second timing task service end corresponding to the timing task queue, and send the timing task to be processed to the second timing task service end corresponding to the task type.
The second timed task server can receive the to-be-processed timed task, add the to-be-processed timed task to the timed task queue corresponding to the type of the to-be-processed timed task, and prompt the service side server of the service side to process the to-be-processed timed task according to the trigger rule corresponding to the queue type of the timed task queue when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time.
For example, assuming that the first timed task Server and the second timed task Server are respectively deployed in a Cluster, as shown in fig. 2, the first timed task Server 210 may form a timer Server Cluster (Robin-Server-Cluster, RSC), and the second timed task Server 220 may form a timer Client centralized forwarding Cluster (Robin-Client-forwarded-Cluster, RCFC), wherein the first timed task Server 210 may include a task obtaining module 2101 and a distributing module 2102, the task obtaining module 2101 is configured to obtain the to-be-processed timed task from the timed task database and determine an expected waiting time of the to-be-processed timed task, determine a to-be-processed timed task type of the to-be-processed timed task whose expected waiting time is less than a preset time threshold, determine a timed task queue corresponding to the to-be-processed timed task type, and the second timed task Server corresponding to the timed task queue, the distribution module 2102 is configured to send the to-be-processed timed task to the second timed task server 202 corresponding to the task type, for example, the distribution module 2102 broadcasts the to-be-processed timed task to the eligible RCFC machines in a broadcast manner.
The second timed task server 220 may include a first task receiving module 2201 and a task adding module 2202, where the task receiving module 2201 is configured to receive a to-be-processed timed task, and the task adding module 2202 is configured to add the to-be-processed timed task to a timed task queue corresponding to a type of the to-be-processed timed task, set the task queue in a memory, and wait for fixed-point execution. When a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, the service side server 120 of the service side is prompted to process the to-be-processed timed task according to the trigger rule corresponding to the queue type of the timed task queue. For example, the RCFC machine will trigger different forwarding logic according to different queue types, and send the timing task to the service side through Nydus. And the service party acquires the execution parameters in the timing task by consuming the Nydus message and performs service processing.
In the second form of deployment of the timed task service end, the first timed task service end and the service end 120 are deployed independently, and the service logic in the second timed task service end may run in the service end 120 in the form of a logic data packet, for example, deployed in a consumption cluster of the service end as a Software Development Kit (SDK). The first timed task server can obtain the to-be-processed timed task from the timed task database, determine the expected waiting time of the to-be-processed timed task, send the to-be-processed timed task with the expected waiting time being less than the preset time threshold to the service side server 120, the service side server 120 can receive the to-be-processed timed task, add the to-be-processed timed task to a timed task queue corresponding to the type of the to-be-processed timed task, and trigger and call the message consumption method of the service side server to execute the to-be-processed timed task according to a trigger rule corresponding to the queue type of the timed task queue when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time.
For example, assuming that the first timed task Server and the service side Server are respectively deployed in a Cluster, as shown in fig. 3, the first timed task Server 210 may form a timer-Server-Cluster (RSC), and the service side Server 120 may form a service-Consumer-Cluster (BCC), where the first timed task Server 210 includes a task obtaining module 2101 and a distributing module 2012, the task obtaining module 2101 is configured to obtain a to-be-processed timed task from a timed task database and determine an expected waiting time of the to-be-processed timed task, and the distributing module 2102 is configured to send the to-be-processed timed task whose expected waiting time is less than a preset time threshold to the service side Server 120. For example, the distribution module 2102 broadcasts the pending timed task to the eligible BCC machine by broadcasting.
The service side server 120 may include a second task receiving module 1201, a task processing module 1202, and a task executing module 1203, where the second task receiving module 1201 is configured to receive a to-be-processed timed task, and the task processing module 1202 adds the to-be-processed timed task to a timed task queue corresponding to a to-be-processed timed task type, sets the task queue in a memory, and waits for fixed-point execution. When a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, according to a trigger rule corresponding to the queue type of the timed task queue, the task execution module 1203 is called to execute the to-be-processed timed task according to the message consumption method of the service side server. The service side realizes the corresponding method by bearing the corresponding Java class, namely directly taking the execution parameters in the timing task and carrying out service processing.
It should be noted that, when the timed task server 110 includes a first timed task server and a second timed task server, the business side server 120 may respond to the selection or configuration operation of the deployment form, so that the timed task server 110 provides the timed task processing service according to the deployment form of the timed task server selected by the business side. The timed task server 110 may be configured with a monitoring module for monitoring a processing cycle of a to-be-processed timed task of the timed task server, and when any timed task processing link has a problem, a fault prompt may be performed, so as to facilitate operation and maintenance of the timed task server.
Fig. 4 shows an exemplary flow of a timed task processing method, which may be applied to a timed task server, and the method may include steps S401 to S404:
step S401, the timing task to be processed is obtained from the timing task database.
In the embodiment of the present disclosure, the timed task server may include a timed task database, where the timed task database is used to store the to-be-processed timed task of the service party, and the timed task database may include fields such as task identifier, execution time, and task content. The timing task server can respond to the updating operation of the service party server on the timing task database to obtain the timing task to be processed when detecting the calling operation of the service party server on the timing task database. And generating a new event in a log file of the timed task database, and recording the updating operation of the timed task database. The log file may be a Binlog log file, and the update operation may be an operation of newly adding a to-be-processed timed task in the timed task database, or an operation of modifying or deleting an existing to-be-processed timed task in the timed task database.
It should be noted that the execution time field in the timed task database may allow the service party to set the execution time with the precision of millisecond level, so as to meet the service scenario with high requirement on the precision of the execution time.
In this step S401, the process of acquiring the to-be-processed timed task from the timed task database may include: monitoring a log file of a timed task database; and when a new event is generated in the log file, acquiring the timing task to be processed from the timing task database according to the new event. The to-be-processed timed task updated in the timed task database can be immediately acquired after the timed task database is updated, and it should be noted that the log file of the timed task database can be monitored in real time through an NDC (network Data Canal) system.
The process of acquiring the to-be-processed timed task from the timed task database according to the new event may include: and determining a task identifier of a new event in the log file, and acquiring a to-be-processed timed task consistent with the task identifier from the timed task database according to the task identifier.
And step S402, determining the expected waiting time of the timing task to be processed.
In the embodiment of the present disclosure, after the to-be-processed timed task is obtained, the to-be-processed timed task needs to be added to the timed task queue corresponding to the type of the to-be-processed timed task, so as to prompt the service party to execute the to-be-processed timed task, in general, after the to-be-processed timed task is obtained, the to-be-processed timed task may be directly added to the corresponding timed task queue, but if the time difference between the execution time of the to-be-processed timed task and the current time is large, the to-be-processed timed task needs to stay in the timed task queue for a long time, and the timed task queue needs to consume resources to maintain the to-be-processed timed task, waste resources, and easily cause the jam of the.
In order to solve the above problem, in the embodiment of the present disclosure, a preset time threshold may be set, where the preset time threshold is a time condition for determining whether the acquired to-be-processed timed task needs to be added to the timed task queue. After the to-be-processed timed task is acquired, in this step S402, an expected waiting time of the to-be-processed timed task may be determined, where the expected waiting time is a time difference between an execution time of the to-be-processed timed task and a current time, so as to determine whether to add the to-be-processed timed task to a corresponding task queue according to the expected waiting time and a preset time threshold.
And S403, adding the to-be-processed timed task with the expected waiting time less than the preset time threshold to a timed task queue corresponding to the type of the to-be-processed timed task.
In this step S403, the to-be-processed timed task whose expected waiting time is less than the preset time threshold may be added to the timed task queue corresponding to the type of the to-be-processed timed task, where the preset time threshold may be determined based on actual needs, which is not limited in this embodiment of the disclosure. For example, the preset time threshold may be any time period between 15 minutes and 60 minutes. The to-be-processed timed tasks in the timed task queue are all to-be-executed to-be-processed timed tasks, and management of the to-be-processed timed tasks in the timed task queue is facilitated.
In an alternative embodiment, the process of adding the to-be-processed timed task with the expected waiting time less than the preset time threshold to the timed task queue corresponding to the to-be-processed timed task type may include: determining the task type of a timing task to be processed; determining a timing task queue corresponding to the task type; and adding the timing task to be processed to a timing task queue corresponding to the task type.
In an optional implementation manner, the timed task database may further include a task type field for recording a timed task type in a service scenario corresponding to the to-be-processed timed task, the service side server may configure the task type of the to-be-processed timed task when calling the timed task database and updating the to-be-processed timed task, and the timed task server may store the task type field of the to-be-processed timed task in the local database when acquiring the to-be-processed timed task from the timed task database. The process of determining the task type of the timing task to be processed may be: and determining the task type of the timing task to be processed by querying a local database.
In an optional implementation manner, in order to facilitate the classification management of the timing tasks of different service parties in different service scenarios, the timing task database in the timing task server may include not only different timing task databases corresponding to different service parties, but also different timing task databases corresponding to each timing task type in the same service party service scenario, and then the process of determining the task type of the timing task to be processed may be: and determining the task type of the timing task to be processed by determining the task type of a timing task database for storing the timing task to be processed.
It can be understood that, in the embodiment of the present disclosure, after sending the to-be-processed timed task whose expected waiting time is less than the preset time threshold to the timed task server, the to-be-processed timed task whose expected waiting time that has been added to the timed task queue is less than the preset time threshold needs to be removed from the local database.
Further, after the to-be-processed timing task with the expected waiting time smaller than the preset time threshold is removed from the local database, each to-be-processed timing task in the local database can be scanned according to a preset period; and when the expected waiting time of the timing task to be processed is less than a preset time threshold, adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed. After the to-be-processed timed task is obtained, the to-be-processed timed task with a large time difference between the execution time and the current time can be kept in the local database, and the data processing pressure of the timed task queue is reduced.
In an optional implementation manner, in this embodiment of the present disclosure, when a timed task server cluster is deployed, for different service scenarios, different types of timed task queues are used to store to-be-processed timed tasks, and isolation of timed task processing in different service scenarios is implemented at a timed task server layer, then in this step S403, a process of adding a to-be-processed timed task whose expected waiting time is less than a preset time threshold to a timed task queue corresponding to the to-be-processed timed task may include: determining a timing task queue corresponding to a timing task to be processed; determining a timing task server side which stores a timing task queue corresponding to a timing task to be processed; and adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed in the timing task server. The process of determining the timing task queue corresponding to the timing task to be processed may include: determining the task type of a timing task to be processed; a timed task queue corresponding to the task type is determined.
In an optional implementation manner, when the running environment of the timed task processing method includes a timed task server and a service side server, where the timed task server may be deployed in a cluster, where any timed task server is configured to add a to-be-processed timed task whose expected waiting time is less than a preset time threshold to a timed task queue corresponding to a type of the to-be-processed timed task, and the remaining timed task servers are configured with task queues.
In step S403, the process of adding, by any timed task server, the to-be-processed timed task whose expected waiting time is less than the preset time threshold to the timed task queue corresponding to the to-be-processed timed task type may include: determining a timing task queue corresponding to a timing task to be processed; determining a timing task server configured with a timing task queue corresponding to a timing task to be processed; and adding the to-be-processed timed task to a timed task queue corresponding to the to-be-processed timed task in the timed task server, wherein the timed task server configured with the timed task queue corresponding to the to-be-processed timed task refers to the timed task server used for storing the to-be-processed timed task with the same type as the type of the to-be-processed timed task.
In an optional implementation manner, when the running environment of the timed task processing method includes a first timed task server and a service side server, where the first timed task server is configured to send a to-be-processed timed task whose expected waiting time is less than a preset time threshold to the service side server, the service side server is configured with a task queue, and the service side server is configured to add the to-be-processed timed task whose expected waiting time is less than the preset time threshold to the timed task queue corresponding to the to-be-processed timed task type.
In step S403, the process of adding, by the service side server, the to-be-processed timed task whose expected waiting time is less than the preset time threshold to the timed task queue corresponding to the to-be-processed timed task type may include: determining a timing task queue corresponding to a timing task to be processed; and adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed in the service side server.
And step S404, when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, prompting the service party to execute the to-be-processed timed task according to a trigger rule corresponding to the queue type of the timed task queue.
In the embodiment of the present disclosure, the timed task queue is configured based on a service scene, and one task queue corresponds to one service scene, that is, service requirements of the service scene are met. A business scenario is an abstraction of a business type with similar characteristics. A task queue can support multiple timing task types in the same service scene, and the multiple timing tasks in the same service scene have similarity to the processing requirements of the timing tasks. For example, a service scenario a only needs to receive one notification message, so a timing task queue of a deduplication type can be constructed to support various timing task types under the scenario a, such as a song information change timing task; service scenario B: multiple timed task reminders need to be received, but the processing of each task has priority requirements, so that a timed task queue of a priority type can be constructed to support various timed task types in the scenario B, such as album release timed tasks. And one timing task type corresponds to an independent and isolated timing task queue, namely, a plurality of timing tasks in the same service scene all correspond to the same type of timing task queue, and different types of timing tasks are maintained by adopting different task queues, so that task isolation is realized from the service scene level and the task type level. In step S404, according to a trigger rule corresponding to a queue type of the timing task queue, a process of prompting a service party to execute the timing task to be processed may include the following optional implementation manners:
in an optional implementation manner, the timed task queue includes a first type of timed task queue, as shown in fig. 5, the process of prompting the service party to execute the to-be-processed timed task according to the trigger rule corresponding to the queue type of the timed task queue may include:
step S501, determining the trigger sequence of a plurality of to-be-processed timed tasks reaching the execution time in the first type timed task queue.
In this step S501, the process of determining the trigger sequence of the multiple to-be-processed timed tasks that reach the execution time in the first-class timed task queue may include: determining each to-be-processed timing task which reaches the execution time in the first type of timing task queue, adding a timestamp of the first type of timing task queue, and arranging a plurality of to-be-processed timing tasks according to the sequence of the timestamps from early to late to obtain the triggering sequence of the plurality of to-be-processed timing tasks; or arranging a plurality of to-be-processed timing tasks according to the sequence of the timestamps from late to early to obtain the triggering sequence of the plurality of to-be-processed timing tasks; or arranging the plurality of to-be-processed timing tasks according to a random sequence to obtain the triggering sequence of the plurality of to-be-processed timing tasks.
And step S502, sequentially prompting the service party to execute the timing tasks to be processed according to the triggering sequence.
In this step S502, the service party may be sequentially prompted to execute the to-be-processed timing tasks according to the trigger sequence, so that the service party sequentially executes each to-be-processed timing task according to the trigger sequence.
For example, since the song release timing task has no very strict time limit in the triggering process and belongs to a common task scenario, in the embodiment of the present disclosure, the song release timing task may be added to the first type timing task queue.
In an alternative implementation manner, the timing task queue includes a second type of timing task queue, as shown in fig. 6, the process of prompting the service party to execute the timing task to be processed according to the trigger rule corresponding to the queue type of the timing task queue may include:
step S601, determining task priorities of a plurality of to-be-processed timed tasks reaching the execution time in the second type timed task queue.
In the embodiment of the present disclosure, the timed task database may further include a task priority field for recording the priority of the to-be-processed timed task, and when the service side server calls the timed task database and updates the to-be-processed timed task, the priority of the to-be-processed timed task may be configured, and when the to-be-processed timed task is added to the second type timed task queue, the to-be-processed timed task may carry priority information thereof. Then in this step S601, the process of determining the task priority of each to-be-processed timing task may be: and determining the task priority of the timing task to be processed by analyzing each timing task to be processed.
And step S602, sequentially prompting the service party to execute the timing tasks to be processed according to the sequence of the task priority corresponding to each timing task to be processed from high to low.
In step S602, the service party may be sequentially prompted to execute the to-be-processed timed tasks according to the order of the task priority corresponding to each to-be-processed timed task from high to low, so that the service party sequentially executes each to-be-processed timed task according to the order of the task priority from high to low.
For example, in the triggering process of the album release timing task, the to-be-processed timing task with a higher priority needs to be triggered in priority according to the priority of the album, and belongs to a priority task scenario.
In an optional implementation manner, the timed task queue includes a third type of timed task queue, and the process of prompting the service party to execute the to-be-processed timed task according to the trigger rule corresponding to the queue type of the timed task queue may include: and selecting any one to-be-processed timing task from the plurality of to-be-processed timing tasks as the to-be-processed timing task, and prompting the service party to execute the to-be-processed timing task, wherein after the service party acquires prompt information about executing any one to-be-processed timing task, the service party can execute the plurality of to-be-processed timing tasks at the same execution time as any one to-be-processed timing task at one time.
For example, since the information change task generally belongs to a plurality of to-be-processed timing tasks of the same modification target (e.g., timing modification tasks of different fields of the same song, or timing modification tasks of different fields of the same album), when the execution time of the plurality of to-be-processed timing tasks is the same, any one of the to-be-processed timing tasks may be selected to trigger, and the service party is prompted to execute the plurality of to-be-processed timing tasks, and belongs to the deduplication task scenario, in the embodiment of the present disclosure, the information change task may be added to the third type timing task queue.
In an optional implementation manner, if the running environment of the timed task processing method includes a timed task server and a service side server, and the number of the timed task servers configured with the same type of timed task queue may include multiple ones, and when the execution time of the to-be-processed timed task is reached, each timed task server may obtain a processing identifier of the to-be-processed timed task, in this step S404, a process of prompting the service side to execute the to-be-processed timed task may include: the target timing task server prompts the service party to execute the timing task to be processed, wherein the target timing task server is the only timing task server which successfully acquires the processing identifier from the plurality of timing task servers configured with the timing task queues corresponding to the timing task to be processed, the processing identifier can be a distributed lock of the timing task to be processed, and the problem that the plurality of timing task servers all execute the process of prompting the service party to execute the timing task to be processed to cause resource waste can be avoided.
The process of prompting the service party to execute the timing task to be processed may include: generating prompt information about the timing task to be processed; sending prompt information about the timing task to be processed to a service side server of a service side; or sending the timing task to be processed to a service side server of the service side.
It can be understood that, in the embodiment of the present disclosure, if the running environment of the timed task processing method includes a timed task server and a service side server, for a plurality of to-be-processed timed tasks in the first type of timed task queue and the second type of timed task queue, it is necessary to send prompt information about each to-be-processed timed task one by one, or send each to-be-processed timed task one by one; for a plurality of to-be-processed timing tasks in the third type timing task queue, any to-be-processed timing task needs to be sent, or task prompt information is sent, and the prompt information is used for prompting the service side server to execute the plurality of to-be-processed timing tasks at the same time.
In an optional implementation manner, if the running environment of the timed task processing method includes the first timed task server and the service side server, in this step S404, the process of prompting the service side to execute the to-be-processed timed task may include: and the service side server calls the message consumption method of the service side to execute the timing task to be processed.
It can be understood that, in the embodiment of the present disclosure, if the running environment of the timed task processing method includes the first timed task server and the service side server, for the multiple to-be-processed timed tasks in the first type of timed task queue and the second type of timed task queue, the message consumption method of the service side needs to be called one by one to execute the to-be-processed timed tasks one by one; for a plurality of to-be-processed timing tasks in the third type of timing task queue, a message consumption method of a primary service side needs to be called to execute the plurality of to-be-processed timing tasks at one time.
To sum up, the timing task processing method provided by the embodiment of the present disclosure can obtain a to-be-processed timing task from a timing task database; determining the expected waiting time of the timing task to be processed; adding the timing task to be processed with the expected waiting time smaller than the preset time threshold value to a timing task queue corresponding to the type of the timing task to be processed; when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, prompting a business party to execute the to-be-processed timed tasks according to a trigger rule corresponding to the queue type of the timed task queue. When a large number of timing tasks to be processed need to be triggered and executed at the same time, the business side is prompted to execute the timing tasks efficiently and stably in time.
Exemplary devices
Having described the method of the exemplary embodiment of the present disclosure, the apparatus of the exemplary embodiment of the present disclosure will next be described with reference to fig. 7.
The embodiment of the present disclosure provides a timed task processing apparatus, which may be applied to a timed task server, as shown in fig. 7, the timed task processing apparatus 700 includes:
an obtaining module 701 configured to obtain a to-be-processed timed task from a timed task database;
a determining module 702 configured to determine an expected waiting time of the timing task to be processed, where the expected waiting time is a time difference between an execution time of the timing task to be processed and a current time;
an adding module 703 configured to add a to-be-processed timed task whose expected waiting time is less than a preset time threshold to a timed task queue corresponding to the to-be-processed timed task;
and the triggering module 704 is configured to prompt the service party to execute the to-be-processed timed task according to a triggering rule corresponding to the queue type of the timed task queue when the plurality of to-be-processed timed tasks in the timed task queue simultaneously reach the execution time.
In an optional implementation manner, the timed task queues are configured based on service scenarios, one task queue corresponds to one service scenario, one task queue supports multiple timed task types in the same service scenario, and one timed task type corresponds to one independent and isolated timed task queue.
In an alternative embodiment, as shown in fig. 7, the timed task processing device 700 further includes:
a storage module 705 configured to store the to-be-processed timing task in a local database;
a removal module 706 configured to remove from the local database pending timed tasks that have been added to the timed task queue with an expected wait time less than a preset time threshold.
In an alternative embodiment, as shown in fig. 7, the timed task processing device 700 further includes:
a scanning module 707 configured to scan each to-be-processed timed task in the local database according to a preset period;
the adding module 703 is configured to add the to-be-processed timed task to the timed task queue corresponding to the to-be-processed timed task when the expected waiting time of the to-be-processed timed task is less than a preset time threshold.
In an alternative embodiment, the timed task queues include a first type of timed task queue, and the triggering module 704 is configured to:
determining a triggering sequence of a plurality of to-be-processed timed tasks reaching an execution time in a first type timed task queue;
and sequentially prompting the service party to execute the timing tasks to be processed according to the triggering sequence.
In an alternative embodiment, the timed task queues include a second type of timed task queue, and the triggering module 704 is configured to:
determining task priorities of a plurality of to-be-processed timed tasks reaching the execution time in the second type timed task queue;
and sequentially prompting the service party to execute the timing tasks to be processed according to the sequence of the task priority corresponding to each timing task to be processed from high to low.
In an alternative embodiment, the timed task queues include a third type of timed task queue, and the triggering module 704 is configured to:
and selecting any one to-be-processed timing task from the plurality of to-be-processed timing tasks as the to-be-processed timing task, and prompting the service party to execute the to-be-processed timing task.
In an alternative embodiment, as shown in fig. 7, the timed task processing device 700 further includes:
an obtaining module 701 configured to obtain a to-be-processed timed task and a task type of the to-be-processed timed task when a call operation to a timed task database is detected;
and the processing module 708 is configured to store the to-be-processed timed task in the timed task database, and generate a new event in a log file of the timed task database.
In an alternative embodiment, the obtaining module 701 is configured to:
monitoring a log file of a timed task database;
and when a new event is generated in the log file, acquiring the timing task to be processed from the timing task database according to the new event.
In an optional implementation, the adding module 703 is configured to:
determining the task type of a timing task to be processed;
determining a timing task queue corresponding to the task type;
and adding the timing task to be processed to a timing task queue corresponding to the task type.
In an optional implementation manner, the task queue is configured at the timed task server, and the adding module 703 is configured to:
determining a timing task queue corresponding to a timing task to be processed;
determining a timing task server configured with a timing task queue corresponding to a timing task to be processed;
and adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed in the timing task server.
In an optional implementation manner, the number of the timed task servers configured with the timed task queue corresponding to the to-be-processed timed task includes a plurality of timed task servers, and when the execution time of the to-be-processed timed task is reached, each timed task server acquires a processing identifier of the to-be-processed timed task;
the trigger module 704 of the target timed task server is configured to prompt the service party to execute the to-be-processed timed task, and the target timed task server is only one timed task server that successfully acquires the processing identifier from the plurality of timed task servers configured with the timed task queue corresponding to the to-be-processed timed task.
In an alternative embodiment, the triggering module 704 is configured to:
generating prompt information about the timing task to be processed;
sending prompt information about the timing task to be processed to a service party; alternatively, the first and second electrodes may be,
and sending the timing task to be processed to the service party.
In an optional implementation manner, the task queue is configured at the service side of the business, and the adding module 703 is configured to:
determining a timing task queue corresponding to a timing task to be processed;
and adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed in the service side server.
In an alternative embodiment, the triggering module 704 is configured to:
and calling the message consumption device of the service party to execute the timing task to be processed.
To sum up, the timing task processing device provided by the embodiment of the present disclosure can obtain a to-be-processed timing task from a timing task database; determining the expected waiting time of the timing task to be processed; adding the timing task to be processed with the expected waiting time smaller than the preset time threshold value to a timing task queue corresponding to the type of the timing task to be processed; when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, prompting a business party to execute the to-be-processed timed tasks according to a trigger rule corresponding to the queue type of the timed task queue. When a large number of timing tasks to be processed need to be triggered and executed at the same time, the service party is prompted to execute the timing tasks efficiently and stably in time.
In addition, other specific details of the embodiments of the present disclosure have been described in detail in the embodiments of the invention of the above method, and are not described herein again.
Exemplary storage Medium
The storage medium of the exemplary embodiment of the present disclosure is explained below.
In the present exemplary embodiment, the above-described method may be implemented by a program product, such as a portable compact disc read only memory (CD-ROM) and including program code, and may be executed on a device, such as a personal computer. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RE, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a local area network (FAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
Exemplary electronic device
An electronic device of an exemplary embodiment of the present disclosure is explained with reference to fig. 8.
The electronic device 800 shown in fig. 8 is only an example and should not bring any limitations to the functionality and scope of use of the embodiments of the present disclosure.
As shown in fig. 8, electronic device 800 is in the form of a general purpose computing device. The components of the electronic device 800 may include, but are not limited to: at least one processing unit 810, at least one memory unit 820, a bus 830 connecting the various system components (including the memory unit 820 and the processing unit 810), and a display unit 840.
Where the memory unit stores program code, the program code may be executed by the processing unit 810 to cause the processing unit 810 to perform steps according to various exemplary embodiments of the present disclosure as described in the "exemplary methods" section above in this specification. For example, the processing unit 810 may perform the method steps as shown in fig. 4-6, etc.
The storage unit 820 may include volatile storage units such as a random access storage unit (RAM)821 and/or a cache storage unit 822, and may further include a read only storage unit (ROM) 823.
Storage unit 820 may also include a program/utility 824 having a set (at least one) of program modules 825, such program modules 825 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 830 may include a data bus, an address bus, and a control bus.
The electronic device 800 may also communicate with one or more external devices 900 (e.g., keyboard, pointing device, bluetooth device, etc.), which may be through an input/output (I/O) interface 850. The electronic device 800 further comprises a display unit 840 connected to the input/output (I/O) interface 850 for displaying. Also, the electronic device 800 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet) via the network adapter 860. As shown, the network adapter 860 communicates with the other modules of the electronic device 800 via the bus 830. It should be appreciated that although not shown, other hardware and/or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
It should be noted that although in the above detailed description several modules or sub-modules of the apparatus are mentioned, such division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more of the units/modules described above may be embodied in one unit/module, in accordance with embodiments of the present disclosure. Conversely, the features and functions of one unit/module described above may be further divided into embodiments by a plurality of units/modules.
Further, while the operations of the disclosed methods are depicted in the drawings in a particular order, this does not require or imply that these operations must be performed in this particular order, or that all of the illustrated operations must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions.
While the spirit and principles of the present disclosure have been described with reference to several particular embodiments, it is to be understood that the present disclosure is not limited to the particular embodiments disclosed, nor is the division of aspects, which is for convenience only as the features in such aspects may not be combined to benefit. The disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims (10)

1. A method for processing a timed task is applied to a timed task server, and comprises the following steps:
acquiring a timing task to be processed from a timing task database;
determining the expected waiting time of the timing task to be processed, wherein the expected waiting time is the time difference between the execution time of the timing task to be processed and the current time;
adding the timing task to be processed with the expected waiting time smaller than the preset time threshold value to a timing task queue corresponding to the type of the timing task to be processed;
and when a plurality of to-be-processed timed tasks in the timed task queue reach the execution time at the same time, prompting a service party to execute the to-be-processed timed tasks according to a trigger rule corresponding to the queue type of the timed task queue.
2. The method of claim 1, wherein the timed task queues are configured based on business scenarios, one task queue corresponds to one business scenario, one task queue supports multiple timed task types in the same business scenario, and one timed task type corresponds to an independent and isolated timed task queue.
3. The method of claim 1, further comprising:
storing the timing task to be processed in a local database;
after adding the to-be-processed timed task with the expected waiting time smaller than the preset time threshold to the timed task queue corresponding to the to-be-processed timed task, the method further comprises the following steps:
and removing the timing tasks to be processed, which have been added to the timing task queue and the expected waiting time of which is less than a preset time threshold value, from the local database.
4. The method of claim 3, wherein after removing pending timed tasks having an expected wait time less than a preset time threshold from the local database, the method further comprises:
scanning each to-be-processed timing task in the local database according to a preset period;
and when the expected waiting time of the timing task to be processed is less than a preset time threshold, adding the timing task to be processed to a timing task queue corresponding to the timing task to be processed.
5. The method according to claim 2, wherein the timed task queue comprises a first type of timed task queue, and the prompting the service party to execute the to-be-processed timed task according to the trigger rule corresponding to the queue type of the timed task queue comprises:
determining a triggering sequence of a plurality of to-be-processed timed tasks reaching the execution time in the first type of timed task queue;
and sequentially prompting the service party to execute the timing tasks to be processed according to the trigger sequence.
6. The method according to claim 2, wherein the timed task queue comprises a second type of timed task queue, and the prompting, according to a trigger rule corresponding to a queue type of the timed task queue, a service party to execute the to-be-processed timed task comprises:
determining task priorities of a plurality of to-be-processed timed tasks reaching the execution time in the second type timed task queue;
and sequentially prompting a service party to execute the timing tasks to be processed according to the sequence of the task priority corresponding to each timing task to be processed from high to low.
7. The method according to claim 2, wherein the timed task queue comprises a third type of timed task queue, and the prompting, according to a trigger rule corresponding to a queue type of the timed task queue, a service party to execute the to-be-processed timed task comprises:
and selecting any one of the to-be-processed timing tasks as the to-be-processed timing task, and prompting a service party to execute the to-be-processed timing task.
8. A timed task processing device, which is applied to a timed task server, the device comprising:
the acquisition module is configured to acquire the timing task to be processed from the timing task database;
a determining module configured to determine an expected waiting time of the timing task to be processed, where the expected waiting time is a time difference between an execution time of the timing task to be processed and a current time;
the adding module is configured to add the timing task to be processed with the expected waiting time smaller than a preset time threshold value to a timing task queue corresponding to the timing task to be processed;
and the triggering module is configured to prompt a service party to execute the to-be-processed timed task according to a triggering rule corresponding to the queue type of the timed task queue when the to-be-processed timed tasks in the timed task queue simultaneously reach the execution time.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method of any one of claims 1 to 7.
10. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the method of any of claims 1 to 7 via execution of the executable instructions.
CN202110603563.XA 2021-05-31 2021-05-31 Timed task processing method and device, storage medium and electronic equipment Pending CN113238849A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110603563.XA CN113238849A (en) 2021-05-31 2021-05-31 Timed task processing method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110603563.XA CN113238849A (en) 2021-05-31 2021-05-31 Timed task processing method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN113238849A true CN113238849A (en) 2021-08-10

Family

ID=77135948

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110603563.XA Pending CN113238849A (en) 2021-05-31 2021-05-31 Timed task processing method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN113238849A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113760936A (en) * 2021-09-10 2021-12-07 杭州网易云音乐科技有限公司 Timing updating method, medium, device and electronic equipment
CN115297336A (en) * 2022-07-06 2022-11-04 北京达佳互联信息技术有限公司 Task processing method and device, electronic equipment, storage medium and program product

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107608770A (en) * 2017-08-08 2018-01-19 西安交大捷普网络科技有限公司 Multi-task Concurrency performs processing method
CN110196761A (en) * 2019-04-15 2019-09-03 北京达佳互联信息技术有限公司 Delay task processing method and processing device
CN111045813A (en) * 2019-12-27 2020-04-21 京北方信息技术股份有限公司 Task distribution system and method
CN111221638A (en) * 2020-01-03 2020-06-02 北京字节跳动网络技术有限公司 Scheduling processing method, device, equipment and medium for concurrent tasks

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107608770A (en) * 2017-08-08 2018-01-19 西安交大捷普网络科技有限公司 Multi-task Concurrency performs processing method
CN110196761A (en) * 2019-04-15 2019-09-03 北京达佳互联信息技术有限公司 Delay task processing method and processing device
CN111045813A (en) * 2019-12-27 2020-04-21 京北方信息技术股份有限公司 Task distribution system and method
CN111221638A (en) * 2020-01-03 2020-06-02 北京字节跳动网络技术有限公司 Scheduling processing method, device, equipment and medium for concurrent tasks

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113760936A (en) * 2021-09-10 2021-12-07 杭州网易云音乐科技有限公司 Timing updating method, medium, device and electronic equipment
CN113760936B (en) * 2021-09-10 2024-04-05 杭州网易云音乐科技有限公司 Timing updating method, medium, device and electronic equipment
CN115297336A (en) * 2022-07-06 2022-11-04 北京达佳互联信息技术有限公司 Task processing method and device, electronic equipment, storage medium and program product
CN115297336B (en) * 2022-07-06 2024-03-19 北京达佳互联信息技术有限公司 Task processing method and device, electronic equipment, storage medium and program product

Similar Documents

Publication Publication Date Title
EP3637733B1 (en) Load balancing engine, client, distributed computing system, and load balancing method
US8185624B2 (en) Efficient on-demand provisioning of servers for specific software sets
US8112659B2 (en) Reducing recovery time for business organizations in case of disasters
US11526386B2 (en) System and method for automatically scaling a cluster based on metrics being monitored
CN110825535B (en) Job scheduling method and system
US20110022861A1 (en) Reducing power consumption in data centers having nodes for hosting virtual machines
US11218386B2 (en) Service ticket escalation based on interaction patterns
US11689641B2 (en) Resiliency control engine for network service mesh systems
US11314554B2 (en) System and method for grouping nodes by analyzing and associating nodes of a computer system by shared characteristics
CN113238849A (en) Timed task processing method and device, storage medium and electronic equipment
US20220413937A1 (en) Node management method, device and apparatus, storage medium, and system
US10305817B1 (en) Provisioning system and method for a distributed computing environment using a map reduce process
CN110750592A (en) Data synchronization method, device and terminal equipment
US20220182851A1 (en) Communication Method and Apparatus for Plurality of Administrative Domains
CN114356521A (en) Task scheduling method and device, electronic equipment and storage medium
CN114168297A (en) Method, device, equipment and medium for scheduling collection tasks
CN111046007A (en) Method, apparatus and computer program product for managing a storage system
US11461185B2 (en) Event processing
CN110795225B (en) Method and system for executing scheduling task
CN112463616A (en) Chaos testing method and device for Kubernetes container platform
CN110764882A (en) Distributed management method, distributed management system and device
US20230297970A1 (en) Intelligent scheduling of maintenance tasks to minimize downtime
CN113204434B (en) Planned task execution method and device based on k8s and computer equipment
US11902111B1 (en) Service status determination framework
CN108008966B (en) Resource updating method and 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