Distributed timed task scheduling method, system, server and program product

By introducing distributed design and highly available redundant design in the distributed timing task scheduling system, using load balancers and storage database clusters for task scheduling and storage, the problem that existing system performance is affected by a single server is solved, and the stability, scalability and reliability of the system are improved.

CN119493651BActive Publication Date: 2025-04-15RONG MING MICROELECTRONICS (JINAN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510082027.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-04-15
Estimated Expiration
2045-01-20

AI Technical Summary

Technical Problem

The performance of the existing distributed timing task scheduling system is affected by a single server and cannot be redundant, resulting in poor reliability and stability, poor scalability, and is not suitable for large-scale applications.

Method used

By introducing distributed design and highly available redundant designs into the distributed timing task scheduling system, the task scheduling and storage using load balancers and storage database clusters are ensured that timing tasks are redundantly backed up and load allocation between multiple servers.

Benefits of technology

Improves the stability, scalability and reliability of timed task scheduling, and is suitable for large-scale applications to ensure high availability and consistency of task execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119493651B_ABST
    Figure CN119493651B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computer technology, and provides a distributed scheduled task scheduling method, system, server and program product, which obtains a scheduled task creation request scheduled by a second load balancer in a target task cluster in at least one task cluster; binds the scheduled task to a time wheel in the first server according to the scheduled task creation request; and stores the scheduled task creation request in a storage database cluster of the target task cluster, the storage database cluster having notification and monitoring functions, and other servers of the target task cluster obtain the scheduled task creation request from the storage database cluster of the target task cluster after monitoring the scheduled task creation event; binds the scheduled task to the time wheel in other servers according to the scheduled task creation request, thereby increasing the distributed design of the system and the high-availability redundant design, and improving the stability, scalability and reliability of scheduled task scheduling.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a distributed timed task scheduling method, system, server and program product. Background Art

[0002] In various business scenarios, there are always some operations that need to be executed at a specified time point or at a fixed time interval. This requires a timing scheduling logic and a high-availability architecture to ensure the stability of task execution.

[0003] The architecture of the existing distributed timed task scheduling system is affected by the performance of a single server; it cannot perform redundant processing, and its reliability and stability are poor; it has poor scalability and is not suitable for large-scale applications. Summary of the invention

[0004] In order to solve or at least partially solve the above technical problems, the present application provides a distributed timed task scheduling method, system, server and program product, which can increase the distributed design and high-availability redundant design of the system, and improve the stability, scalability and reliability of timed task scheduling.

[0005] In a first aspect, the present application provides a distributed timed task scheduling method, which is applied to a first server in a distributed timed task scheduling system, wherein the distributed timed task scheduling system includes at least one task cluster, each task cluster includes a second load balancer, multiple servers and a storage database cluster, and the first server is any of the servers; the method includes:

[0006] Obtaining a scheduled task creation request scheduled by a second load balancer in a target task cluster in at least one task cluster;

[0007] Binding the scheduled task to the time wheel in the first server according to the scheduled task creation request;

[0008] And the scheduled task creation request is stored in the storage database cluster of the target task cluster, wherein the storage database cluster has notification and monitoring functions, can monitor the task creation event of the first server, and notify other servers in the target task cluster of the task creation event of the first server, so that after monitoring the scheduled task creation event, the other servers of the target task cluster obtain the scheduled task creation request from the storage database cluster of the target task cluster; and bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request.

[0009] In a second aspect, the present application provides a distributed timed task scheduling system, including: a first load balancer, multiple gateway devices, multiple task clusters, each task cluster including a second load balancer, multiple servers and a storage database cluster; wherein,

[0010] The first load balancer is used to receive a scheduled task creation request; and schedule the scheduled task creation request to a target gateway device among the multiple gateway devices;

[0011] The target gateway device is used to generate task identification information according to the scheduled task creation request; and forward the scheduled task creation request to the second load balancer of the target task cluster among the multiple task clusters according to the task identification information;

[0012] The second load balancer of the target task cluster is used to dispatch the scheduled task creation request to the first server among the multiple servers of the target task cluster;

[0013] The first server is used to bind the scheduled task to the time wheel in the first server according to the scheduled task creation request; and store the scheduled task creation request in the storage database cluster of the target task cluster;

[0014] The other servers of the target task cluster are used to listen to the scheduled task creation event of the first server; and after listening to the scheduled task creation event, obtain the scheduled task creation request from the storage database cluster of the target task cluster; and bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request.

[0015] In a third aspect, an embodiment of the present application further provides a server comprising a processor and a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include steps for the distributed timed task scheduling method as described in the first aspect.

[0016] In a fourth aspect, the embodiments of the present application further provide a computer-readable program product, wherein the computer program in the computer program product enables the computer to execute the aforementioned distributed timed task scheduling method when the computer program is executed by the computer.

[0017] In an implementation manner of the present application, a distributed scheduled task scheduling system includes at least one task cluster, each task cluster includes a second load balancer, multiple servers and a storage database cluster, the first server is any of the servers, and a scheduled task creation request scheduled by the second load balancer in a target task cluster in at least one task cluster is obtained through the first server; the scheduled task is bound to the time wheel in the first server according to the scheduled task creation request; and the scheduled task creation request is stored in the storage database cluster of the target task cluster, wherein the storage database cluster has notification and monitoring functions, can monitor the task creation event of the first server, and notify other servers in the target task cluster of the task creation event of the first server, so that other servers in the target task cluster obtain the scheduled task creation request from the storage database cluster of the target task cluster after monitoring the scheduled task creation event; binding the scheduled task to the time wheel in other servers according to the scheduled task creation request can increase the distributed design and high-availability redundant design of the system, and improve the stability, scalability and reliability of scheduled task scheduling. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the implementation of the present application, the following is a brief introduction to the relevant drawings. It is understood that the drawings described below are only used to illustrate some implementations of the present application, and those skilled in the art can also obtain many other technical features and connection relationships not mentioned in this document based on these drawings.

[0019] Figure 1 A flow chart of a distributed timed task scheduling method provided in an embodiment of the present application;

[0020] Figure 2 A flowchart of another distributed scheduled task scheduling method provided in an embodiment of the present application;

[0021] Figure 3 A schematic diagram showing a multi-layer time wheel provided in an embodiment of the present application;

[0022] Figure 4 A schematic diagram of the structure of a distributed timed task scheduling system provided by an embodiment of the present application;

[0023] Figure 5 A schematic diagram of the structure of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0025] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0026] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0027] In various business scenarios, there are always some operations that need to be executed at a specified time point or at a fixed time interval. This requires a timing scheduling logic and a high-availability architecture to ensure the stability of task execution.

