CN117492944A - Task scheduling method and device, electronic equipment and readable storage medium - Google Patents

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

Info

Publication number
CN117492944A
CN117492944A CN202310778889.5A CN202310778889A CN117492944A CN 117492944 A CN117492944 A CN 117492944A CN 202310778889 A CN202310778889 A CN 202310778889A CN 117492944 A CN117492944 A CN 117492944A
Authority
CN
China
Prior art keywords
task
node
target
processed
scheduling
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310778889.5A
Other languages
Chinese (zh)
Inventor
邓林凡
苏超
曾琳铖曦
蒋宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mashang Xiaofei Finance Co Ltd
Original Assignee
Mashang Xiaofei Finance Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mashang Xiaofei Finance Co Ltd filed Critical Mashang Xiaofei Finance Co Ltd
Priority to CN202310778889.5A priority Critical patent/CN117492944A/en
Publication of CN117492944A publication Critical patent/CN117492944A/en
Pending legal-status Critical Current

Links

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)

Abstract

The application provides a task scheduling method, a task scheduling device, electronic equipment and a readable storage medium, which are used for avoiding the problem of preempting a database lock when a task scheduling system distributes tasks and reducing the influence of different task processing nodes in the task scheduling system due to unbalanced loads. The method comprises the following steps: according to the acquired task attribute information of the task to be processed, determining a task group to which the task to be processed belongs from a plurality of task groups, and dividing the task to be processed into the task groups to which the task to be processed belongs; taking any task to be processed contained in any task group as a target task, and calculating a task hash value corresponding to the target task in a hash operation mode; acquiring the node quantity of a plurality of task processing nodes to be allocated, and selecting a task processing node corresponding to a target task from the plurality of task processing nodes to be allocated according to the task hash value and the node quantity corresponding to the target task; and distributing the target task to the corresponding task processing node.

Description

