A streaming task scheduling method, engine and system

Through the streaming task scheduling method and system, the problem that the existing task scheduling engine cannot meet the universal, reliable and efficient requirements is solved, the customization and fault tolerance of task scheduling are realized, and the system performance and reliability are improved.

CN118394485BActive Publication Date: 2024-09-06YUSYS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410805636.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-09-06
Estimated Expiration
2044-06-21

AI Technical Summary

Technical Problem

Existing task scheduling engines cannot meet the universal, reliable and efficient requirements, resulting in reduced application performance and reliability.

Method used

Provide a streaming task scheduling method and system that realizes task scheduling and execution by receiving task instances, verifying their validity, determining whether the run queue is full, and generating executable logic code based on user-defined business processing classes and command execution classes. Execution supports the validity check of task instances, the update of running queues and waiting queues, and uses the engine monitoring service for balanced distribution and fault handling of task instances.

Benefits of technology

It improves the reliability, scalability and performance of the system, reduces development complexity, allows users to customize business logic and task execution processes, and achieves rapid docking and fault-tolerance mechanisms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118394485B
    Figure CN118394485B
Patent Text Reader

Abstract

The present invention provides a streaming task scheduling method, engine and system, belonging to the field of software task scheduling, the method comprising: receiving a task instance and verifying the validity; if valid, when the running queue is not full, adding the task instance to the running queue, and when the running queue is full, adding the task instance to the waiting queue; for each task instance in the running queue, calling a user-defined business processing instance corresponding to the task instance, converting the user-defined business processing logic data in the task instance into an executable business processing logic code corresponding to the task instance; calling a user-defined command execution instance corresponding to the task instance, starting the execution of the user-defined task submission execution logic corresponding to the task instance, so as to execute the executable business processing logic code; removing the task instance whose user-defined task submission execution logic has been executed from the running queue, pulling the task instance from the waiting queue, and returning to the place where the validity of the task instance is verified for execution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software task scheduling, and in particular to a streaming task scheduling method, engine and system. Background Art

[0002] In the field of software applications, there are a large number of scenarios that require various types of task execution. As the complexity of software systems continues to increase, task queue engines have become one of the indispensable components in many applications. The task queue engine is responsible for managing and executing asynchronous tasks, which may involve background processing, scheduled tasks, messaging, etc. Its main goal is to improve the reliability, scalability and performance of the system while reducing the complexity for developers. Currently, many applications implement task queue functions in their own way, which leads to a lot of duplication of work and inconsistency.

[0003] With the rise of distributed systems and the popularity of cloud computing, a more universal, reliable, and efficient task queue engine is needed to meet the growing demand. Generally speaking, when developing applications, they will develop a customized task queue engine on their own. This engine is not universal, that is, the task queue engine developed by application A cannot be used by application B. When an application customizes its own task queue engine, due to a series of reasons such as the ability of technical personnel, project development cycle, and project cost, it cannot be guaranteed that a task queue engine with good performance and high reliability can be developed, resulting in reduced performance and reliability of its own application.

[0004] In the process of implementing the present invention, the applicant discovered that there are at least the following problems in the prior art: the existing task scheduling engine cannot meet the requirements of generality, reliability and efficiency. Summary of the invention

[0005] The embodiments of the present invention provide a streaming task scheduling method, engine and system to solve the problem that the existing task queue cannot meet the requirements of generality, reliability and efficiency.

[0006] In a first aspect, an embodiment of the present invention provides a streaming task scheduling method, comprising:

[0007] Receive the task instance of the task;

[0008] Verifying the validity of the task instance;

[0009] When the task instance is verified to be valid, determining whether the running queue is full; when determining that the running queue is not full, adding the task instance to the running queue, and when determining that the running queue is full, adding the task instance to the waiting queue;

[0010] For each task instance in the running queue, a user-defined business processing instance corresponding to the task instance is generated according to a preset user-defined business processing class, the user-defined business processing instance is called, and the user-defined business processing logic data in the task instance is converted into an executable business processing logic code corresponding to the task instance;

[0011] For each task instance in the running queue, a user-defined command execution instance corresponding to the task instance is generated according to a preset user-defined command execution class, and the executable business processing logic code corresponding to the task instance is used as a parameter to call the user-defined command execution instance to start the execution of the user-defined task submission execution logic corresponding to the task instance; wherein, the executable business processing logic code corresponding to the task instance is called to execute in the user-defined task submission execution logic corresponding to the task instance; the user-defined task submission execution logic is pre-configured in the user-defined command execution class; the user-defined task submission execution logic is used to define the execution process of the task corresponding to the corresponding task instance;

[0012] For the task instance whose execution logic has been completed in the user-defined task submission, the task instance is removed from the running queue, and the task instance is pulled from the waiting queue, and the step of verifying the validity of the task instance is jumped to execute;

[0013] The task instance includes: user-defined business processing logic data; the user-defined business processing logic data is used to describe the parameters required to generate executable business processing logic code.

[0014] In a second aspect, an embodiment of the present invention provides a streaming task scheduling engine, including:

[0015] A task instance receiving unit, used for receiving a task instance of a task;

[0016] A task verification unit, used to verify the validity of the task instance;

[0017] A queue interception unit is used to determine whether the running queue is full when verifying that the task instance is valid; when determining that the running queue is not full, add the task instance to the running queue; when determining that the running queue is full, add the task instance to the waiting queue;

[0018] A business logic execution unit is used to generate, for each task instance in the running queue, a user-defined business processing instance corresponding to the task instance according to a preset user-defined business processing class, call the user-defined business processing instance, and convert the user-defined business processing logic data in the task instance into an executable business processing logic code corresponding to the task instance;