[0028] A common timed task scheduling solution is to use a simple timer. This method is relatively simple. If you want to perform an operation periodically, you only need to create a timer, set the time interval, set the callback function, and then let the system run it. This solution has no problem when there are fewer timers. However, if there are many timers and they have their own cycles, many timers will be generated, which will put a lot of pressure on the memory and CPU.

[0029] Another method is to use the task queue round-robin method. In order to solve the problem of too many timers, this method can only run one timer and put all the scheduled tasks into a queue. Each scheduled task saves its own timing information. The timer round-robin all the tasks in the queue at regular intervals. If the execution time of the task (time=0) has arrived, the task is handed over to other threads for execution. If the execution time of the task has not arrived (that is, time>0), the scheduled execution time (time) of the task is subtracted from the execution time interval of this timer, and the task is put back into the task queue again, waiting for the next round-robin of the timer. After the timer has finished round-robin training all the tasks in the queue, it will wait for a certain time interval before starting the next round-robin training. However, in this way, the timer needs to round-robin a large amount of data, and then find a small number of tasks that need to be executed, wasting a lot of CPU and memory resources.

[0030] You can also use the optimized task queue round-robin method. In order to solve the problem of too many tasks in the task queue and too much pressure on one timer, this method classifies tasks in a certain way, creates multiple timers, and puts tasks with the same cycle on the same timer. Each timer is only responsible for tasks within its own cycle and not for tasks in other cycles. In this way, the pressure on each timer will be greatly reduced. However, if this method is used, if each task is different, many timers will still be generated, and the problem of too many timers cannot be fundamentally solved.

[0031] You can also use a single time wheel method to set up a circular queue as a time wheel. Each element on the queue is called a slot. The time corresponding to each slot is unique in the time wheel. Each slot contains a task queue and maintains a pointer. The pointer points to a certain slot, indicating that the execution time of the slot has arrived, and the task in the task queue in the slot will be executed. When a task is inserted into the time wheel, the slot will be determined according to the current time and its own execution time cycle. The next step is to wait for the pointer to point to this slot, and the task will be triggered. However, using this method, the maximum processing cycle is limited. If the time span of the scheduled task is too long, a larger time wheel needs to be designed. If the scheduled tasks are too concentrated, the amount of data in a certain slot will be large, and a bottleneck problem caused by traversal will occur. If the number of tasks is small, a large time span will take up too much memory space.

[0032] You can also use multiple time rounds, such as Figure 3The figure shows a schematic diagram of a multi-layer time wheel. The multi-layer time wheel is to divide the time wheel into multiple parts, each of which is a carry relationship, such as seconds, minutes, and hours, that is: on the second-level time wheel, there are 60 slots, and the time between each two slots is 1s; on the minute-level time wheel, there are 60s slots, and the time between each two slots is 1min; on the hour-level time wheel, there are 24 slots, and the time between each two slots is 1h. In this way, every time the second level moves 60 slots, one minute has passed, the second-level time wheel returns to zero, and the graded time wheel moves one slot; every time the graded time wheel moves 60 slots, one hour has passed, the graded time wheel returns to zero, and the hour-level time wheel moves one slot. The execution process of using multiple time wheels: when creating a scheduled task, bind the scheduled task to the hour-level time wheel according to the time information to be executed. When the pointer on the hourly time wheel moves to the next slot, the corresponding task queue has reached its hourly execution time. At this time, these tasks need to be transferred to the next-level minute-level time wheel and inserted into the task queue in the slot according to their minute-level execution time. When the pointer on the minute-level time wheel points to the next slot, the corresponding task queue needs to be transferred to the second-level time wheel and inserted into the task queue of the corresponding slot according to the second-level execution time. When the pointer on the second-level time wheel points to the next slot, the task to be executed is placed in the asynchronous execution thread queue, and then the task is scheduled regularly.

[0033] However, the architecture of the existing distributed timed task scheduling system is affected by the performance of a single server; it cannot perform redundant processing, and its reliability and stability are poor; it has poor scalability and is not suitable for large-scale applications.

[0034] The technical solutions in the embodiments of the present application will be described in detail below in conjunction with the drawings in the embodiments of the present application.

[0035] Embodiment 1

[0036] like Figure 1 As shown, Figure 1 A structural diagram of a distributed timed task scheduling system provided by an embodiment of the present application. An embodiment of the present application proposes a distributed timed task scheduling system, including a first load balancer 100, multiple gateway devices 200, and multiple task clusters 300, each task cluster including a second load balancer 310, multiple servers 320 and a storage database cluster 330:

[0037] The first load balancer 100 is used to receive a scheduled task creation request; schedule the scheduled task creation request to a target gateway device 200 among the multiple gateway devices;

[0038] The target gateway device 200 is used to generate task identification information according to the scheduled task creation request; and forward the scheduled task creation request to the second load balancer 310 of the target task cluster among the multiple task clusters according to the task identification information;

[0039] The second load balancer 310 of the target task cluster is used to dispatch the scheduled task creation request to the first server among the multiple servers 320 of the target task cluster;

[0040] The first server is used to bind the scheduled task to the time wheel in the first server according to the scheduled task creation request; and store the scheduled task creation request in the storage database cluster of the target task cluster;

[0041] The other servers of the target task cluster are used to listen to the scheduled task creation event of the first server; and after listening to the scheduled task creation event, obtain the scheduled task creation request from the storage database cluster of the target task cluster; and bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request.