Task scheduling method and device, electronic equipment and readable storage medium
Technical Field
The present disclosure relates to the field of data processing technologies, and in particular, to a task scheduling method, a task scheduling device, an electronic device, and a readable storage medium.
Background
With the increasing development of the internet, many business systems are required to be implemented by a large number of processing modules cooperating with each other. In order to ensure that the service system can stably operate under different service scenes, a plurality of timing tasks are deployed in each processing module, but massive timing tasks are caused to wait for scheduling in the service system. In the prior art, a task scheduling system is typically provided in a business system to ensure that timed tasks between different processing modules are performed orderly and efficiently.
At present, when a task scheduling system distributes a plurality of timing tasks triggered simultaneously, as task processing nodes corresponding to each timing task cannot be determined in advance, in order to prevent each task processing node from repeatedly processing the same task, the task needs to be acquired by strongly relying on a database exclusive lock, and the preemption problem of the database lock can occur; moreover, as the resource occupation conditions of different tasks are different, the task scheduling system can cause the problem of unbalanced load of different task processing nodes when the tasks are distributed.
Disclosure of Invention
The application provides a task scheduling method, a task scheduling device, electronic equipment and a readable storage medium, which are used for avoiding the problem of preempting a database lock when a task scheduling system distributes tasks and reducing the influence of different task processing nodes in the task scheduling system due to unbalanced loads.
In a first aspect, the present application provides a task scheduling method, including the following steps:
task attribute information of a task to be processed is obtained, a task group to which the task to be processed belongs is determined from a plurality of task groups according to the task attribute information, and the task to be processed is divided into the task groups to which the task to be processed belongs;
taking any task to be processed contained in any task group as a target task, and calculating a task hash value corresponding to the target task in a hash operation mode;
acquiring the node quantity of a plurality of task processing nodes to be allocated, and selecting a task processing node corresponding to the target task from the plurality of task processing nodes to be allocated according to the task hash value corresponding to the target task and the node quantity;
distributing the target task to the task processing node corresponding to the target task; each task processing node is used for adding the allocated target task to a task scheduling queue corresponding to the task processing node, so that the task scheduling module performs scheduling processing according to the task scheduling queue.
In a second aspect, the present application provides a task scheduling device, including:
the acquisition module is suitable for acquiring task attribute information of a task to be processed;
the distribution module is suitable for determining a task group to which the task to be processed belongs from a plurality of task groups according to the task attribute information, and dividing the task to be processed into the task group to which the task to be processed belongs; the method comprises the steps of obtaining the number of nodes of a plurality of task processing nodes to be distributed, and selecting task processing nodes corresponding to target tasks from the plurality of task processing nodes to be distributed according to task hash values corresponding to the target tasks and the number of nodes; and adapted to assign the target task to the task processing node corresponding to the target task; each task processing node is used for adding an allocated target task to a task scheduling queue corresponding to the task processing node so as to enable a task scheduling module to perform scheduling processing according to the task scheduling queue;
the calculation module is suitable for taking any task to be processed contained in any task group as a target task, and calculating a task hash value corresponding to the target task in a hash operation mode.
In a third aspect, the present application provides an electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, one or more of the computer programs being executable by the at least one processor to enable the at least one processor to perform the task scheduling method described above.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor/processing core implements the task scheduling method described above.
In the embodiment provided by the application, firstly, task attribute information of a task to be processed is obtained, a task group to which the task to be processed belongs is determined from a plurality of task groups according to the task attribute information, and the task to be processed is divided into the task groups to which the task to be processed belongs; then, taking any task to be processed contained in any task group as a target task, and calculating a task hash value corresponding to the target task in a hash operation mode; and acquiring the node number of the plurality of task processing nodes to be allocated, and selecting the task processing node corresponding to the target task from the plurality of task processing nodes to be allocated according to the task hash value and the node number corresponding to the target task, so as to allocate the target task to any one of the plurality of task processing nodes. Each task processing node is used for adding the allocated target task to a task scheduling queue corresponding to the task processing node so that the task scheduling module can perform scheduling processing according to the task scheduling queue. Therefore, the task is divided into a plurality of different task groups, and the tasks in each task group are distributed to different task processing nodes in a hash operation mode, on the one hand, by grouping the tasks, each task group can be distributed among a plurality of task processing nodes in a grouping unit, so that the number of tasks distributed by each task processing node and belonging to the same task group is ensured to be approximately balanced, and the problem of unbalanced task distribution caused by the fact that a large number of tasks of one group are distributed to one task processing node and a large number of tasks of the other group are distributed to other task processing nodes is avoided. On the other hand, any task in each task group can be distributed to the corresponding task processing node through a hash operation mode, and as the task key of the same task is unique and the hash operation rule and the task distribution rule are also fixed, under the condition that the task key is unique, the hash value and the distribution result corresponding to the same task are also fixed, and accordingly, by adopting the mode, the corresponding task processing node can be distributed for each task, and the corresponding relation between each task and the corresponding task processing node is fixed, each task processing node only needs to process the task distributed to the node, so that the problem of lock preemption caused by a database lock mode is avoided.
It should be understood that the description of this section is not intended to identify key or critical features of the embodiments of the application or to delineate the scope of the application. Other features of the present application will become apparent from the description that follows.
Drawings
The accompanying drawings are included to provide a further understanding of the application and are incorporated in and constitute a part of this specification, illustrate the application and together with the embodiments of the application, and not constitute a limitation to the application. The above and other features and advantages will become more readily apparent to those skilled in the art by describing in detail exemplary embodiments with reference to the attached drawings, in which:
FIG. 1 is a flow chart of a task scheduling method according to one embodiment of the present application;
FIG. 2 shows a schematic flow diagram of one specific example;
FIG. 3 is a block diagram of a task scheduling device according to an embodiment of the present application;
fig. 4 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For a better understanding of the technical solutions of the present application, the following description of exemplary embodiments of the present application is made with reference to the accompanying drawings, in which various details of embodiments of the present application are included to facilitate understanding, and they should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the absence of conflict, embodiments and features of embodiments herein may be combined with one another.
As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used herein, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. The terms "connected" or "connected," and the like, are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the relevant art and this application and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The task scheduling method according to the embodiment of the application may be performed by an electronic device such as a terminal device or a server, where the terminal device may be a vehicle-mounted device, a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, or the like; the server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud computing service. The method may in particular be implemented by means of a processor calling a computer program stored in a memory.
In the related art, a task scheduling system is generally disposed in a service system to ensure that timed tasks between different processing modules are performed orderly and efficiently. However, the inventor finds that when the task scheduling system distributes a plurality of timing tasks triggered simultaneously, the task processing nodes corresponding to the timing tasks cannot be determined in advance, so that in order to prevent the task processing nodes from repeatedly processing the same task, the task needs to be acquired by strongly relying on the exclusive database lock, and the preemption problem of the database lock can occur; moreover, as the resource occupation conditions of different tasks are different, the task scheduling system can cause the problem of unbalanced load of different task processing nodes when the tasks are distributed. In order to solve the above-mentioned problems, the present application proposes a task scheduling method, on the one hand, by grouping tasks, each task group can be respectively allocated among a plurality of task processing nodes in units of groups, so as to ensure that the number of tasks belonging to the same task group allocated to each task processing node is approximately balanced, and avoid the problem of unbalanced task allocation caused by that a large number of tasks of one group are allocated to one task processing node and a large number of tasks of another group are allocated to other task processing nodes. On the other hand, any task in each task group can be distributed to the corresponding task processing node through a hash operation mode, and the hash value and the distribution result corresponding to the same task are fixed, so that the one-to-one correspondence between the tasks and the processing nodes can be ensured through the mode, and the lock preemption problem caused by a database lock mode is avoided.
Fig. 1 is a flowchart of a task scheduling method according to an embodiment of the present application. Referring to fig. 1, the method includes:
step S110: task attribute information of a task to be processed is obtained, a task group to which the task to be processed belongs is determined from a plurality of task groups according to the task attribute information, and the task to be processed is divided into the task groups to which the task to be processed belongs.
Wherein, the task to be processed can be the task stored in the task allocation list; the task allocation list is arranged in the task scheduling system and is used for storing all timing tasks generated by different processing modules in the service system. The task attribute information is used for identifying the task to be processed to which the task belongs, and can include information such as the name of the task, the type of the task, the triggering condition of the task and the like; specifically, the task name is used to identify the source of the task, and may include, for example, a system task, a user-defined task, a derivative task, and the like; the type of the task is used for identifying the execution effect of the task, and can comprise query type tasks, search type tasks, acquisition type tasks and the like; the trigger condition of the task is used to identify a trigger threshold for the task, and may include, for example, frequent triggers, occasional triggers, very few triggers, and the like; further, any content information related to task consumption resources can be used as task attribute information, such as importance information of a task and resource occupation amount information of the task; the importance information of the task is used for representing the importance degree of the task and can be divided into three layers of high, medium and low, and the system needs to ensure the priority execution of the task with high importance degree; the resource occupation information of the task is used for representing occupation of system resources by the task, such as occupation of CPU resources, occupation of network resources, occupation of hard disk resources and the like. Wherein the task group is established according to different task attribute information; because the task attribute information characterizes the basic information of different tasks to be processed, the tasks to be processed with the same task attribute information can be distributed into corresponding task groups according to the task attribute information of the different tasks to be processed; that is, a plurality of different tasks to be processed having similar task attribute information are aggregated in each task group.
In an alternative implementation, the task attribute information of the task to be processed includes: task expression information; the task expression information is used for indicating a triggering mode of the task to be processed.
Accordingly, when determining a task group to which a task to be processed belongs from a plurality of task groups according to task attribute information, the task group is realized by the following modes:
firstly, determining a triggering mode of a task to be processed according to task expression information of the task to be processed; the task expression information can be used for representing a triggering mode of a task to be processed; the triggering modes of the task to be processed can comprise a frequency triggering mode, a timing triggering mode, an event triggering mode and the like. The frequency triggering mode refers to: the task is periodically triggered according to a preset frequency, the triggering frequency is used for representing the frequency of executing the triggering of the task to be processed within a certain duration, and the corresponding task can be divided into millisecond level, second level, minute level and the like; the highest trigger times of the millisecond tasks in the same time interval represent the highest execution times of the millisecond tasks in a certain time. In the timing triggering mode, the task to be processed is triggered to be executed only when the task to be processed is in a preset time, and the task to be processed is highly associated with the system time; only when the system time is in a preset time, the task to be processed is triggered; furthermore, a trigger time period may be preset, and when the task to be processed is in the trigger time period, the task to be processed is repeatedly triggered. In the event triggering mode, a task to be processed is triggered when a preset event is detected.
Then, aiming at a task to be processed, the triggering mode of which is a frequency triggering mode, acquiring the triggering frequency of the task to be processed; the triggering frequency of the task to be processed can be millisecond level, second level, minute level and the like; the trigger frequency represents that the task to be processed is triggered once every corresponding time.
Finally, determining a task group to which the task to be processed belongs from a plurality of task groups according to the triggering frequency of the task to be processed; wherein the plurality of task groups are a plurality of task groups which are configured in advance and respectively correspond to different trigger frequencies. The task group can be a millisecond-level task group, a second-level task group, a minute-level task group and the like; the tasks to be processed in the millisecond-level task group are tasks to be processed with the triggering frequency of millisecond-level, the tasks to be processed in the second-level task group are tasks to be processed with the triggering frequency of second-level, and the tasks to be processed in the minute-level task group are tasks to be processed with the triggering frequency of minute-level.
In a word, the tasks to be processed with different trigger frequencies can be classified and summarized according to the trigger frequencies, and the tasks to be processed with different trigger frequencies in each group can be distributed to a plurality of task processing nodes relatively uniformly, so that the problem of unbalanced distribution of excessive millisecond-level tasks in one task processing node, excessive minute-level tasks in another task processing node and the like can be solved, and the load balancing can be realized better.
Step S120: and taking any task to be processed contained in any task group as a target task, and calculating a task hash value corresponding to the target task in a hash operation mode.
Each target task corresponds to a unique task hash value, and the task hash value is obtained by performing hash operation on a task key of the target task. The task key of the target task is used for uniquely characterizing a target task, and specifically can be various information such as task identification, task ID and the like of the target task.
In an alternative implementation, the task hash value corresponding to the target task is determined by: first, a task key of a target task is generated based on task attribute information of the target task. For example, the task serial number of the target task is extracted according to the task attribute information of the target task, and a corresponding task key is generated according to the task serial number. Then, hash operation is carried out on the task key, and a task hash value corresponding to the target task is obtained.
Step S130: the method comprises the steps of obtaining the node number of a plurality of task processing nodes to be distributed, and selecting the task processing node corresponding to a target task from the plurality of task processing nodes to be distributed according to the task hash value and the node number corresponding to the target task.
The node number of the plurality of task processing nodes to be distributed is determined according to the node number of the task processing nodes in the available state in the current system. The system is configured with a plurality of task processing nodes, however, in consideration of that the node state of each task processing node can be dynamically changed, in order to facilitate timely determination of down nodes or newly added nodes, the node management cluster can be used for determining the number of the plurality of task processing nodes to be distributed.
Accordingly, in an alternative implementation, the number of nodes of the plurality of task processing nodes to be allocated is determined by: firstly, a node registration request is sent to a node management cluster; the node registration request is used for registering the current task processing node to the node management cluster; then, acquiring node state information sent by a node management cluster, and determining the node number of task processing nodes currently in an available state according to the node state information; and finally, determining the node quantity of a plurality of task processing nodes to be distributed according to the node quantity of the task processing nodes in the current available state. The method can dynamically sense the downtime node or the newly added node, thereby ensuring that the node quantity of a plurality of task processing nodes to be distributed is matched with the current state of the system.
When selecting the task processing node corresponding to the target task from the plurality of task processing nodes to be allocated according to the task hash value and the node number corresponding to the target task, the task processing node can be realized in various modes. For example, it may be realized by a general hash algorithm or a consistent hash algorithm.
In an alternative implementation, the task processing node corresponding to the target task is selected by a common hash algorithm: firstly, performing modular operation on the number of nodes according to a task hash value corresponding to a target task to obtain a modular operation result. For example, when the number of nodes is 3, the task hash value is left over 3, and a modulo operation result is obtained. And then, determining the task processing node corresponding to the target task according to the mapping relation between the plurality of task processing nodes to be allocated and the modulo operation result. For example, the 3 task processing nodes respectively correspond to the remainders 0, 1, and 2, and the task processing node for processing the target task is determined according to the correspondence between the modulo operation result and the task processing node.
In yet another alternative implementation, a task processing node corresponding to a target task is selected by a consistent hashing algorithm:
Firstly, performing modular operation on the total number of preset hash ring intervals according to a task hash value corresponding to a target task to obtain a task modular result; determining a task mapping interval corresponding to a target task from a plurality of mapping intervals contained in a preset hash ring according to a task modulus result; the preset hash ring interval total number is determined according to the interval total number of the mapping intervals contained in the preset hash ring.
Specifically, a preset hash ring is created, the hash ring is divided into a plurality of hash ring sections (i.e. mapping sections), and the total number of sections of the mapping sections included in the preset hash ring is determined as the total number of the hash ring sections. Correspondingly, performing modular operation on the task hash value corresponding to the target task and the total number of the preset hash ring intervals to obtain a task modular result. And determining a task mapping interval corresponding to the target task according to the corresponding relation between the task modulo result and the mapping intervals contained in the hash ring, so as to map the target task to the task mapping interval.
Then, according to the node hash value of each task processing node, performing modulo operation on the total number of hash ring intervals to obtain a node modulo result; and determining a node mapping interval corresponding to each task processing node from a plurality of mapping intervals contained in a preset hash ring according to the node modulo result.
Specifically, a corresponding node hash value can be determined according to the node ID of each task processing node, and the node hash value of the task processing node is subjected to modulo operation on the total number of the preset hash ring intervals, so as to obtain a node modulo result. And determining a node mapping interval corresponding to the task processing nodes according to the corresponding relation between the node modulo result and the plurality of mapping intervals contained in the hash ring, so that each task processing node is mapped to the corresponding node mapping interval respectively.
It can be seen that in this manner, on one hand, a plurality of task processing nodes are mapped to a corresponding plurality of node mapping intervals in the hash ring, respectively; on the other hand, the target task is mapped to a task mapping interval on the hash ring.
And finally, matching the task mapping interval with the node mapping intervals of the plurality of task processing nodes, and selecting the task processing node corresponding to the target task according to the matching result. When the task is specifically matched, the task processing node corresponding to the node mapping interval closest to the task mapping interval can be used as the task processing node corresponding to the target task. Alternatively, from the task mapping interval, the task processing node corresponding to the first node mapping interval may be searched in a clockwise direction (or a counterclockwise direction), and the task processing node corresponding to the first node mapping interval may be used as the task processing node corresponding to the target task. Through the consistent hash algorithm, the abnormal problem caused by the change of the number of the nodes can be avoided.
In a specific implementation, each task processing node may be divided into a real task processing node and a virtual task processing node; then, correspondingly, the node mapping interval of the task processing node may be divided into a real node mapping interval corresponding to the real task processing node and a virtual node mapping interval corresponding to the virtual task processing node. For example, each real task processing node may be determined according to an IP address or a host name of the task processing node, and each virtual task processing node may be determined by adding a prefix number or a suffix number to the IP address or the host name of the task processing node. And executing consistent hash operation on each real task processing node and each virtual task processing node to obtain a corresponding real node mapping interval and virtual node mapping interval on the hash ring. And (3) starting from the task mapping interval, searching clockwise along the hash ring, wherein the task processing node corresponding to the first encountered mapping interval (comprising the real node mapping interval and the virtual node mapping interval) is the task processing node matched with the target task. In the implementation manner, considering the problem that data is easy to incline when the number of task processing nodes is small and the distribution of each task processing node on the hash ring is unbalanced, a corresponding virtual task node is configured for each task processing node, so that the distribution balance of each service instance on the hash ring is improved by means of the virtual task nodes.
In a word, by means of the hash consistency algorithm, the task processing nodes and the target task can be matched, and a proper task processing node is found for the target task, so that the function of uniformly configuring different tasks to a plurality of task processing nodes is realized.
Step S140: the target task is assigned to a task processing node corresponding to the target task. Each task processing node is used for adding the allocated target task to a task scheduling queue corresponding to the task processing node so that the task scheduling module can perform scheduling processing according to the task scheduling queue.
In an alternative implementation, acquiring task attribute information of a task to be processed includes: acquiring task attribute information of a task to be processed from a task database;
and when the task scheduling module performs scheduling processing according to the task scheduling queue, the method further comprises the following steps: and acquiring a scheduling execution result of the task scheduling module for scheduling the target task, and storing the scheduling execution result of the target task into a preset distributed publishing and subscribing message system.
The task attribute information of all the tasks to be processed is stored in the task database. The scheduling execution result is a result generated by the task scheduling module after scheduling the target task, and may include a scheduling success result and a scheduling failure result. The scheduling execution result is used for representing the execution condition of the task and is used for realizing subsequent system analysis, abnormal positioning and other processing. In the related art, the scheduling execution result is generally stored directly in the task database described above, but the inventors found in the course of executing the present invention: under the condition that the scheduling execution result is stored in the task database, the task database may have special conditions such as database abnormality or downtime, and once the abnormal conditions occur, the subsequent abnormal processing mechanism realized based on the scheduling execution result is invalid, so that immeasurable loss is caused to the system. To solve the above-described problem, in the present embodiment, the scheduling execution result is stored in a distributed publish-subscribe message system other than the task database. It can be seen that the distributed publish-subscribe messaging system is used for storing and delivering messages; the distributed publishing and subscribing message system acquires the scheduling execution result of the target task, and stores the scheduling execution result of the target task in a database of the distributed publishing and subscribing message system.
Further, after storing the scheduling execution result of the target task in the preset distributed publish-subscribe message system, a log file may also be generated according to the scheduling execution result of the target task. The log file is used for being provided for the task alarm module, so that the task alarm module can detect the log file and can carry out alarm processing under the condition that abnormal information is detected. The abnormal information may be information of task scheduling failure; after the information of task scheduling failure is detected in the log file, the task alarm module performs alarm processing and pushes the information to the system in a notification mode to be displayed to an administrator. Because the distributed publish-subscribe message system stores the scheduling execution result of the target task in the database thereof, even if the task database is abnormal, the task alarm module can acquire a log file from the distributed publish-subscribe message system and continue to execute the subsequent processing flows of alarm analysis and the like of the task.
In a word, the implementation manner can store the scheduling execution result of the target task at other positions different from the task database, so that decoupling between the database and the scheduling task is realized, and even if the task database is abnormal, the storage of the scheduling execution result is not affected, so that the fault tolerance performance and the robustness of the whole system are improved.
In an alternative implementation, when determining the number of nodes of the plurality of task processing nodes to be allocated, the method may be implemented by:
firstly, a node registration request is sent to a node management cluster; the node registration request is used for registering the current task processing node to the node management cluster; the node management cluster is used for managing a plurality of task processing nodes, and is responsible for registration, deletion, state maintenance and the like of the task processing nodes. Correspondingly, before each task processing node accesses the task scheduling system, a node registration request needs to be sent to the node management cluster.
And then, acquiring node state information sent by the node management cluster, and determining the node quantity of the task processing nodes currently in the available state according to the node state information. The node state information is used for representing specific information of the nodes, and may include the number of nodes of the task nodes in the available state, the number of task nodes in the unavailable state, and the like.
And finally, determining the node quantity of a plurality of task processing nodes to be distributed according to the node quantity of the task processing nodes in the current available state. The task processing nodes in the available state can only execute the processing tasks, so that after the number of the task processing nodes in the available state is determined, the task processing nodes can be used as task processing nodes to be distributed to perform subsequent task scheduling work.
In short, the state of each task processing node is considered to be possibly changed, namely, newly-increased task processing nodes can be dynamically generated in the system, or the task processing nodes are reduced due to abnormal downtime; therefore, in order to facilitate accurate determination of the number of task processing nodes, the number of task processing nodes currently in an available state can be dynamically perceived by means of the node management cluster, so that the stability of the system is improved.
In an optional implementation manner, obtaining node status information sent by the node management cluster includes: acquiring node state information corresponding to the current time period sent by a node management cluster at intervals of a preset time period; the current time period is a time period corresponding to a preset time period; and collecting the number information, the load information, the task processing information and the like of the task processing nodes in the current period by the node management cluster at intervals of a preset time period. Correspondingly, after the number information of the task processing nodes in the current period is obtained, hash operation is carried out according to the number of the nodes, and a target task is distributed to any task processing node in the plurality of task processing nodes.
Accordingly, after determining the number of nodes of the task processing node currently in the available state according to the node state information, the following operations are further performed:
Firstly, determining task processing nodes with changed states under the condition that the number of the nodes of the task processing nodes in the current available state is different from the number of the nodes of the task processing nodes in the available state in the last time period; if the number of the nodes of the task processing nodes in the current available state is different from the number of the nodes of the task processing nodes in the available state in the last time period, it is indicated that a new task processing node may join in the node management cluster, or that some task processing nodes operate in overload or are in downtime and disconnection due to other abnormal conditions.
And then, screening target tasks associated with the task processing nodes with changed states from the allocated target tasks, and reallocating the screened target tasks so that the task allocation results can be dynamically adapted to the current node states of the task processing nodes.
For example, in a specific implementation manner, when the screened target tasks are reassigned, if the number of task processing nodes is reduced, only the target tasks needing to use the task processing nodes are affected, and then the target tasks processed by the task processing nodes are reassigned to other available task processing nodes by using consistent hash operation; if the number of task processing nodes increases, the newly added task processing nodes acquire node mapping positions of the newly added task processing nodes through consistent hash operation, and the new node mapping positions only affect adjacent task processing nodes, and then target tasks of the affected task processing nodes are redistributed. It follows that the consistent hashing algorithm avoids large data migration, reducing the stress on the servers of the distributed cluster.
For ease of understanding, fig. 2 shows a flow chart of a specific example, and taking this example as an example, details of a specific implementation of the task scheduling method in the present application will be described in detail:
as shown in fig. 2, the task scheduling method of the present application is supported and operated by a task database, a node management cluster, a plurality of task processing nodes (only three task processing nodes are listed in the figure), a task scheduling module integrated inside the task processing nodes, and a distributed publish-subscribe message system. The task database stores task attribute information of all tasks to be processed, task grouping can be determined through the task attribute information, and then a target task is determined; the node management cluster is used for managing a plurality of task processing nodes, and collecting the quantity information of adding, reducing and the like of the task processing nodes, and the basic information of the load, the task execution condition and the like of the task processing nodes; the task scheduling module is used for scheduling the tasks according to the task scheduling queues, and the task scheduling module is used for scheduling the tasks according to the task scheduling queues; the task scheduling module is used for scheduling the target task in the task scheduling queue corresponding to each task processing node and generating a scheduling execution result of the task; the distributed publishing and subscribing message system is used for storing the scheduling execution result of the task and transmitting the scheduling execution result of the task back to the task database.
Firstly, a task processing node sends a node registration request to a node management cluster, and registers itself to the node management cluster; then, the node management cluster confirms the number of task processing nodes in the available state at regular time; next, task attribute information of a plurality of tasks to be processed is obtained from a task database, and the tasks to be processed with the triggering mode being a frequency triggering mode are screened out; distributing the tasks to be processed to a plurality of task groups corresponding to different trigger frequencies according to the acquired trigger frequencies of the tasks to be processed; then, calculating and matching positions of the task to be processed in each task group and the task processing nodes in the available state (such as a first task processing node, a second task processing node and a third task processing node in the figure) on the hash ring respectively through a consistent hash algorithm, and distributing the task to be processed to the corresponding matched task processing nodes; then, each task processing node adds the allocated task to a task scheduling queue corresponding to the node, and the task scheduling module performs scheduling processing according to the task scheduling queue; after the dispatching processing is completed, the task dispatching module sends dispatching execution results to a distributed publishing and subscribing message system, and the distributed publishing and subscribing message system stores the dispatching execution results and transmits the dispatching execution results back to the task database; meanwhile, the node management cluster collects basic information of each task processing node and manages the task processing nodes.
In a specific implementation manner, the task database may be a MySQL-based DB database, the node management cluster may be an Apache Zookeeper-based cross-machine room cluster, the task processing node may be an application node integrating functions of monitoring, alarming, managing and scheduling (the task scheduling module is also integrated in the task processing node), and the distributed publishing and subscribing message system may be implemented by a Kafka service-based message transmission manner. The following is a detailed description:
firstly, initializing each component part; specifically, the distributed publish-subscribe message system based on Kafka is initialized, the node management cluster based on Zookeeper is initialized, and each task processing node is internally initialized and a task database is initialized. When the task processing node is internally initialized, firstly, a monitoring node/server/nodes are set, then self nodes are registered to the monitoring node/server/nodes, the monitoring node/server/reload is set, the monitoring node/server/tmp-job is set, and then all surviving nodes of a dispatching machine room are loaded and all surviving node lists are based on the surviving nodes; and finally, after the initialization is completed, performing consistent hash calculation on the tasks in each task group. When performing task consistency hash calculation, task attribute information of a task to be processed is firstly obtained through a task database, task groups to which the task to be processed belongs are determined from a plurality of task groups according to the task attribute information, and then the task to be processed is divided into corresponding task groups to serve as target tasks; then, distributing the target task to a task processing node in a consistent hash operation mode; at this time, each surviving node is allocated to a plurality of target tasks, and then allocation processing is performed on the target tasks through the Quartz task scheduling module. The above mentioned, the monitoring alarm function is integrated in each task processing node, which is realized by relying on the monitoring module; the dependency monitoring module adopts event-driven model design, can monitor against DB database and Zookeeper connection, and when detecting that the state of the node changes, sends corresponding events to the corresponding event monitor so as to perform corresponding fault-tolerant processing on the node. Specifically, when the monitoring alarm function integrated in the task processing node monitors the Zookeeper connection, the following processing logic exists:
Firstly, judging whether the task processing node can be connected with a Zookeeper; if the connection can be normally carried out, monitoring the online and offline conditions of other task processing nodes (monitoring and information interaction are carried out between the task processing nodes through an http interface), and reloading the tasks to be processed distributed by the node through an active segmentation technology; if the Zookeeper cannot be connected, judging whether other nodes can be connected with the Zookeeper normally. When judging whether other nodes can be normally connected with the Zookeeper, if feedback from other task processing nodes exists, the problem of the current task processing node is described, at the moment, task scheduling of the task processing node is stopped, and task scheduling is continued after normal recovery is performed; if all the task processing nodes in the available state, which are owned by the node management cluster, are not connected with the Zookeeper, the problem occurs to the Zookeeper cluster, at the moment, the scheduling process of the task to be processed is unchanged, the scheduling is continued, and the recalculation of the fragments is automatically compensated after the Zookeeper cluster is restored; if the http of other task processing nodes cannot respond, scheduling is not executed at the moment, and the other task processing nodes are restored and then the slicing task is recalculated; if no node responds, the situation that the Zookeeper is normally connected cannot be confirmed whether the problem that other application nodes http cannot respond occurs, at the moment, the task is suspended and not scheduled, and the slicing task is recalculated during recovery. The Zookeeper component is a key component used for node registration/discovery, and has a decisive role in subsequent task grouping (if the Zookeeper fails, the execution of the existing assigned tasks is not affected, and the reassignment of the tasks after the subsequent node change is only affected).
In addition, the task scheduling module located inside the task processing node further performs the following operations: firstly, starting an application, and then registering to a Zookeeper monitoring/schedule/node; then, starting a heartbeat keep-alive mechanism (indicating that the heartbeat signal of the task processing module is offline if the heartbeat signal of the task processing module is not detected); next, acquiring a task processing node currently registered to a Zookeeper, pulling all scheduling tasks from a task database, and grouping according to a corn expression; then grouping according to the nodes and the triggering frequency, obtaining a locally responsible scheduling task, adding the scheduling task into a Quartz job scheduling frame, and triggering the scheduling task.
In summary, in the implementation, firstly, a SpringBoot type engineering is constructed, which is used for bearing all the functional modules and realizing the internal communication among different modules; then, configuring a MySQL-based task database, a Kafka-based distributed publishing and subscribing message system and a Zookeeper cluster-based node management cluster; then, initializing a node management cluster (namely a Zookeeper cluster), and initializing a task scheduling module, a cluster detection alarm module, a task triggering module and an asynchronous callback processing module which are integrated in a task processing node; and finally, inputting the tasks to be processed which are subjected to grouping processing into the initialized task processing nodes, and carrying out distributed task scheduling.
In summary, in the embodiment provided in the present application, task attribute information of a task to be processed is first obtained, a task group to which the task to be processed belongs is determined from a plurality of task groups according to the task attribute information, and the task to be processed is divided into task groups to which the task to be processed belongs; then, taking any task to be processed contained in any task group as a target task, and calculating a task hash value corresponding to the target task in a hash operation mode; and acquiring the node number of the plurality of task processing nodes to be allocated, and selecting the task processing node corresponding to the target task from the plurality of task processing nodes to be allocated according to the task hash value and the node number corresponding to the target task, so as to allocate the target task to any one of the plurality of task processing nodes. Each task processing node is used for adding the allocated target task to a task scheduling queue corresponding to the task processing node so that the task scheduling module can perform scheduling processing according to the task scheduling queue. Therefore, the task is divided into a plurality of different task groups, and the tasks in each task group are distributed to different task processing nodes in a hash operation mode, on the one hand, by grouping the tasks, each task group can be distributed among a plurality of task processing nodes in a grouping unit, so that the number of tasks distributed by each task processing node and belonging to the same task group is ensured to be approximately balanced, and the problem of unbalanced task distribution caused by the fact that a large number of tasks of one group are distributed to one task processing node and a large number of tasks of the other group are distributed to other task processing nodes is avoided. On the other hand, any task in each task group can be distributed to the corresponding task processing node through a hash operation mode, and as the task key of the same task is unique and the hash operation rule and the task distribution rule are also fixed, under the condition that the task key is unique, the hash value and the distribution result corresponding to the same task are also fixed, and accordingly, by adopting the mode, the corresponding task processing node can be distributed for each task, and the corresponding relation between each task and the corresponding task processing node is fixed, each task processing node only needs to process the task distributed to the node, so that the problem of lock preemption caused by a database lock mode is avoided.
In addition, the tasks to be processed with different trigger frequencies can be classified and summarized according to the trigger frequencies, and the tasks to be processed with different trigger frequencies in each group can be distributed to a plurality of task processing nodes relatively uniformly, so that the problem of unbalanced distribution such as excessive millisecond-level tasks in one task processing node and excessive minute-level tasks in the other task processing node can be solved, and the load balancing can be realized better; and the task processing nodes can be matched with the target tasks through the consistent hash algorithm, so that the proper task processing nodes can be found for the target tasks, the function of uniformly configuring different tasks to a plurality of task processing nodes can be realized, and the abnormal problem caused by the change of the number of the nodes can be avoided.
In addition, the dispatching execution result of the target task is stored in other positions different from the task database, so that decoupling between the database and the dispatching task can be realized, and even if the task database is abnormal, the storage of the dispatching execution result is not affected, thereby improving the fault tolerance performance and the robustness of the whole system. Considering that the states of all the task processing nodes may change, namely newly added task processing nodes may dynamically appear in the system, or the task processing nodes are reduced due to abnormal downtime; therefore, in order to facilitate accurate determination of the number of task processing nodes, the number of task processing nodes currently in an available state can be dynamically perceived by means of the node management cluster, so that the stability of the system is improved.
Fig. 3 shows a block diagram of a task scheduling device according to an embodiment of the present application.
Referring to fig. 3, an embodiment of the present application provides a task scheduling device 30, where the task scheduling device 30 includes:
the acquisition module 31 is suitable for acquiring task attribute information of a task to be processed;
the allocation module 32 is adapted to determine a task group to which a task to be processed belongs from a plurality of task groups according to task attribute information, and divide the task to be processed into the task group to which the task to be processed belongs; the method comprises the steps of obtaining the number of nodes of a plurality of task processing nodes to be distributed, and selecting task processing nodes corresponding to target tasks from the plurality of task processing nodes to be distributed according to task hash values corresponding to the target tasks and the number of the nodes; and a task processing node adapted to assign the target task to a task corresponding to the target task; each task processing node is used for adding the allocated target task to a task scheduling queue corresponding to the task processing node so as to enable the task scheduling module to perform scheduling processing according to the task scheduling queue;
the calculation module 33 is adapted to calculate a task hash value corresponding to the target task by using any task to be processed included in any task group as the target task through a hash operation mode.
In an alternative implementation manner, the task attribute information of the task to be processed includes task expression information, where the task expression information is used to represent a trigger manner of the task to be processed;
the allocation module 32 is specifically adapted to:
determining a triggering mode of the task to be processed according to the task expression information of the task to be processed;
aiming at a task to be processed, the triggering mode of which is a frequency triggering mode, acquiring the triggering frequency of the task to be processed;
according to the triggering frequency of the task to be processed, determining a task group to which the task to be processed belongs from a plurality of task groups; wherein the plurality of task groups are a plurality of task groups which are configured in advance and respectively correspond to different trigger frequencies.
In an alternative implementation, the task hash value corresponding to the target task is determined by: generating a task key of the target task according to task attribute information of the target task; performing hash operation on the task key to obtain a task hash value corresponding to the target task;
the allocation module 32 is specifically adapted to:
performing modular operation on the number of nodes according to the task hash value corresponding to the target task to obtain a modular operation result;
and determining the task processing node corresponding to the target task according to the mapping relation between the plurality of task processing nodes to be distributed and the modular operation result.
In an alternative implementation, the allocation module 32 is specifically adapted to:
performing modular operation on the total number of the preset hash ring intervals according to the task hash value corresponding to the target task to obtain a task modular result; determining a task mapping interval corresponding to a target task from a plurality of mapping intervals contained in a preset hash ring according to a task modulus result; the method comprises the steps that a preset hash ring interval total number is determined according to the interval total number of mapping intervals contained in a preset hash ring;
performing modular operation on the total number of hash ring intervals according to the node hash value of each task processing node to obtain a node modular result; determining a node mapping interval corresponding to each task processing node from a plurality of mapping intervals contained in a preset hash ring according to a node modulus result;
and matching the task mapping interval with the node mapping intervals of the plurality of task processing nodes, and selecting the task processing node corresponding to the target task according to the matching result.
In an alternative implementation, acquiring task attribute information of a task to be processed includes: acquiring task attribute information of a task to be processed from a task database;
the allocation module 32 is further adapted to:
And acquiring a scheduling execution result of the task scheduling module for scheduling the target task, and storing the scheduling execution result of the target task into a preset distributed publishing and subscribing message system.
In an alternative implementation, the allocation module 32 is specifically adapted to:
sending a node registration request to a node management cluster; the node registration request is used for registering the current task processing node to the node management cluster;
acquiring node state information sent by a node management cluster, and determining the node quantity of task processing nodes currently in an available state according to the node state information;
and determining the node quantity of a plurality of task processing nodes to be distributed according to the node quantity of the task processing nodes currently in the available state.
In an optional implementation manner, obtaining node status information sent by the node management cluster includes: acquiring node state information corresponding to the current time period sent by a node management cluster at intervals of a preset time period;
the allocation module 32 is further adapted to:
determining the task processing node with changed state under the condition that the number of the nodes of the task processing node in the current available state is different from the number of the nodes of the task processing node in the available state in the last time period;
And screening target tasks associated with the task processing nodes with changed states from the allocated target tasks, and reallocating the screened target tasks so that the task allocation results can be dynamically adapted to the current node states of the task processing nodes.
Fig. 4 is a block diagram of an electronic device according to an embodiment of the present application.
An embodiment of the present application provides an electronic device with reference to fig. 4, including: at least one processor 501; at least one memory 502, and one or more I/O interfaces 503, coupled between the processor 501 and the memory 502; wherein the memory 502 stores one or more computer programs executable by the at least one processor 501, the one or more computer programs being executed by the at least one processor 501 to perform the task scheduling method described above.
The embodiment of the application also provides a computer readable storage medium, on which a computer program is stored, wherein the computer program realizes the task scheduling method when being executed by a processor/processing core. The computer readable storage medium may be a volatile or nonvolatile computer readable storage medium.
Embodiments of the present application also provide a computer program product comprising computer readable code, or a non-transitory computer readable storage medium carrying computer readable code, which when executed in a processor of an electronic device, performs the task scheduling method described above.
Those of ordinary skill in the art will appreciate that all or some of the steps, systems, functional modules/units in the apparatus, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between the functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed cooperatively by several physical components. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer-readable storage media, which may include computer storage media (or non-transitory media) and communication media (or transitory media).
The term computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable program instructions, data structures, program modules or other data, as known to those skilled in the art. Computer storage media includes, but is not limited to, random Access Memory (RAM), read Only Memory (ROM), erasable Programmable Read Only Memory (EPROM), static Random Access Memory (SRAM), flash memory or other memory technology, portable compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical disc storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically embodies computer readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and may include any information delivery media.
The computer readable program instructions described herein may be downloaded from a computer readable storage medium to a respective computing/processing device or to an external computer or external storage device over a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmissions, wireless transmissions, routers, firewalls, switches, gateway computers and/or edge servers. The network interface card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium in the respective computing/processing device.
Computer program instructions for performing the operations of the present application may be assembly instructions, instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, c++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may be executed entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, aspects of the present application are implemented by personalizing electronic circuitry, such as programmable logic circuitry, field Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs), with state information for computer readable program instructions, which may execute the computer readable program instructions.
The computer program product described herein may be embodied in hardware, software, or a combination thereof. In an alternative embodiment, the computer program product is embodied as a computer storage medium, and in another alternative embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), or the like.
Various aspects of the present application are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable medium having the instructions stored therein includes an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted in a generic and descriptive sense only and not for purpose of limitation. In some instances, it will be apparent to one skilled in the art that features, characteristics, and/or elements described in connection with a particular embodiment may be used alone or in combination with other embodiments unless explicitly stated otherwise. It will therefore be understood by those of ordinary skill in the art that various changes in form and details may be made therein without departing from the scope of the present application as set forth in the following claims.