[0019] A task submission execution unit is used to generate a user-defined command execution instance corresponding to each task instance in the running queue according to a preset user-defined command execution class, and to call the user-defined command execution instance with the executable business processing logic code corresponding to the task instance as a parameter to start the execution of the user-defined task submission execution logic corresponding to the task instance; wherein, the executable business processing logic code corresponding to the task instance is called to execute in the user-defined task submission execution logic corresponding to the task instance; the user-defined task submission execution logic is pre-configured in the user-defined command execution class; the user-defined task submission execution logic is used to define the execution process of the task corresponding to the corresponding task instance;

[0020] A task callback unit is used to submit a task instance whose execution logic has been completed for a user-defined task, remove the task instance from the running queue, pull the task instance from the waiting queue, and trigger the task verification unit to execute;

[0021] The task instance includes: user-defined business processing logic data; the user-defined business processing logic data is used to describe the parameters required to generate executable business processing logic code.

[0022] In a third aspect, an embodiment of the present invention provides a streaming task scheduling system, including an engine cluster composed of a plurality of any of the streaming task scheduling engines described above and an engine monitoring service unit;

[0023] The engine monitoring service unit is used to obtain the operating data of each streaming task scheduling engine in the engine cluster in real time, and evenly distribute task instances among the streaming task scheduling engines according to the operating data of each streaming task scheduling engine, or redistribute the task instances in a failed streaming task scheduling engine to the normally operating streaming task scheduling engines in the engine cluster.

[0024] The above technical solution has the following beneficial effects: by setting user-defined business processing classes and user-defined command execution classes, users are allowed to customize the specific behaviors of user-defined business processing classes and user-defined command execution classes according to their own needs, so that other implemented logics of the task scheduling process can be fully reused, such as the validity check of task instances, the update of running queues and waiting queues, etc. Any application system with concurrent task running control can achieve rapid docking through the technical solution of the present invention, improve the reliability, scalability and performance of the system, and reduce the complexity of developers, so that they can focus more on business implementation. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0026] Figure 1 is a flow chart of a streaming task scheduling method according to one embodiment of the present invention;

[0027] Figure 2 This is an architecture diagram of a streaming task scheduling engine according to one embodiment of the present invention;

[0028] Figure 3 This is an architecture diagram of a streaming task scheduling system according to one embodiment of the present invention;

[0029] Figure 4 It is a data flow diagram of a streaming task scheduling method according to one embodiment of the present invention;

[0030] Figure 5 This is an example diagram of a task scheduling process of a streaming task scheduling engine according to one embodiment of the present invention. DETAILED DESCRIPTION

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

[0032] First, as Figure 1 As shown, an embodiment of the present invention provides a streaming task scheduling method, including:

[0033] Step S10, receiving a task instance of a task;

[0034] Step S11, verifying the validity of the task instance;

[0035] Step S12, when the task instance is verified to be valid, determining whether the running queue is full; when determining that the running queue is not full, adding the task instance to the running queue; when determining that the running queue is full, adding the task instance to the waiting queue;

[0036] Step S13, for each task instance in the running queue, generating a user-defined business processing instance corresponding to the task instance according to a preset user-defined business processing class, calling the user-defined business processing instance, and converting the user-defined business processing logic data in the task instance into an executable business processing logic code corresponding to the task instance;

[0037] Step S14, for each task instance in the running queue, according to the preset user-defined command execution class, a user-defined command execution instance corresponding to the task instance is generated, and the executable business processing logic code corresponding to the task instance is used as a parameter to call the user-defined command execution instance to start the execution of the user-defined task submission execution logic corresponding to the task instance; wherein, the executable business processing logic code corresponding to the task instance is called to execute in the user-defined task submission execution logic corresponding to the task instance; the user-defined task submission execution logic is pre-configured in the user-defined command execution class; the user-defined task submission execution logic is used to define the execution process of the task corresponding to the corresponding task instance;

[0038] Step S15, for the task instance whose execution logic of the user-defined task submission has been completed, remove the task instance from the running queue, pull the task instance from the waiting queue, and jump to the step of verifying the validity of the task instance for execution;

[0039] The task instance includes: user-defined business processing logic data; the user-defined business processing logic data is used to describe the parameters required to generate executable business processing logic code.

[0040] In some embodiments, a task instance is a collection of various parameters required for task operation, and can be in various formats such as json, xml, ini, etc. The user assembles his own tasks (related parameters) into the task instance required by the embodiment of the present invention, and the parameters to be included in the task instance include but are not limited to the task instance ID, the number of task failure retries, the maximum number of tasks that can be run concurrently, the task submission time, the task status, the task delay check time, the data required by the user-defined business processing logic, etc. After receiving the task instance, the embodiment of the present invention needs to verify the validity of the task instance, such as identifying whether there are errors in the parameters of the task instance, correcting the correctable errors, and if the errors cannot be corrected, the task instance is considered invalid, otherwise the task instance where no errors are found or the errors are successfully corrected is judged as a valid task instance.

[0041] After verifying that the task instance is valid, it is necessary to determine whether the run queue is full. Task instances can only be added to the run queue when there are free slots in the run queue. The query interface provided by the run queue can be used to query the number of free slots in the run queue, or the number of tasks currently running in the run queue can be queried first, and then the maximum number of tasks allowed to be executed in parallel by the run queue can be combined to determine whether the run queue is full. When the run queue is not full, add the task instance to the run queue. If multiple task instances are received, add as many task instances as possible to the run queue according to the maximum number that the run queue can currently receive to ensure concurrent execution capabilities. Task instances that exceed the maximum number that the current run queue can receive are added to the waiting queue.