[0042] The first load balancer 100 receives a scheduled task creation request; and schedules the scheduled task creation request to a target gateway device 200 among the multiple gateway devices according to a scheduling algorithm.

[0043] Optionally, in terms of scheduling the scheduled task creation request to a target gateway device among the multiple gateway devices, the first load balancer is specifically used to adopt any one of the following scheduling algorithms: a polling algorithm, a weighted polling algorithm, a source address hash algorithm, and a target address hash algorithm.

[0044] Specifically, a polling algorithm is adopted, and the first load balancer distributes the received scheduled task creation requests to the gateway devices in turn in order, evenly distributing the requests without considering the number of connections and load conditions of the gateway devices. A weighted polling algorithm is adopted, and different weights can be given according to the processing capabilities of the gateway devices, and gateway devices with good performance are allocated more scheduled task creation requests. A source address hash algorithm is adopted, and the corresponding gateway device is found from the statically allocated hash table based on the source IP address of the request as the hash key. A target address hash algorithm is adopted, and the corresponding gateway device is found from the statically allocated hash table based on the target IP address of the request as the hash key. Requests sent to the same target address are always forwarded to the gateway device scheduled for the first time.

[0045] The target gateway device 200 can generate task identification information according to the ID generation algorithm, which may include a distributed ID generation algorithm or a hash algorithm to generate a task ID, and according to the last digit or digits of the task ID, according to the configuration rules of the prior system (for example: if the last digit is a number from 0 to 9, it is forwarded to the first task cluster 1), forward the scheduled task creation request to the second load balancer of a task cluster (target task cluster) on the back end.

[0046] Furthermore, the second load balancer 310 of the target task cluster may use a scheduling algorithm to schedule the scheduled task creation request to one of the multiple servers 320 of the target task cluster, such as the first server.

[0047] The scheduling algorithm adopted by the second load balancer 310 may be any one of the following: a polling algorithm, a weighted polling algorithm, a source address hash algorithm, and a target address hash algorithm.

[0048] Specifically, a polling algorithm is adopted, and the second load balancer distributes the received scheduled task creation requests to the servers in turn in order, evenly distributing the requests without considering the number of server connections and load conditions. A weighted round-robin algorithm is adopted, and different weights can be given according to the processing capabilities of the servers, and servers with good performance are allocated more scheduled task creation requests. A source address hash algorithm is adopted, and the corresponding server is found from the statically allocated hash table based on the source IP address of the request as the hash key. A target address hash algorithm is adopted, and the corresponding server is found from the statically allocated hash table based on the target IP address of the request as the hash key. Requests sent to the same target address are always forwarded to the server scheduled for the first time.

[0049] The first server binds the scheduled task to the time wheel in the first server according to the scheduled task creation request, so that the timer on the first server can be timed and execute the scheduled task according to the execution time of the scheduled task; the first server stores the scheduled task creation request in the storage database cluster of the target task cluster.

[0050] The storage database cluster has monitoring and notification functions. The storage database cluster (kv store cluster) will actively send notifications to other servers that monitor this event.

[0051] The general process of the monitoring mechanism of the storage database cluster is as follows:

[0052] A1. When all servers are started, they register a monitoring event with the storage database cluster and inform the storage database cluster to specify the key indicators of certain characteristics to monitor. The key indicators can be represented by keys (such as: the key prefix is ​​xxx), and maintain a long link, waiting to receive event notifications from the storage database cluster.

[0053] A2. When a server calls the storage database cluster and creates the key of this feature (for example, creates the key of xxx_123), the storage database cluster queries which servers listen to the key of this feature, and then actively sends event notifications of the key of this feature to these servers.

[0054] Specifically, other servers in the target task cluster (such as the second server and the third server) are used to monitor the scheduled task creation event of the first server, and obtain information about the scheduled task creation event from the storage database cluster; and after monitoring the scheduled task creation event, obtain the scheduled task creation request from the storage database cluster of the target task cluster; bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request, so that redundant backup of the scheduled task is achieved. At this time, the scheduled task is on the time wheels of multiple servers in the target task cluster.

[0055] Optionally, when the execution time of the scheduled task is reached, the multiple servers of the target task cluster are respectively used to request a distributed lock;

[0056] If the first server among the multiple servers obtains the distributed lock, the first server is used to execute the scheduled task; after executing the scheduled task, the execution completion status information is stored in the storage database cluster of the target task cluster, and the distributed lock is released.

[0057] When the execution time is reached, the tasks on the three servers of the target task cluster start to execute the scheduled task almost at the same time. At this time, the three servers need to grab a global distributed lock for this scheduled task. The three servers that grab the distributed lock execute the scheduled task, and the servers that do not grab the lock enter the lock waiting state. For example, if the first server grabs the lock, the first server will execute the scheduled task, and the other two servers will enter the lock waiting state. When the first server completes the execution, the execution completion status information is stored in the storage database cluster and the distributed lock is released.

[0058] Optionally, if other servers among the multiple servers fail to acquire the distributed lock, the other servers are configured to enter a lock wait state;

[0059] After other servers among the multiple servers release the distributed lock, the other servers are used to re-request the distributed lock;

[0060] If other servers obtain the distributed lock and obtain the execution completion status information from the storage database cluster of the target task cluster, then the execution of the scheduled task is exited;

[0061] If other servers obtain the distributed lock but fail to obtain the execution completion status information from the storage database cluster of the target task cluster, the scheduled task is executed.

[0062] Among them, other servers that are waiting for the lock will reacquire the distributed lock, and then obtain the status of this task from the storage database cluster. If this task has been completed, it will exit the execution; if the first server execution fails, the server that obtains the lock for the second time will continue to execute, ensuring that the task is executed reliably.