Claims (10)

1. A method for task scheduling, comprising:
task attribute information of a task to be processed is obtained, a task group to which the task to be processed belongs is determined from a plurality of task groups according to the task attribute information, and the task to be processed is divided into the task groups to which the task to be processed belongs;
taking any task to be processed contained in any task group as a target task, and calculating a task hash value corresponding to the target task in a hash operation mode;
Acquiring the node quantity of a plurality of task processing nodes to be allocated, and selecting a task processing node corresponding to the target task from the plurality of task processing nodes to be allocated according to the task hash value corresponding to the target task and the node quantity;
distributing the target task to the task processing node corresponding to the target task; each task processing node is used for adding the allocated target task to a task scheduling queue corresponding to the task processing node, so that the task scheduling module performs scheduling processing according to the task scheduling queue.
2. The method according to claim 1, wherein the task attribute information of the task to be processed includes task expression information for indicating a trigger manner of the task to be processed; the determining, according to the task attribute information, a task group to which the task to be processed belongs from a plurality of task groups includes:
determining a triggering mode of the task to be processed according to the task expression information of the task to be processed;
aiming at a task to be processed, the triggering mode of which is a frequency triggering mode, acquiring the triggering frequency of the task to be processed;
Determining a task group to which the task to be processed belongs from a plurality of task groups according to the triggering frequency of the task to be processed; wherein the plurality of task groups are pre-configured task groups corresponding to different trigger frequencies.
3. Method according to claim 1 or 2, characterized in that the task hash value corresponding to the target task is determined by: generating a task key of the target task according to the task attribute information of the target task; performing hash operation on the task key to obtain a task hash value corresponding to the target task;
the selecting the task processing node corresponding to the target task from the plurality of task processing nodes to be allocated according to the task hash value corresponding to the target task and the node number includes:
performing modular operation on the node quantity according to the task hash value corresponding to the target task to obtain a modular operation result;
and determining the task processing node corresponding to the target task according to the mapping relation between the plurality of task processing nodes to be distributed and the modulo operation result.
4. The method according to claim 1 or 2, wherein selecting a task processing node corresponding to the target task from the plurality of task processing nodes to be allocated according to the task hash value corresponding to the target task and the number of nodes comprises:
Performing modular operation on the total number of preset hash ring intervals according to the task hash value corresponding to the target task to obtain a task modular result; determining a task mapping interval corresponding to the target task from a plurality of mapping intervals contained in a preset hash ring according to the task modulus result; the preset hash ring interval total number is determined according to the interval total number of the mapping intervals contained in the preset hash ring;
performing modular operation on the total number of the hash ring intervals according to the node hash value of each task processing node to obtain a node modular result; determining a node mapping interval corresponding to each task processing node from a plurality of mapping intervals contained in a preset hash ring according to the node modulus result;
and matching the task mapping interval with the node mapping intervals of the plurality of task processing nodes, and selecting the task processing node corresponding to the target task according to a matching result.
5. The method according to claim 1 or 2, wherein the acquiring task attribute information of the task to be processed includes: acquiring task attribute information of a task to be processed from a task database;
And the task scheduling module performs scheduling processing according to the task scheduling queue and then further comprises:
and acquiring a scheduling execution result of the task scheduling module for scheduling the target task, and storing the scheduling execution result of the target task into a preset distributed publishing and subscribing message system.
6. A method according to claim 1 or 2, wherein the number of nodes of the plurality of task processing nodes to be allocated is determined by:
sending a node registration request to a node management cluster; the node registration request is used for registering the current task processing node to the node management cluster;
acquiring node state information sent by the node management cluster, and determining the node number of task processing nodes currently in an available state according to the node state information;
and determining the node quantity of the plurality of task processing nodes to be distributed according to the node quantity of the task processing nodes in the current available state.
7. The method of claim 6, wherein the obtaining node status information sent by the node management cluster comprises:
acquiring node state information corresponding to the current time period sent by the node management cluster at intervals of a preset time period;
After determining the number of the nodes of the task processing node currently in the available state according to the node state information, the method further comprises:
determining the task processing node with changed state under the condition that the number of the nodes of the task processing node in the current available state is different from the number of the nodes of the task processing node in the available state in the last time period;
and screening target tasks associated with the task processing nodes with the changed states from the allocated target tasks, and reallocating the screened target tasks so that the task allocation results can be dynamically adapted to the current node states of the task processing nodes.
8. A task scheduling device, comprising:
the acquisition module is suitable for acquiring task attribute information of a task to be processed;
the distribution module is suitable for determining a task group to which the task to be processed belongs from a plurality of task groups according to the task attribute information, and dividing the task to be processed into the task group to which the task to be processed belongs; the method comprises the steps of obtaining the number of nodes of a plurality of task processing nodes to be distributed, and selecting task processing nodes corresponding to target tasks from the plurality of task processing nodes to be distributed according to task hash values corresponding to the target tasks and the number of nodes; and adapted to assign the target task to the task processing node corresponding to the target task; each task processing node is used for adding an allocated target task to a task scheduling queue corresponding to the task processing node so as to enable a task scheduling module to perform scheduling processing according to the task scheduling queue;
The calculation module is suitable for taking any task to be processed contained in any task group as a target task, and calculating a task hash value corresponding to the target task in a hash operation mode.
9. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores one or more computer programs executable by the at least one processor to enable the at least one processor to perform the task scheduling method of any one of claims 1-7.
10. A computer readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the task scheduling method according to any one of claims 1-7.
CN202310778889.5A 2023-06-28 2023-06-28 Task scheduling method and device, electronic equipment and readable storage medium Pending CN117492944A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310778889.5A CN117492944A (en) 2023-06-28 2023-06-28 Task scheduling method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310778889.5A CN117492944A (en) 2023-06-28 2023-06-28 Task scheduling method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN117492944A true CN117492944A (en) 2024-02-02