[0042] The preset user-defined business processing class and the user-defined command execution class are both object-oriented classes in the software field, which may contain one or more members and / or one or more methods. In an embodiment of a streaming task scheduling method, there may be one or more preset user-defined business processing classes; when there are multiple user-defined business processing classes, the user-defined business processing class that the current task instance needs to use can be specified in the task instance to be compatible with a variety of different business processing logics. There may be one or more preset user-defined command execution classes; when there are multiple user-defined command execution classes, the user-defined command execution class that the current task instance needs to use can be specified in the task instance to be compatible with a variety of different user-defined task submission execution logics. The task instance added to the running queue generates a user-defined business processing instance corresponding to the task instance according to the preset user-defined business processing class, calls the user-defined business processing instance, and converts the user-defined business processing logic data in the task instance into an executable business processing logic code corresponding to the task instance. For example, if user-defined business processing logic data is configured in the task instance: {search_table:student, insert_table:high_table,search_param:where count > 80 and sex = man}, the converted executable business processing logic code is the SQL statement: select * from student where where count > 80 and sex = man;insert into high_table values.

[0043] For each task instance in the running queue, a user-defined command execution instance corresponding to the task instance is generated according to a preset user-defined command execution class, and the executable business processing logic code corresponding to the task instance is used as a parameter to call the user-defined command execution instance to start the execution of the user-defined task submission execution logic corresponding to the task instance; the executable business processing logic code has been spliced ​​according to the user-defined business processing logic data, such as the aforementioned SQL statement. To execute this SQL, it must be submitted to the environment where the database is located, such as the Spark environment. In the embodiment of the present invention, an execution process is generated in the user-defined command execution class, and the execution process may include one or more commands. For example, for the aforementioned SQL statement, the user-defined task submission execution logic is preset in the user-defined command execution class as: spark-sql --master yarn-client -e "replaced here with the aforementioned SQL statement during execution".

[0044] The startup of the user-defined task submission execution logic in the task instance may succeed or fail. For the task instance that successfully starts the user-defined task submission execution logic, after successful execution, the task instance is removed from the running queue, the task instance is pulled from the waiting queue, and the step of verifying the validity of the task instance is executed, so as long as the running queue has free space or free slots (the number of free slots is greater than 0), the task instance is added from the waiting queue to the running queue. Among them, the waiting queue and the running queue can be implemented using Redis, which is an open source in-memory database that provides a high-performance key-value storage system.

[0045] The embodiments of the present invention have the following technical effects: by setting user-defined business processing classes and user-defined command execution classes, users are allowed to customize the specific behaviors of user-defined business processing classes and user-defined command execution classes according to their own needs, so that other implemented logics of the task scheduling process can be fully reused, such as validity verification of task instances, updating of running queues and waiting queues, etc. Based on the embodiments of the present invention, any application system with concurrent task running control can achieve rapid docking, improve system reliability, scalability and performance, while reducing the complexity of developers, so that they can focus more on business implementation.

[0046] Furthermore, the task instance also includes: delayed check time, actual task retry times, and preset task failure retry times;

[0047] For each task instance in the run queue, according to a preset user-defined command execution class, a user-defined command execution instance corresponding to the task instance is generated, and the executable business processing logic code corresponding to the task instance is used as a parameter to call the user-defined command execution instance to start the execution of the user-defined task submission execution logic corresponding to the task instance, and further includes:

[0048] The timing starts from the time when the execution of the user-defined task submission execution logic corresponding to the task instance is started. When the timing duration reaches the delay check time in the task instance, a user-defined delay check instance corresponding to the task instance is generated according to a preset user-defined delay check class, and the user-defined delay check instance corresponding to the task instance is called to execute the user-defined delay check logic to check whether the user-defined task submission execution logic corresponding to the task instance has been successfully started; wherein the user-defined delay check logic is pre-configured in the user-defined delay check class;

[0049] If it is checked that the user-defined task submission execution logic corresponding to the task instance is not successfully started, the actual number of task retries of the task instance is increased, the task instance is removed from the running queue, and the task instance is added to the failure queue;

[0050] For each task instance in the failure queue, check whether the actual number of task retries of the task instance exceeds the preset number of task failure retries, and when it is checked that the actual number of task retries of the task instance exceeds the preset number of task failure retries, remove the task instance from the failure queue, or when it is checked that the actual number of task retries of the task instance does not exceed the preset number of task failure retries, add the task instance to the waiting queue.

[0051] In some embodiments, after the task instance is submitted, it enters the running state. At this time, the streaming queue engine (streaming task scheduling engine) implemented based on the embodiment of the present invention provides a task delay checker interface. The task delay checker interface will call an instance of the user-defined delay check class to assist the user in determining whether the task has been submitted successfully. The user needs to implement the judgment logic of the user-defined delay check class to implement the task delay check according to the characteristics of their own task execution. At the same time, the task delay checker will execute the user's customized judgment logic (user-defined delay check logic) within n seconds (task delay check time) after the task is submitted according to the parameters of the task delay check time set by the user in the task instance to determine whether the task has been submitted successfully. For example, if the task delay check time set by the user is 10 seconds, then after the task is submitted and run for 10 seconds, the task delay checker will execute the user's customized delay check method to determine whether the task has been submitted successfully. For tasks (instances) that fail to submit, you can limit the number of retries and allow retries to run the task as much as possible. At the same time, for task instances that exceed the preset number of retries, it is considered that they cannot be successfully submitted. In order to avoid ineffective waste of scheduling resources, they need to be removed from the failure queue. The failure queue can be implemented using Redis.

[0052] The embodiments of the present invention have the following technical effects: tasks can be diverse, and in order to adapt to the diversity of tasks, the embodiments of the present invention reserve a variety of mechanisms for executing custom logic for each task, such as user-defined business processing classes, user-defined command execution classes, and user-defined delay check classes, so that when users process various different tasks, they can pay more attention to the logic of the task itself, without spending too much energy to unify the execution behaviors of various different tasks for the same scheduling process. The embodiments of the present invention allow each task to define the method of whether the user-defined task submission execution logic of each task is successfully started according to its own characteristics. Each task does not need to use the same judgment method, thereby avoiding the situation where each task has to adjust the behavior of each task in order to adapt to the use of the same scheduling engine, thereby using the same judgment method. By using a failure queue, a limited number of retries can be provided for task instances that fail to submit, thereby avoiding continuous resource consumption by task instances that cannot be successfully submitted while running each task instance as much as possible.