[0063] For example, a scheduled task is created to be executed at 8 o'clock. The task content is: query Baidu once and save the query results. When it reaches 8 o'clock, three servers start this task at the same time. Only one server can execute this task. In order to ensure that only one server executes, a distributed lock is needed to assist. Specific process: When the time reaches 8 o'clock, the three servers start initialization execution at the same time (initialization process and other preparations); then the three servers need to grab the distributed lock, but in the end only one server will succeed in grabbing the lock, and the other two will fail; the server that grabs the lock continues to execute the code, and the server that does not grab the lock enters the lock waiting; the server that grabs the lock executes: query Baidu, save the query results, update the status of this task to successful execution, and release the distributed lock; the other two servers that did not grab the lock, at this time, grab the distributed lock again, and eventually one server will grab the lock, and the other one that did not grab the lock will continue to wait for the lock; the server that grabs the lock first queries the latest status of the task. If the status is successful, it releases the lock and exits after the process ends; the last server starts to execute the lock grabbing operation and grabs the lock, because at this time only this server grabs the lock, and the processes of the other two servers have already exited, and then this server executes the operations after grabbing the lock and finally exits. In the end, this task was successfully executed only once by one server.

[0064] In an implementation manner of the present application, a distributed scheduled task scheduling system includes a first load balancer, multiple gateway devices, and multiple task clusters, each task cluster includes a second load balancer, multiple servers and a storage database cluster, and the first load balancer is used to receive a scheduled task creation request; schedule the scheduled task creation request to a target gateway device among the multiple gateway devices; the target gateway device is used to generate task identification information according to the scheduled task creation request; and forward the scheduled task creation request to a second load balancer of a target task cluster among the multiple task clusters according to the task identification information; the second load balancer of the target task cluster is used to schedule the scheduled task creation request to multiple servers of the target task cluster on a first server among the servers; the first server is used to bind the scheduled task to the time wheel in the first server according to the scheduled task creation request; and the scheduled task creation request is stored in the storage database cluster of the target task cluster; other servers of the target task cluster are used to listen to the scheduled task creation event of the first server; and after listening to the scheduled task creation event, obtain the scheduled task creation request from the storage database cluster of the target task cluster; binding the scheduled task to the time wheel in the other servers according to the scheduled task creation request can increase the distributed design of the system and the high-availability redundant design, and improve the stability, scalability and reliability of scheduled task scheduling.

[0065] Embodiment 2

[0066] like Figure 2 As shown, an embodiment of the present application proposes a distributed timed task scheduling method, which is applied to a first server in a distributed timed task scheduling system, wherein the distributed timed task scheduling system includes at least one task cluster, each task cluster includes a second load balancer, multiple servers and a storage database cluster, and the first server is any of the servers; Figure 2 A schematic diagram of a distributed scheduled task scheduling method provided in an embodiment of the present application, the method comprising:

[0067] 101. Obtain a scheduled task creation request scheduled by a second load balancer in a target task cluster in at least one task cluster.

[0068] In a specific implementation, the second load balancer of the target task cluster may use a scheduling algorithm to schedule the scheduled task creation request to one of the multiple servers of the target task cluster, such as the first server.

[0069] The scheduling algorithm adopted by the second load balancer may be any one of the following: a round-robin algorithm, a weighted round-robin algorithm, a source address hash algorithm, and a target address hash algorithm.

[0070] Specifically, a polling algorithm is adopted, and the second load balancer distributes the received scheduled task creation requests to the servers in turn in order, evenly distributing the requests without considering the number of server connections and load conditions. A weighted round-robin algorithm is adopted, and different weights can be given according to the processing capabilities of the servers, and servers with good performance are allocated more scheduled task creation requests. A source address hash algorithm is adopted, and the corresponding server is found from the statically allocated hash table based on the source IP address of the request as the hash key. A target address hash algorithm is adopted, and the corresponding server is found from the statically allocated hash table based on the target IP address of the request as the hash key. Requests sent to the same target address are always forwarded to the server scheduled for the first time.

[0071] 102. Bind the scheduled task to the time wheel in the first server according to the scheduled task creation request.

[0072] The first server binds the scheduled task to the time wheel in the first server according to the scheduled task creation request, so that the timer on the first server can be timed and execute the scheduled task according to the execution time of the scheduled task.

[0073] 103. Store the scheduled task creation request in the storage database cluster of the target task cluster.

[0074] Among them, the storage database cluster has notification and monitoring functions, which can monitor the task creation event of the first server and notify other servers in the target task cluster of the task creation event of the first server, so that after monitoring the scheduled task creation event, the other servers of the target task cluster obtain the scheduled task creation request from the storage database cluster of the target task cluster; and bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request.

[0075] The first server stores the scheduled task creation request in the storage database cluster of the target task cluster.

[0076] The storage database cluster has monitoring and notification functions. The storage database cluster (kv store cluster) will actively send notifications to other servers that monitor this event.

[0077] The general process of the monitoring mechanism of the storage database cluster is as follows:

[0078] A1. When all servers are started, they register a listening event with the storage database cluster and inform the storage database cluster to specify the key indicator key of certain characteristics to be listened (for example, the key prefix is ​​xxx), and maintain a long link, waiting to receive event notifications from the storage database cluster.

[0079] A2. When a server calls the storage database cluster and creates the key of this feature (for example, creates the key of xxx_123), the storage database cluster queries which servers listen to the key of this feature, and then actively sends event notifications of the key of this feature to these servers.

[0080] Specifically, other servers in the target task cluster (such as the second server and the third server) are used to monitor the scheduled task creation event of the first server, and obtain information about the scheduled task creation event from the storage database cluster; and after monitoring the scheduled task creation event, obtain the scheduled task creation request from the storage database cluster of the target task cluster; bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request, so that redundant backup of the scheduled task is achieved. At this time, the scheduled task is on the time wheels of multiple servers in the target task cluster.

[0081] In an embodiment of the present application, a distributed scheduled task scheduling system includes at least one task cluster, each task cluster includes a second load balancer, multiple servers and a storage database cluster, the first server is any of the servers, and a scheduled task creation request scheduled by the second load balancer in a target task cluster in at least one task cluster is obtained through the first server; the scheduled task is bound to the time wheel in the first server according to the scheduled task creation request; and the scheduled task creation request is stored in the storage database cluster of the target task cluster, wherein the storage database cluster has notification and monitoring functions, can monitor the task creation event of the first server, and notify other servers in the target task cluster of the task creation event of the first server, so that other servers in the target task cluster obtain the scheduled task creation request from the storage database cluster of the target task cluster after monitoring the scheduled task creation event; binding the scheduled task to the time wheel in other servers according to the scheduled task creation request can increase the distributed design and high-availability redundant design of the system, and improve the stability, scalability and reliability of scheduled task scheduling.