Family

ID=89677060

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310778889.5A Pending CN117492944A (en) 2023-06-28 2023-06-28 Task scheduling method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN117492944A (en)

Similar Documents

Publication Publication Date Title
US11765110B2 (en) Method and system for providing resiliency in interaction servicing across data centers
US9971823B2 (en) Dynamic replica failure detection and healing
EP2979183B1 (en) Method and arrangement for fault management in infrastructure as a service clouds
CN107251533B (en) Co-located peer device for peer-to-peer matching
CN111614748B (en) Apparatus and method for scalable peer-to-peer matching
US10944655B2 (en) Data verification based upgrades in time series system
US20150236902A1 (en) System, method and apparatus to manage services in a network
US20140059315A1 (en) Computer system, data management method and data management program
CN111064781A (en) Multi-container cluster monitoring data acquisition method and device and electronic equipment
JP6272190B2 (en) Computer system, computer, load balancing method and program thereof
US8751711B2 (en) Storage topology manager
CN111258851A (en) Cluster alarm method, device, setting and storage medium
US11397632B2 (en) Safely recovering workloads within a finite timeframe from unhealthy cluster nodes
US8521861B2 (en) Migrating device management between object managers
US10498617B1 (en) System, method, and computer program for highly available and scalable application monitoring
CN107426012B (en) Fault recovery method and device based on super-fusion architecture
US11544091B2 (en) Determining and implementing recovery actions for containers to recover the containers from failures
US11595471B1 (en) Method and system for electing a master in a cloud based distributed system using a serverless framework
US9973569B2 (en) System, method and computing apparatus to manage process in cloud infrastructure
US20160125330A1 (en) Rolling upgrade of metric collection and aggregation system
CN117492944A (en) Task scheduling method and device, electronic equipment and readable storage medium
US11637737B2 (en) Network data management framework
US10771539B2 (en) Systems and methods for cross-cluster service provision
EP4323881A1 (en) Geographically dispersed hybrid cloud cluster
US20230388205A1 (en) Cluster availability monitoring and alerting

Legal Events

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