[0053] Furthermore, the task instance of receiving the task includes:

[0054] Receiving a task instance of the task through a preset http protocol application program interface, and continuing to execute the step of verifying the validity of the task instance; and / or,

[0055] The task instance of the task is received through the interface provided by the task initialization queue, and the task instance is saved in the task initialization queue, and the task instance is extracted in batches from the task initialization queue at a regular interval, and the step of verifying the validity of the task instance is continued.

[0056] In some embodiments, the task receiving API (Application Programming Interface) of the streaming queue engine is called by means of http (Hypertext Transfer Protocol), and the API receives the task and then performs the next processing. Alternatively, the task instance is stored in the task initialization queue of the streaming queue engine, and the streaming queue engine detects whether there is a task instance in the queue every 10 seconds through the initialization task processor, and then batches out all the current task instances in the initialization queue and performs the next processing.

[0057] The embodiments of the present invention have the following technical effects: two methods for adding task instances are provided, each task instance can be added individually, or task instances can be added in batches, and a flexible interface for adding task instances is provided for different scenarios.

[0058] Furthermore, the task instance includes: the maximum number of tasks that can currently be run concurrently;

[0059] The step of determining whether the run queue is full includes:

[0060] Compare the maximum number of tasks that can currently run concurrently in the task instance with the number of tasks in the running queue. If it is determined that the maximum number of tasks that can currently run concurrently is greater than the number of tasks in the running queue, it is determined that the running queue is not full; otherwise, it is determined that the running queue is full.

[0061] Further, the task instance whose execution logic has been completed for the user-defined task submission is removed from the running queue, and the task instance is pulled from the waiting queue, and the step of verifying the validity of the task instance is executed, and further includes:

[0062] After completing the execution of the user-defined task submission execution logic corresponding to the task instance, a callback instance corresponding to the task instance is generated according to the preset callback class, and the callback instance corresponding to the task instance is called to notify the user of the task execution status.

[0063] Second, as Figure 2 As shown, an embodiment of the present invention provides a streaming task scheduling engine, including:

[0064] A task instance receiving unit 200, used for receiving a task instance of a task;

[0065] A task verification unit 201, used to verify the validity of the task instance;

[0066] The queue interception unit 202 is used to determine whether the running queue is full when verifying that the task instance is valid; when determining that the running queue is not full, add the task instance to the running queue; when determining that the running queue is full, add the task instance to the waiting queue;

[0067] The business logic execution unit 203 is used to generate a user-defined business processing instance corresponding to each task instance in the running queue according to a preset user-defined business processing class, call the user-defined business processing instance, and convert the user-defined business processing logic data in the task instance into an executable business processing logic code corresponding to the task instance;

[0068] The task submission execution unit 204 is used to generate a user-defined command execution instance corresponding to each task instance in the running queue according to a preset user-defined command execution class, and call the user-defined command execution instance with the executable business processing logic code corresponding to the task instance as a parameter to start the execution of the user-defined task submission execution logic corresponding to the task instance; wherein, the executable business processing logic code corresponding to the task instance is called and executed in the user-defined task submission execution logic corresponding to the task instance; the user-defined task submission execution logic is pre-configured in the user-defined command execution class; the user-defined task submission execution logic is used to define the execution process of the task corresponding to the corresponding task instance;

[0069] The task callback unit 205 is used to remove the task instance whose execution logic has been completed for the user-defined task submission from the running queue, pull the task instance from the waiting queue, and trigger the task verification unit to execute;

[0070] The task instance includes: user-defined business processing logic data; the user-defined business processing logic data is used to describe the parameters required to generate executable business processing logic code.

[0071] Furthermore, the task instance also includes: delayed check time, actual task retry times, and preset task failure retry times;

[0072] The engine further includes:

[0073] A task delay detection unit is used to start timing from the time when the execution of the user-defined task submission execution logic corresponding to the task instance is started, and when the timing duration reaches the delay check time in the task instance, a user-defined delay check instance corresponding to the task instance is generated according to a preset user-defined delay check class, and the user-defined delay check instance corresponding to the task instance is called to execute the user-defined delay check logic to check whether the user-defined task submission execution logic corresponding to the task instance has been successfully started; wherein the user-defined delay check logic is pre-configured in the user-defined delay check class;

[0074] A failure queue updating unit is used to increase the actual task retry count of the task instance if it is checked that the user-defined task submission execution logic corresponding to the task instance is not successfully started, remove the task instance from the running queue, and add the task instance to the failure queue;

[0075] The failure queue processing unit is used to check, for each task instance in the failure queue, whether the actual number of task retries of the task instance exceeds the preset number of task failure retries, and to remove the task instance from the failure queue when it is checked that the actual number of task retries of the task instance exceeds the preset number of task failure retries, or to add the task instance to the waiting queue when it is checked that the actual number of task retries of the task instance does not exceed the preset number of task failure retries.

[0076] Furthermore, the task instance receiving unit 200 includes:

[0077] A single task instance receiving module, used to receive a task instance of a task through a preset http protocol application program interface, and trigger the task verification unit;

[0078] The multi-task instance receiving module is used to receive the task instance of the task through the interface provided by the task initialization queue, save the task instance in the task initialization queue, extract the task instance in batches from the task initialization queue at a regular time, and trigger the task verification unit.

[0079] Furthermore, the task instance includes: the maximum number of tasks that can currently be run concurrently;