[0082] The distributed scheduled task scheduling system further includes a first load balancer and at least one gateway device; the scheduled task creation request is scheduled to the first server in the following manner:

[0083] The first load balancer receives a scheduled task creation request; schedules the scheduled task creation request to a target gateway device in the at least one gateway device;

[0084] The target gateway device generates task identification information according to the scheduled task creation request; and forwards the scheduled task creation request to the second load balancer of the target task cluster among the multiple task clusters according to the task identification information;

[0085] The second load balancer of the target task cluster dispatches the scheduled task creation request to a first server among the at least one server of the target task cluster.

[0086] The first load balancer receives a scheduled task creation request; and schedules the scheduled task creation request to a target gateway device among the multiple gateway devices according to a scheduling algorithm.

[0087] Optionally, in terms of scheduling the scheduled task creation request to a target gateway device among the multiple gateway devices, the first load balancer is specifically used to adopt any one of the following scheduling algorithms: a polling algorithm, a weighted polling algorithm, a source address hash algorithm, and a target address hash algorithm.

[0088] Specifically, a polling algorithm is adopted, and the first load balancer distributes the received scheduled task creation requests to the gateway devices in turn in order, evenly distributing the requests without considering the number of connections and load conditions of the gateway devices. A weighted polling algorithm is adopted, and different weights can be given according to the processing capabilities of the gateway devices, and gateway devices with good performance are allocated more scheduled task creation requests. A source address hash algorithm is adopted, and the corresponding gateway device is found from the statically allocated hash table based on the source IP address of the request as the hash key. A target address hash algorithm is adopted, and the corresponding gateway device is found from the statically allocated hash table based on the target IP address of the request as the hash key. Requests sent to the same target address are always forwarded to the gateway device scheduled for the first time.

[0089] The target gateway device can generate task identification information according to the ID generation algorithm. The ID generation algorithm may include a distributed ID generation algorithm or a hash algorithm to generate a task ID, and according to the last digit or digits of the task ID, according to the configuration rules of the prior system (for example: if the last digit is a number from 0 to 9, it is forwarded to the first task cluster 1), the scheduled task creation request is forwarded to the second load balancer of a certain task cluster (target task cluster) on the back end.

[0090] Furthermore, the second load balancer of the target task cluster may use a scheduling algorithm to schedule the scheduled task creation request to one of the multiple servers of the target task cluster, such as the first server.

[0091] Optionally, the method further comprises:

[0092] When the execution time of the scheduled task is reached, request a distributed lock;

[0093] If the distributed lock is successfully acquired, the scheduled task is executed;

[0094] After the scheduled task is executed, the execution completion status information is stored in the storage database cluster of the target task cluster, and the distributed lock is released.

[0095] Among them, when the execution time is reached, the tasks on the three servers of this target task cluster start to execute this scheduled task almost at the same time. At this time, the three servers need to grab a global distributed lock for this scheduled task. The three servers that grab the distributed lock execute this scheduled task, and the servers that do not grab the lock enter the lock waiting state. For example, if the first server grabs the lock, the first server will execute this scheduled task, and the other two servers will enter the lock waiting state. When the first server completes the execution, the execution completion status information is stored in the storage database cluster and the distributed lock is released.

[0096] Optionally, the method further comprises:

[0097] If the distributed lock is not acquired, enter the lock waiting state;

[0098] After other servers among the multiple servers release the distributed lock, re-requesting the distributed lock;

[0099] If the distributed lock is successfully acquired and the execution completion status information is obtained from the storage database cluster of the target task cluster, the execution of the scheduled task is exited;

[0100] If the distributed lock is successfully acquired, but the execution completion status information is not acquired from the storage database cluster of the target task cluster, the scheduled task is executed.

[0101] If the distributed lock is not acquired, the server enters the lock waiting state; the server in the lock waiting state re-requests the distributed lock after other servers among the multiple servers release the distributed lock;

[0102] If the distributed lock is successfully acquired and the execution completion status information is obtained from the storage database cluster of the target task cluster, indicating that the task has been completed, the first server exits the execution of the scheduled task;

[0103] If the distributed lock is successfully acquired, but the execution completion status information is not obtained from the storage database cluster of the target task cluster, indicating that other servers have errors in executing tasks, the scheduled task is executed to ensure that the task is reliably executed.

[0104] For example, a scheduled task is created to be executed at 8 o'clock. The task content is: query Baidu once and save the query results. When it reaches 8 o'clock, three servers start this task at the same time. Only one server can execute this task. In order to ensure that only one server executes, a distributed lock is needed to assist. Specific process: When the time reaches 8 o'clock, the three servers start initialization execution at the same time (initialization process and other preparations); then the three servers need to grab the distributed lock, but in the end only one server will succeed in grabbing the lock, and the other two will fail; the server that grabs the lock continues to execute the code, and the server that does not grab the lock enters the lock waiting; the server that grabs the lock executes: query Baidu, save the query results, update the status of this task to successful execution, and release the distributed lock; the other two servers that did not grab the lock, at this time, grab the distributed lock again, and eventually one server will grab the lock, and the other one that did not grab the lock will continue to wait for the lock; the server that grabs the lock first queries the latest status of the task. If the status is successful, it releases the lock and exits after the process ends; the last server starts to execute the lock grabbing operation and grabs the lock, because at this time only this server grabs the lock, and the processes of the other two servers have already exited, and then this server executes the operations after grabbing the lock and finally exits. In the end, this task was successfully executed only once by one server.

[0105] Optionally, the time wheel is a multi-layer time wheel, and the step of binding the scheduled task to the time wheel in the first server according to the scheduled task creation request includes:

[0106] Binding the scheduled task to the task queue corresponding to the first-layer time wheel in the first server according to the scheduled task creation request;

[0107] When the pointer on the first layer of time wheel moves to the next time slot, and the task queue corresponding to the time slot has reached the execution time, the scheduled task is bound to the task queue corresponding to the next layer of time wheel in the first server;

[0108] When the pointer on the next layer of time wheel moves to the next time slot and the task queue corresponding to the time slot has reached the execution time, the scheduled task is bound to the task queue corresponding to the next layer of time wheel in the first server until the scheduled task is bound to the task queue corresponding to the last layer of time wheel of the multi-layer time wheel.

[0109] like Figure 3The figure shows a schematic diagram of a multi-layer time wheel. The multi-layer time wheel is to divide the time wheel into multiple parts, each of which is a carry relationship, such as seconds, minutes, and hours, that is: on the second-level time wheel, there are 60 slots, and the time between each two slots is 1s; on the minute-level time wheel, there are 60s slots, and the time between each two slots is 1min; on the hour-level time wheel, there are 24 slots, and the time between each two slots is 1h. In this way, every time the second-level time wheel moves 60 slots, one minute has passed, the second-level time wheel returns to zero, and the graded time wheel moves one slot; every time the minute-level time wheel moves 60 slots, one hour has passed, the graded time wheel returns to zero, and the hour-level time wheel moves one slot. The execution process of using multiple time wheels: when creating a scheduled task, bind the scheduled task to the hour-level time wheel according to the time information to be executed. When the pointer on the hourly time wheel moves to the next slot, the corresponding task queue has reached its hourly execution time. At this time, these tasks need to be transferred to the next-level minute-level time wheel and inserted into the task queue in the slot according to their minute-level execution time. When the pointer on the minute-level time wheel points to the next slot, the corresponding task queue needs to be transferred to the second-level time wheel and inserted into the task queue of the corresponding slot according to the second-level execution time. When the pointer on the second-level time wheel points to the next slot, the task to be executed is placed in the asynchronous execution thread queue, and then the task is scheduled regularly.

[0110] Embodiment 3

[0111] Consistent with the above embodiment, Figure 4 As shown, an embodiment of the present application proposes a distributed timed task scheduling method, which is applied to a first server in a distributed timed task scheduling system, wherein the distributed timed task scheduling system includes at least one task cluster, each task cluster includes a second load balancer, multiple servers and a storage database cluster, and the first server is any of the servers; Figure 4 A flow chart of the steps of a distributed timed task scheduling method provided in an embodiment of the present application, the method comprising:

[0112] 201. Obtain a scheduled task creation request scheduled by a second load balancer in a target task cluster in at least one task cluster.

[0113] The distributed scheduled task scheduling system also includes a first load balancer and at least one gateway device; the scheduled task creation request is scheduled to the first server in the following manner: the first load balancer receives the scheduled task creation request; schedules the scheduled task creation request to a target gateway device in the at least one gateway device;

[0114] The target gateway device generates task identification information according to the scheduled task creation request; and forwards the scheduled task creation request to the second load balancer of the target task cluster among the multiple task clusters according to the task identification information;

[0115] The second load balancer of the target task cluster dispatches the scheduled task creation request to a first server among the at least one server of the target task cluster.

[0116] 202. Bind the scheduled task to the time wheel in the first server according to the scheduled task creation request.

[0117] 203. Store the scheduled task creation request in the storage database cluster of the target task cluster.

[0118] Among them, the storage database cluster has notification and monitoring functions, which can monitor the task creation event of the first server and notify other servers in the target task cluster of the task creation event of the first server, so that after monitoring the scheduled task creation event, the other servers of the target task cluster obtain the scheduled task creation request from the storage database cluster of the target task cluster; and bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request.

[0119] 204. When the execution time of the scheduled task is reached, request a distributed lock;

[0120] 205. If the distributed lock is successfully acquired, the scheduled task is executed.

[0121] 206. After the scheduled task is executed, the execution completion status information is stored in the storage database cluster of the target task cluster, and the distributed lock is released.

[0122] 207. If the distributed lock is not acquired, enter the lock waiting state.

[0123] 208. After other servers among the multiple servers release the distributed lock, re-request the distributed lock.

[0124] 209. If the distributed lock is successfully acquired and the execution completion status information is acquired from the storage database cluster of the target task cluster, the execution of the scheduled task is exited.

[0125] 210. If the distributed lock is successfully acquired, but the execution completion status information is not acquired from the storage database cluster of the target task cluster, the scheduled task is executed.

[0126] The tasks on multiple servers of the target task cluster start to execute this scheduled task almost at the same time. At this time, multiple servers need to grab a global distributed lock for this scheduled task. The first server that grabs the distributed lock executes the scheduled task, and the other servers that do not grab the lock enter the lock waiting state. For example, if the first server grabs the lock, the first server will execute this scheduled task, and the other two servers will enter the lock waiting state. When the first server completes the execution, the execution completion status information is stored in the storage database cluster and the distributed lock is released; if the distributed lock is not obtained, the lock waiting state is entered; the server in the lock waiting state re-requests the distributed lock after the other servers in the multiple servers release the distributed lock; if the distributed lock is successfully obtained and the execution completion status information is obtained from the storage database cluster of the target task cluster, indicating that the task has been completed, the first server exits the execution of the scheduled task; if the distributed lock is successfully obtained, but the execution completion status information is not obtained from the storage database cluster of the target task cluster, indicating that the other servers have errors in executing the task, the scheduled task is executed to ensure that the task is reliably executed, thereby ensuring that there is a server that can execute the scheduled task.

[0127] Embodiment 4

[0128] like Figure 4 As shown, Figure 4 A server provided in the embodiment of the present application is applied to the first server in a distributed timed task scheduling system, wherein the distributed timed task scheduling system includes at least one task cluster, each task cluster includes a second load balancer, multiple servers and a storage database cluster, and the first server is any of the servers; the server includes a processor 410 and a memory 420; and one or more programs, one or more programs are stored in the memory, and the memory 420 can be a high-speed RAM memory or a non-volatile memory, such as a disk memory. The memory 420 is used to store a set of program codes, and the processor 410 is used to call the program code stored in the memory 420 to perform the following operations:

[0129] Obtaining a scheduled task creation request scheduled by a second load balancer in a target task cluster in at least one task cluster;

[0130] Binding the scheduled task to the time wheel in the first server according to the scheduled task creation request;

[0131] The scheduled task creation request is stored in the storage database cluster of the target task cluster, wherein the storage database cluster has notification and monitoring functions, and is capable of monitoring the task creation event of the first server, and notifying other servers in the target task cluster of the task creation event of the first server, so that after monitoring the scheduled task creation event, the other servers of the target task cluster obtain the scheduled task creation request from the storage database cluster of the target task cluster; and bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request.

[0132] In a possible example, the distributed scheduled task scheduling system further includes a first load balancer and at least one gateway device; the scheduled task creation request is scheduled to the first server in the following manner:

[0133] The first load balancer receives a scheduled task creation request; schedules the scheduled task creation request to a target gateway device in the at least one gateway device;

[0134] The target gateway device generates task identification information according to the scheduled task creation request; and forwards the scheduled task creation request to the second load balancer of the target task cluster among the multiple task clusters according to the task identification information;

[0135] The second load balancer of the target task cluster dispatches the scheduled task creation request to a first server among the at least one server of the target task cluster.

[0136] In a possible example, the processor 410 is further configured to:

[0137] When the execution time of the scheduled task is reached, request a distributed lock;

[0138] If the distributed lock is successfully acquired, the scheduled task is executed;

[0139] After the scheduled task is executed, the execution completion status information is stored in the storage database cluster of the target task cluster, and the distributed lock is released.

[0140] In a possible example, the processor 410 is further configured to:

[0141] If the distributed lock is not acquired, enter the lock waiting state;

[0142] After other servers among the multiple servers release the distributed lock, re-requesting the distributed lock;

[0143] If the distributed lock is successfully acquired and the execution completion status information is obtained from the storage database cluster of the target task cluster, the execution of the scheduled task is exited;

[0144] If the distributed lock is successfully acquired, but the execution completion status information is not acquired from the storage database cluster of the target task cluster, the scheduled task is executed.

[0145] In a possible example, the time wheel is a multi-layer time wheel, and in binding the scheduled task to the time wheel in the first server according to the scheduled task creation request, the processor 410 is specifically configured to:

[0146] Binding the scheduled task to the task queue corresponding to the first-layer time wheel in the first server according to the scheduled task creation request;

[0147] When the pointer on the first layer of time wheel moves to the next time slot, and the task queue corresponding to the time slot has reached the execution time, the scheduled task is bound to the task queue corresponding to the next layer of time wheel in the first server;

[0148] When the pointer on the next layer of time wheel moves to the next time slot and the task queue corresponding to the time slot has reached the execution time, the scheduled task is bound to the task queue corresponding to the next layer of time wheel in the first server until the scheduled task is bound to the task queue corresponding to the last layer of time wheel of the multi-layer time wheel.

[0149] In an embodiment of the present application, a distributed scheduled task scheduling system includes at least one task cluster, each task cluster includes a second load balancer, multiple servers and a storage database cluster, the first server is any of the servers, and a scheduled task creation request scheduled by the second load balancer in a target task cluster in at least one task cluster is obtained through the first server; the scheduled task is bound to the time wheel in the first server according to the scheduled task creation request; and the scheduled task creation request is stored in the storage database cluster of the target task cluster, wherein the storage database cluster has notification and monitoring functions, can monitor the task creation event of the first server, and notify other servers in the target task cluster of the task creation event of the first server, so that other servers in the target task cluster obtain the scheduled task creation request from the storage database cluster of the target task cluster after monitoring the scheduled task creation event; binding the scheduled task to the time wheel in other servers according to the scheduled task creation request can increase the distributed design and high-availability redundant design of the system, and improve the stability, scalability and reliability of scheduled task scheduling.

[0150] The embodiments of the present application further provide a computer-readable program product storing program instructions, which, when executed by a computer, enable the computer to execute the aforementioned distributed timed task scheduling method.

[0151] The present application also provides a computer program product, wherein the computer program product includes a non-transient computer-readable program product storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in any of the distributed timed task scheduling methods described in the present application. The computer program product may be a software installation package.

[0152] Although the present application is described herein in conjunction with various embodiments, in the process of implementing the claimed application, those skilled in the art may understand and implement other changes to the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "one" or "an" does not exclude multiple situations. A single processor or other unit may implement several functions listed in a claim. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.

[0153] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices (equipment), or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The computer program is stored / distributed in a suitable medium, provided together with other hardware or as part of the hardware, or may take other distribution forms, such as through the Internet or other wired or wireless telecommunications systems.

[0154] The present application is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (devices) and computer program products of the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable human-vehicle trajectory analysis device to produce a machine, so that the instructions executed by the processor of the computer or other programmable human-vehicle trajectory analysis device generate instructions for implementing the processes in the process. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.

[0155] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable human-vehicle trajectory analysis device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0156] These computer program instructions can also be loaded onto a computer or other programmable vehicle trajectory analysis device, so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0157] Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, those skilled in the art may make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A distributed timed task scheduling method, characterized in that: A first server applied to a distributed timed task scheduling system, wherein the distributed timed task scheduling system includes at least one task cluster, each task cluster includes a second load balancer, a plurality of servers and a storage database cluster, and the first server is any of the servers; the method includes: Obtaining a scheduled task creation request scheduled by a second load balancer in a target task cluster in at least one task cluster; Binding the scheduled task to the time wheel in the first server according to the scheduled task creation request; The scheduled task creation request is stored in the storage database cluster of the target task cluster, wherein the storage database cluster has notification and monitoring functions, and is capable of monitoring the task creation event of the first server, and notifying other servers in the target task cluster of the task creation event of the first server, so that after monitoring the scheduled task creation event, the other servers of the target task cluster obtain the scheduled task creation request from the storage database cluster of the target task cluster; and bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request.