[0080] The queue interception unit 202 is used to compare the maximum number of tasks that can currently be run concurrently in the task instance with the number of tasks in the running queue. If it is determined that the maximum number of tasks that can currently be run concurrently is greater than the number of tasks in the running queue, it is determined that the running queue is not full; otherwise, it is determined that the running queue is full.

[0081] Furthermore, the task callback unit 205 is also used to generate a callback instance corresponding to the task instance according to a preset callback class after completing the execution of the user-defined task submission execution logic corresponding to the task instance, and call the callback instance corresponding to the task instance to notify the user of the task execution status.

[0082] The embodiments of the present invention correspond one-to-one to the embodiments of the aforementioned streaming task scheduling method. The embodiments of the present invention can be understood based on the embodiments of the aforementioned streaming task scheduling method, and will not be described in detail here.

[0083] Thirdly, Figure 3 As shown, an embodiment of the present invention provides a streaming task scheduling system, including an engine cluster composed of a plurality of any of the streaming task scheduling engines described above and an engine monitoring service unit;

[0084] The engine monitoring service unit is used to obtain the operating data of each streaming task scheduling engine in the engine cluster in real time, and evenly distribute task instances among the streaming task scheduling engines according to the operating data of each streaming task scheduling engine, or redistribute the task instances in a failed streaming task scheduling engine to the normally operating streaming task scheduling engines in the engine cluster.

[0085] In some embodiments, the streaming task scheduling system provides an intelligent engine monitoring service unit, through which the operating data of each current engine instance (streaming task scheduling engine) is obtained in real time, including but not limited to operating status, server CPU, memory resources and other data. When the engine monitoring service unit finds that an engine instance (streaming task scheduling engine) is down, or the CPU and memory resources of the server where a certain engine (streaming task scheduling engine) is located are insufficient, the engine monitoring service unit will evenly distribute all task instances in the waiting queue and running queue corresponding to the current engine (streaming task scheduling engine) to other engine instances (streaming task scheduling engines), thereby realizing an intelligent fault-tolerant mechanism.

[0086] The above technical solution of the embodiment of the present invention is described in detail below in conjunction with specific application examples. For technical details not introduced during the implementation process, please refer to the relevant description in the previous text.

[0087] The embodiments of the present invention are mainly applied to software application scenarios involving task execution, and can realize efficient flow of tasks from submission to execution, while controlling the tasks and optimizing the utilization of task running resources.

[0088] The specific process includes the following:

[0089] like Figure 4As shown in the data flow diagram, users assemble their own tasks into task instances in the json format required by the engine. The parameters in the task instance include but are not limited to: task instance ID, number of task failure retries, the maximum number of tasks that can be run concurrently, task submission time, task status, task delay check time, data required by user-defined business processing logic, customized task submission execution logic, and / or customized delay check method (customized delay check logic) and other parameters. The task instance is submitted to the streaming queue engine (streaming task scheduling engine). The streaming queue engine has designed two task submission methods. The first is to call the task receiving API 401 of the streaming queue engine through http. After the task receiving API 401 receives the task, it performs the next processing. The second is to store the task instance in the task initialization queue 402 of the streaming queue engine. The streaming queue engine detects whether there is a task instance in the queue every 10 seconds through the initialization task processor 403, and then batches out all current task instances in the initialization queue 402 and performs the next processing.

[0090] After the streaming queue engine receives the task, each task will first enter the task verifier 404, and the task verifier 404 will verify whether the task instance format meets the engine requirements. If not, the task will fail directly.

[0091] If there is no problem with the format of the task instance, indicating that the verification is passed, the task enters the next step queue interceptor 405. Queue interceptor 405 will query and obtain the current length (the number of tasks being run) in the running queue 406, and determine whether the running queue 406 is currently full by comparing the maximum number of tasks that can be run concurrently set by the user in the task instance. If the running queue 406 is full, this task instance will be placed in the task waiting queue 407 to wait for the tasks running in the running queue 406 to be completed.

[0092] If the running queue 406 is not full, the task will proceed to the next business logic processing. In this step, the engine provides a business logic interface 408. If the user needs to have user-defined business processing logic, he needs to customize the class to implement this interface and write his own business logic when compiling the streaming queue engine source code. The subsequent streaming queue engine will pass the task instance to the user-defined business logic processing class 415 through the business logic interface 408 to process the relevant business logic.

[0093] After the business logic is processed, the streaming queue engine will pass the task to the next processor, namely the task submission execution interface 409. Like the business logic interface 408, the user needs to customize the user-defined (task) submission execution logic 417 to implement the task submission execution interface 409. Regardless of whether it is a python task, a flink task, or a linux task, the user can write the corresponding task execution command, and the streaming queue engine will execute the corresponding command.

[0094] After the task instance of the task (user task) is submitted, it enters the running state. At this time, the streaming queue engine provides a task delay checker interface 410 to assist the user in determining whether the task has been submitted successfully. The user needs to use a customized judgment logic to implement the task delay checker interface 410. At the same time, the task delay checker interface 410 will execute the user-defined delay check logic 416 within n seconds after the task is submitted according to the task delay check time parameters set by the user in the task instance to determine whether the task has been submitted successfully. For example, if the task delay check time set by the user is 10 seconds, then after the task is submitted and runs for 10 seconds, the task delay checker interface 410 will execute the user's customized delay check method to determine whether the task has been submitted successfully.

[0095] After the user task 414 is executed, the interface of the task callback 411 of the streaming queue engine needs to be called to notify the status of the task execution. After the task callback 411 in the streaming queue engine receives the status of the user task, it will first remove the task instance in the current running queue, and then perform different processing according to the status of whether the execution is successful or failed.

[0096] If the task fails, the streaming queue engine will put this task instance into the failure queue 412. The tasks in the failure queue 412 will be scanned regularly by the failure queue processor 413 in the streaming queue engine. The failure queue processor 413 will take out the scanned task instance and determine whether the task can be re-executed based on the preset task failure retry count set by the user. If the retry count has reached the user's set value (the preset task failure retry count), the task fails completely. If the retry count has not reached the user's set value (the preset task failure retry count), the task will be placed in the waiting queue and wait to be re-activated.