2. The distributed timed task scheduling method according to claim 1, characterized in that: The distributed scheduled task scheduling system further includes a first load balancer and at least one gateway device; the scheduled task creation request is dispatched to the first server in the following manner: The first load balancer receives a scheduled task creation request; schedules the scheduled task creation request to a target gateway device in the at least one gateway device; The target gateway device generates task identification information according to the scheduled task creation request; and forwards the scheduled task creation request to the second load balancer of the target task cluster among the multiple task clusters according to the task identification information; The second load balancer of the target task cluster dispatches the scheduled task creation request to a first server among the at least one server of the target task cluster.

3. The distributed timed task scheduling method according to claim 1, characterized in that: The method further comprises: When the execution time of the scheduled task is reached, request a distributed lock; If the distributed lock is successfully acquired, the scheduled task is executed; After the scheduled task is executed, the execution completion status information is stored in the storage database cluster of the target task cluster, and the distributed lock is released.

4. The distributed timed task scheduling method according to claim 3 is characterized in that: The method further comprises: If the distributed lock is not acquired, enter the lock waiting state; After other servers among the multiple servers release the distributed lock, re-requesting the distributed lock; If the distributed lock is successfully acquired and the target task cluster storage database cluster is obtained implement When the status information is completed, the execution of the scheduled task will be exited; If the distributed lock is successfully acquired, but the execution completion status information is not acquired from the storage database cluster of the target task cluster, the scheduled task is executed.

5. The distributed timed task scheduling method according to any one of claims 1 to 4, characterized in that: The time wheel is a multi-layer time wheel, and the step of binding the scheduled task to the time wheel in the first server according to the scheduled task creation request includes: Binding the scheduled task to the task queue corresponding to the first-layer time wheel in the first server according to the scheduled task creation request; When the pointer on the first layer of time wheel moves to the next time slot, and the task queue corresponding to the time slot has reached the execution time, the scheduled task is bound to the task queue corresponding to the next layer of time wheel in the first server; When the pointer on the next layer of time wheel moves to the next time slot and the task queue corresponding to the time slot has reached the execution time, the scheduled task is bound to the task queue corresponding to the next layer of time wheel in the first server until the scheduled task is bound to the task queue corresponding to the last layer of time wheel of the multi-layer time wheel.

6. A distributed timed task scheduling system, characterized in that: include: A first load balancer, a plurality of gateway devices, and a plurality of task clusters, each of which includes a second load balancer, a plurality of servers, and a storage database cluster; wherein, The first load balancer is used to receive a scheduled task creation request; and schedule the scheduled task creation request to a target gateway device among the multiple gateway devices; The target gateway device is used to generate task identification information according to the scheduled task creation request; and forward the scheduled task creation request to the second load balancer of the target task cluster among the multiple task clusters according to the task identification information; The second load balancer of the target task cluster is used to dispatch the scheduled task creation request to the first server among the multiple servers of the target task cluster; The first server is used to bind the scheduled task to the time wheel in the first server according to the scheduled task creation request; and store the scheduled task creation request in the storage database cluster of the target task cluster; The other servers of the target task cluster are used to listen to the scheduled task creation event of the first server; and after listening to the scheduled task creation event, obtain the scheduled task creation request from the storage database cluster of the target task cluster; and bind the scheduled task to the time wheel in the other servers according to the scheduled task creation request.

7. The distributed timed task scheduling system according to claim 6, characterized in that: When the execution time of the scheduled task is reached, the multiple servers of the target task cluster are respectively used to request a distributed lock; If a first server among the multiple servers acquires the distributed lock, the first server is used to execute the scheduled task; After the scheduled task is executed, the execution completion status information is stored in the storage database cluster of the target task cluster, and the distributed lock is released.

8. The distributed timed task scheduling system according to claim 7, characterized in that: If other servers among the multiple servers fail to obtain the distributed lock, the other servers are configured to enter a lock waiting state; After other servers among the multiple servers release the distributed lock, the other servers are used to re-request the distributed lock; If other servers obtain the distributed lock and obtain the execution completion status information from the storage database cluster of the target task cluster, then the execution of the scheduled task is exited; If other servers obtain the distributed lock but fail to obtain the execution completion status information from the storage database cluster of the target task cluster, the scheduled task is executed.

9. The distributed timed task scheduling system according to any one of claims 6 to 8, characterized in that: In terms of scheduling the scheduled task creation request to the target gateway device among the multiple gateway devices, the first load balancer is specifically used to adopt any one of the following scheduling algorithms: polling algorithm, weighted polling algorithm, source address hash algorithm, and target address hash algorithm.

10. The distributed timed task scheduling system according to any one of claims 6 to 8, characterized in that: The time wheel is a multi-layer time wheel. In the aspect of binding the scheduled task to the time wheel in the first server according to the scheduled task creation request, the first server is specifically used for: Binding the scheduled task to the task queue corresponding to the first-layer time wheel in the first server according to the scheduled task creation request; When the pointer on the first layer of time wheel moves to the next time slot, and the task queue corresponding to the time slot has reached the execution time, the scheduled task is bound to the task queue corresponding to the next layer of time wheel in the first server; When the pointer on the next layer of time wheel moves to the next time slot and the task queue corresponding to the time slot has reached the execution time, the scheduled task is bound to the task queue corresponding to the next layer of time wheel in the first server until the scheduled task is bound to the task queue corresponding to the last layer of time wheel of the multi-layer time wheel.

11. A server, characterized in that: It comprises a processor and a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include steps for a distributed timed task scheduling method as described in any one of claims 1 to 5.

12. A computer program product, characterized in that The computer program in the computer program product can implement the steps of the distributed timed task scheduling method according to any one of claims 1 to 5 when executed by a processor.

Citation Information

Patent Citations

  • Distributed timed task execution method and system

    CN105100259A

  • Load balancing method and device for batch tasks and computer equipment

    CN114048033A