[0097] If the user task 414 is executed successfully, the task callback 411 will pull a waiting task from the waiting queue 407, that is, the execution is successful, and a new task will be pulled. The user task 414 will flow from the task verifier 404 until the task execution is completed.

[0098] Queue Technical Description:

[0099] The streaming queue engine uses the Redis memory database as the carrier of queue storage. Implementing task queues based on Redis has the following advantages:

[0100] High concurrency. Redis is a high-performance in-memory database that can support high-concurrency access. Therefore, the task queue implemented based on Redis can handle a large number of concurrent requests.

[0101] Low latency. Redis stores data in memory, so the read and write speeds are very fast, and low-latency task queues can be implemented.

[0102] Data persistence: Redis supports data persistence and can store data on disk. Even if the Redis server crashes, the data will not be lost.

[0103] Data sharing, based on Redis queues, can realize data sharing between multiple engines and better implement high-availability architecture.

[0104] The data structure of various queues is the Redis list structure. Through the list structure, the first-in-first-out of task instances is implemented. The tasks that enter the queue first are taken out first, ensuring the time order of task execution.

[0105] The streaming concept is the core of the streaming task queue engine. Figure 5 This mechanism is explained in the form of an example diagram of the task scheduling process of the streaming task scheduling engine.

[0106] Assume that the user sends five tasks a1, a2, a3, a4, and a5 to the streaming queue engine at the same time, and the user's maximum concurrency is set to 2, that is, only two tasks can run at the same time, and the other tasks wait.

[0107] When the task comes to the streaming queue engine, the engine will open up 5 threads to process these 5 tasks. The specific process is as follows:

[0108] 511 means a1 starts running and the thread is s1.

[0109] 521 means a2 starts running, thread s2, and the maximum number of concurrent tasks has been reached.

[0110] 531 indicates that a3 enters the waiting queue, the thread is s3, and after entering the waiting queue, the s3 thread is recycled.

[0111] 541 indicates that a4 enters the waiting queue, the thread is s4, and after entering the waiting queue, the s4 thread is recycled.

[0112] 551 indicates that a5 enters the waiting queue, the thread is s5, and after entering the waiting queue, the s5 thread is recycled.

[0113] 512 indicates that task a1 has been completed and thread s1 is waiting for the queue to pull task a3.

[0114] 522 indicates that task a2 has been completed and thread s2 is waiting for the queue to pull task a4.

[0115] 513 indicates that the s1 thread is ready to start running the a3 task.

[0116] 523 indicates that the s2 thread is ready to start running the a4 task.

[0117] 514 indicates that task a3 starts running and thread s1 is used.

[0118] 524 indicates that task a4 has started running, thread s2, and the maximum number of concurrent tasks has been reached.

[0119] 515 indicates that task a3 has finished running, and thread s1 is waiting for the queue to pull task a5.

[0120] 525 indicates that the a4 task has been completed, the s2 thread finds that the waiting queue is empty, ends the flow, and the thread is recycled.

[0121] 516 indicates that the s1 thread is ready to start running the a5 task.

[0122] 517 indicates that task a5 starts running and the thread is s1.

[0123] 518 indicates that the a5 task has been completed, the s1 thread finds that the waiting queue is empty, ends the flow, the thread is recycled, and all tasks are executed.

[0124] From the above process, it can be seen that the flow of tasks is non-stop. The threads pull tasks in a loop and execute tasks until all tasks are executed. At the same time, the number of active threads that the queue flow engine needs to open is equal to the maximum concurrent number of tasks. This also limits the number of threads opened and improves the resource utilization of the engine.

[0125] like Figure 3 The fault tolerance mechanism of the streaming task scheduling system shown is described as follows:

[0126] The streaming queue engine provides an engine monitoring service unit, through which the operating status of each current engine instance (streaming task scheduling engine), server CPU, memory resources and other operating data are obtained in real time. When the monitoring service finds that an engine instance is down, or the CPU and memory resources of the server where an engine instance is located are insufficient, the engine monitoring service unit will evenly distribute all task instances in the Redis waiting queue and running queue corresponding to the current engine instance to other engine instances, thereby realizing an automatic real-time fault-tolerance mechanism.

[0127] The embodiments of the present invention have the following technical effects:

[0128] Through the universal lightweight streaming task queue engine, tasks are transferred in a streaming manner without pauses. A variety of intelligent fault-tolerant mechanisms are built in to achieve automatic fault handling. Business interfaces are reserved, and users can add their own business processing to the task flow. Full resource utilization allows any application system with concurrent task operation control to achieve rapid docking, improve system reliability, scalability and performance, and reduce the complexity of developers, so that developers can focus more on business implementation. Through the distributed cluster architecture, multiple nodes run concurrently to achieve a natural high-availability architecture.

[0129] It should be understood that the specific order or hierarchy of steps in the disclosed process is an example of an exemplary method. Based on design preferences, it should be understood that the specific order or hierarchy of steps in the process can be rearranged without departing from the scope of protection of the present disclosure. The attached method claims present the elements of the various steps in an exemplary order and are not intended to be limited to the specific order or hierarchy described.

[0130] In the above detailed description, various features are grouped together in a single embodiment to simplify the disclosure. This method of disclosure should not be interpreted as reflecting an intention that the embodiments of the claimed subject matter require more features than are clearly stated in each claim. On the contrary, as reflected in the appended claims, the invention is in a state of having less than all the features of the disclosed individual embodiments. Therefore, the appended claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.

[0131] The disclosed embodiments are described above to enable any person skilled in the art to implement or use the present invention. Various modifications of these embodiments are obvious to those skilled in the art, and the general principles defined herein may also be applied to other embodiments without departing from the spirit and scope of the present disclosure. Therefore, the present disclosure is not limited to the embodiments given herein, but is consistent with the broadest scope of the principles and novel features disclosed in this application.

[0132] The above description includes examples of one or more embodiments. Of course, it is impossible to describe all possible combinations of components or methods for the purpose of describing the above embodiments, but it should be recognized by those skilled in the art that the various embodiments may be further combined and arranged. Therefore, the embodiments described herein are intended to cover all such changes, modifications and variations that fall within the scope of protection of the appended claims. In addition, with respect to the term "comprising" used in the specification or claims, the word is covered in a manner similar to the term "including". In addition, any term "or" used in the specification of the claims is intended to mean "non-exclusive or".

[0133] Those skilled in the art may also understand that the various illustrative logical blocks, units, and steps listed in the embodiments of the present invention may be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly demonstrate the interchangeability of hardware and software, the various illustrative components, units, and steps mentioned above have generally described their functions. Whether such functions are implemented by hardware or software depends on the specific application and the design requirements of the entire system. Those skilled in the art may use various methods to implement the described functions for each specific application, but such implementation should not be understood as exceeding the scope of protection of the embodiments of the present invention.

[0134] The various illustrative logic blocks or units described in the embodiments of the present invention can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or any combination of the above. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any conventional processor, controller, microcontroller or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a digital signal processor core, or any other similar configuration.

[0135] The steps of the method or algorithm described in the embodiments of the present invention can be directly embedded in hardware, a software module executed by a processor, or a combination of the two. The software module can be stored in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM, or other storage media of any form in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Optionally, the storage medium can also be integrated into the processor. The processor and the storage medium can be arranged in an ASIC, and the ASIC can be arranged in a user terminal. Optionally, the processor and the storage medium can also be arranged in different components in the user terminal.

[0136] In one or more exemplary designs, the above functions described in the embodiments of the present invention can be implemented in hardware, software, firmware, or any combination of the three. If implemented in software, these functions can be stored on a computer-readable medium, or transmitted in the form of one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media that facilitate the transfer of computer programs from one place to another. The storage medium can be any available medium that can be accessed by any general or special computer. For example, such computer-readable media can include but are not limited to RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store program codes in the form of instructions or data structures and other forms that can be read by general or special computers, or general or special processors. In addition, any connection can be appropriately defined as a computer-readable medium, for example, if the software is transmitted from a website site, server or other remote resource through a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wirelessly, such as infrared, wireless and microwave, it is also included in the defined computer-readable medium. The disk and disc include compact disk, laser disk, optical disk, DVD, floppy disk and Blu-ray disk. Disks usually copy data magnetically, while discs usually copy data optically with lasers. Combinations of the above may also be included in computer-readable media.

[0137] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A streaming task scheduling method, It is characterized in that include: Receive the task instance of the task; Verifying the validity of the task instance; When the task instance is verified to be valid, determining whether the running queue is full; when determining that the running queue is not full, adding the task instance to the running queue, and when determining that the running queue is full, adding the task instance to the waiting queue; For each task instance in the running queue, a user-defined business processing instance corresponding to the task instance is generated according to a preset user-defined business processing class, the user-defined business processing instance is called, and the user-defined business processing logic data in the task instance is converted into an executable business processing logic code corresponding to the task instance; For each task instance in the running queue, a user-defined command execution instance corresponding to the task instance is generated according to a preset user-defined command execution class, and the executable business processing logic code corresponding to the task instance is used as a parameter to call the user-defined command execution instance to start the execution of the user-defined task submission execution logic corresponding to the task instance; wherein, the executable business processing logic code corresponding to the task instance is called to execute in the user-defined task submission execution logic corresponding to the task instance; the user-defined task submission execution logic is pre-configured in the user-defined command execution class; the user-defined task submission execution logic is used to define the execution process of the task corresponding to the corresponding task instance; For the task instance whose execution logic has been completed in the user-defined task submission, the task instance is removed from the running queue, and the task instance is pulled from the waiting queue, and the step of verifying the validity of the task instance is jumped to execute; The task instance includes: user-defined business processing logic data; the user-defined business processing logic data is used to describe the parameters required to generate executable business processing logic code; The user-defined business processing class is an object-oriented class in the software field, including one or more corresponding members and / or one or more methods; The user-defined command execution class is an object-oriented class in the software field, and includes one or more corresponding members and / or one or more methods.

2. The streaming task scheduling method according to claim 1, It is characterized in that The task instance also includes: delayed check time, actual task retry times, and preset task failure retry times; For each task instance in the run queue, according to a preset user-defined command execution class, a user-defined command execution instance corresponding to the task instance is generated, and the executable business processing logic code corresponding to the task instance is used as a parameter to call the user-defined command execution instance to start the execution of the user-defined task submission execution logic corresponding to the task instance, and further includes: The timing starts from the time when the execution of the user-defined task submission execution logic corresponding to the task instance is started. When the timing duration reaches the delay check time in the task instance, a user-defined delay check instance corresponding to the task instance is generated according to a preset user-defined delay check class, and the user-defined delay check instance corresponding to the task instance is called to execute the user-defined delay check logic to check whether the user-defined task submission execution logic corresponding to the task instance has been successfully started; wherein the user-defined delay check logic is pre-configured in the user-defined delay check class; If it is checked that the user-defined task submission execution logic corresponding to the task instance is not successfully started, the actual number of task retries of the task instance is increased, the task instance is removed from the running queue, and the task instance is added to the failure queue; For each task instance in the failure queue, check whether the actual number of task retries of the task instance exceeds the preset number of task failure retries, and when it is checked that the actual number of task retries of the task instance exceeds the preset number of task failure retries, remove the task instance from the failure queue, or when it is checked that the actual number of task retries of the task instance does not exceed the preset number of task failure retries, add the task instance to the waiting queue.

3. The streaming task scheduling method according to claim 1, It is characterized in that The task instance of receiving the task includes: Receiving a task instance of the task through a preset http protocol application program interface, and continuing to execute the step of verifying the validity of the task instance; and / or, The task instance of the task is received through the interface provided by the task initialization queue, and the task instance is saved in the task initialization queue, and the task instance is extracted in batches from the task initialization queue at a regular interval, and the step of verifying the validity of the task instance is continued.

4. The streaming task scheduling method according to claim 1, It is characterized in that The task instance includes: the maximum number of tasks that can currently be run concurrently; The step of determining whether the run queue is full includes: Compare the maximum number of tasks that can currently run concurrently in the task instance with the number of tasks in the running queue. If it is determined that the maximum number of tasks that can currently run concurrently is greater than the number of tasks in the running queue, it is determined that the running queue is not full; otherwise, it is determined that the running queue is full.

5. The streaming task scheduling method according to claim 1, It is characterized in that The task instance for which the execution logic has been completed for the user-defined task submission is removed from the running queue, and the task instance is pulled from the waiting queue, and the step of verifying the validity of the task instance is executed, and further includes: After completing the execution of the user-defined task submission execution logic corresponding to the task instance, a callback instance corresponding to the task instance is generated according to the preset callback class, and the callback instance corresponding to the task instance is called to notify the user of the task execution status.

6. A streaming task scheduling engine, It is characterized in that include: A task instance receiving unit, used for receiving a task instance of a task; A task verification unit, used to verify the validity of the task instance; A queue interception unit is used to determine whether the running queue is full when verifying that the task instance is valid; when determining that the running queue is not full, add the task instance to the running queue; when determining that the running queue is full, add the task instance to the waiting queue; A business logic execution unit is used to generate, for each task instance in the running queue, a user-defined business processing instance corresponding to the task instance according to a preset user-defined business processing class, call the user-defined business processing instance, and convert the user-defined business processing logic data in the task instance into an executable business processing logic code corresponding to the task instance; A task submission execution unit is used to generate a user-defined command execution instance corresponding to each task instance in the running queue according to a preset user-defined command execution class, and to call the user-defined command execution instance with the executable business processing logic code corresponding to the task instance as a parameter to start the execution of the user-defined task submission execution logic corresponding to the task instance; wherein, the executable business processing logic code corresponding to the task instance is called to execute in the user-defined task submission execution logic corresponding to the task instance; the user-defined task submission execution logic is pre-configured in the user-defined command execution class; the user-defined task submission execution logic is used to define the execution process of the task corresponding to the corresponding task instance; A task callback unit is used to submit a task instance whose execution logic has been completed for a user-defined task, remove the task instance from the running queue, pull the task instance from the waiting queue, and trigger the task verification unit to execute; The task instance includes: user-defined business processing logic data; the user-defined business processing logic data is used to describe the parameters required to generate executable business processing logic code; The user-defined business processing class is an object-oriented class in the software field, including one or more corresponding members and / or one or more methods; The user-defined command execution class is an object-oriented class in the software field, and includes one or more corresponding members and / or one or more methods.

7. The streaming task scheduling engine according to claim 6, It is characterized in that The task instance also includes: delayed check time, actual task retry times, and preset task failure retry times; The engine further comprises: A task delay detection unit is used to start timing from the time when the execution of the user-defined task submission execution logic corresponding to the task instance is started, and when the timing duration reaches the delay check time in the task instance, a user-defined delay check instance corresponding to the task instance is generated according to a preset user-defined delay check class, and the user-defined delay check instance corresponding to the task instance is called to execute the user-defined delay check logic to check whether the user-defined task submission execution logic corresponding to the task instance has been successfully started; wherein the user-defined delay check logic is pre-configured in the user-defined delay check class; A failure queue updating unit is used to increase the actual task retry count of the task instance if it is checked that the user-defined task submission execution logic corresponding to the task instance is not successfully started, remove the task instance from the running queue, and add the task instance to the failure queue; The failure queue processing unit is used to check, for each task instance in the failure queue, whether the actual number of task retries of the task instance exceeds the preset number of task failure retries, and to remove the task instance from the failure queue when it is checked that the actual number of task retries of the task instance exceeds the preset number of task failure retries, or to add the task instance to the waiting queue when it is checked that the actual number of task retries of the task instance does not exceed the preset number of task failure retries.

8. The streaming task scheduling engine according to claim 6, It is characterized in that The task instance receiving unit includes: A single task instance receiving module, used to receive a task instance of a task through a preset http protocol application program interface, and trigger the task verification unit; The multi-task instance receiving module is used to receive the task instance of the task through the interface provided by the task initialization queue, save the task instance in the task initialization queue, extract the task instance in batches from the task initialization queue at a regular time, and trigger the task verification unit.

9. The streaming task scheduling engine according to claim 6, It is characterized in that The task instance includes: the maximum number of tasks that can currently be run concurrently; The queue interception unit is used to compare the maximum number of tasks that can currently run concurrently in the task instance with the number of tasks in the running queue. If it is determined that the maximum number of tasks that can currently run concurrently is greater than the number of tasks in the running queue, it is determined that the running queue is not full; otherwise, it is determined that the running queue is full.

10. A streaming task scheduling system, It is characterized in that It comprises an engine cluster and an engine monitoring service unit composed of a plurality of streaming task scheduling engines as described in any one of claims 6 to 9; The engine monitoring service unit is used to obtain the operating data of each streaming task scheduling engine in the engine cluster in real time, and evenly distribute task instances among the streaming task scheduling engines according to the operating data of each streaming task scheduling engine, or redistribute the task instances in a failed streaming task scheduling engine to the normally operating streaming task scheduling engines in the engine cluster.