Event scheduling methods, devices, electronic equipment and storage media
By adopting an event-driven architecture in the distributed task scheduling system, and selecting target consumer nodes based on event type and consumer node load, the low throughput problem caused by database lock contention is solved, achieving efficient task processing and load balancing.
Patent Information
- Application Number
- CN202111031604.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-03
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2041-09-03
AI Technical Summary
Existing distributed task scheduling systems, when faced with a large number of pending tasks, cause queuing during the task writing process to the database by preempting database locks to determine the consumer node, thus reducing the system's throughput.
By using an event-driven architecture, the target consumer node is dynamically selected for event publishing and processing based on the type of the target event and the message partition load of the preset consumer node. This avoids the database lock contention process and directly publishes the event to the target message partition.
This improved system throughput, achieved load balancing for task consumption, avoided performance bottlenecks caused by database lock contention, and ensured the efficient operation of the distributed task scheduling system.
Smart Images

Figure CN113886032B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of Internet technology, and in particular to an event scheduling method, apparatus, electronic device and storage medium. Background Technology
[0002] In related technologies, task scheduling is performed through a distributed task scheduling platform (XXL-JOB). The XXL-JOB includes a scheduling center and an executor. The scheduling center sends a scheduling request carrying a task to be processed to the executor. The executor receives the scheduling request and executes the task to be processed.
[0003] However, after receiving the task, the executor first writes it to the database, and then determines the consumer node to execute the task by acquiring a database lock. This method of determining the consumer node by acquiring a database lock can cause the writing process to queue when there are many tasks, thus reducing the throughput of the distributed task scheduling system. Summary of the Invention
[0004] This disclosure provides an event scheduling method, apparatus, electronic device, and storage medium to at least address the low throughput problem of distributed task scheduling systems in related technologies. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of the present disclosure, a task event scheduling method is provided, comprising:
[0006] In response to a publication request for a target event, a target topic corresponding to the event type of the target event is determined;
[0007] Based on the current load of the message partitions corresponding to the target topic and one or more preset consumer nodes, the target consumer node corresponding to the target event is determined from the one or more preset consumer nodes; the message partition corresponding to the preset consumer node is obtained by the preset consumer node registering in the corresponding topic, the corresponding topic represents the topic corresponding to the event type of the preset consumer node, and the event type of the preset consumer node represents the event type corresponding to the events that the preset consumer node can process;
[0008] Publish the target event to the target message partition corresponding to the target consumer node.
[0009] In one exemplary implementation, determining the target consumer node corresponding to the target event from the one or more preset consumer nodes based on the current load of the message partitions corresponding to the target topic and each of the one or more preset consumer nodes includes:
[0010] From the one or more preset consumer nodes, a preset number of candidate consumer nodes that have registered message partitions in the target topic are determined;
[0011] The current load of the message partition corresponding to each candidate consumer node is determined based on the number of current messages in the message partition corresponding to each candidate consumer node.
[0012] Candidate consumer nodes whose current load is less than a preset load threshold are selected as the target consumer nodes.
[0013] In one exemplary embodiment, the method further includes:
[0014] The system receives a republishing instruction from the target consumer node, which is sent by the target consumer node in response to an anomaly notification. The anomaly notification is sent by the cache server to the target consumer node when an anomaly occurs in the heartbeat data. The heartbeat data is sent by the target consumer node to the cache server at a preset frequency.
[0015] In response to the republish instruction, the target event is published to other consumer nodes besides the target consumer node.
[0016] In one exemplary embodiment, the method further includes:
[0017] Receive a non-subscription success notification sent by the target consumer node for the target event. The non-subscription success notification is used to indicate that the target consumer node has not stored the event execution status of the target event to the preset database.
[0018] In response to the unsuccessful subscription notification, the target event is republished to the target message partition.
[0019] According to a second aspect of the present disclosure, an event scheduling method is provided, comprising:
[0020] The target event is obtained from the target message partition corresponding to the local consumer node; the target event is published to the corresponding target message partition by the task publishing server; the local consumer node is determined by the task publishing server from one or more preset consumer nodes based on the target topic and the current load of the message partitions corresponding to each of the one or more preset consumer nodes; the target topic is determined by the task publishing server in response to the publication request of the target event, and the target topic corresponds to the event type of the target event; the message partition corresponding to the preset consumer node is obtained by the preset consumer node registering in the corresponding topic, and the corresponding topic represents the topic corresponding to the event type of the preset consumer node, and the event type of the preset consumer node represents the event type corresponding to the events that the preset consumer node can process;
[0021] Process the target event.
[0022] In one exemplary embodiment, the method further includes:
[0023] Heartbeat data is sent to the cache server at a preset frequency;
[0024] Receive the exception notification from the cache server to the target consumer node when the heartbeat data is abnormal;
[0025] In response to the abnormal notification, a republishing instruction is sent to the task publishing server, the republishing instruction instructing the target event to be published to other consumer nodes besides the target consumer node.
[0026] In one exemplary implementation, after obtaining the target event from the target message partition corresponding to the local consumer node, the method further includes:
[0027] Store the event execution status of the target event in a preset database;
[0028] Send a subscription success notification corresponding to the target event to the task publishing server.
[0029] In one exemplary embodiment, the method further includes:
[0030] If the execution status of the event is not stored in the preset database, a notification of unsuccessful subscription corresponding to the target event is sent to the task publishing server.
[0031] In one exemplary implementation, after obtaining the target event from the target message partition corresponding to the local consumer node, the method further includes:
[0032] Determine the target workload required to process the target event;
[0033] Send the target load to the cache server.
[0034] In one exemplary embodiment, after storing the event execution status of the target event in a preset database, the method further includes:
[0035] A load update instruction is sent to the cache server, which records the current load of the message partition corresponding to each of the one or more preset consumer nodes. The load update instruction indicates that the current load of the target message partition be updated based on the target load.
[0036] According to a third aspect of the present disclosure, an event scheduling system is provided, comprising: a task publishing server and a target consumer node:
[0037] The task publishing server is configured to: respond to a publishing request for a target event; determine a target topic corresponding to the event type of the target event; and determine a target consumer node corresponding to the target event from the one or more preset consumer nodes based on the target topic and the current load of the message partitions corresponding to each of the one or more preset consumer nodes; the message partitions corresponding to the preset consumer nodes are obtained by the preset consumer nodes registering in the corresponding topics, the corresponding topics representing the topics corresponding to the event type of the preset consumer nodes, and the event type of the preset consumer nodes representing the event types corresponding to the events that the preset consumer nodes can process; and publish the target event to the target message partition corresponding to the target consumer node.
[0038] The target consumer node is used to obtain the target event from the corresponding target message partition and to process the target event.
[0039] According to a fourth aspect of the present disclosure, a task event scheduling apparatus is provided, comprising:
[0040] The publish request and response module is configured to execute a publish request in response to a target event and determine the target topic corresponding to the event type of the target event;
[0041] The target consumer node determination module is configured to determine the target consumer node corresponding to the target event from the one or more preset consumer nodes based on the current load of the message partitions corresponding to the target topic and the one or more preset consumer nodes respectively; the message partitions corresponding to the preset consumer nodes are obtained by the preset consumer nodes registering in the corresponding topics, the corresponding topics representing the topics corresponding to the event type of the preset consumer nodes, and the event type of the preset consumer nodes representing the event types corresponding to the events that the preset consumer nodes can process;
[0042] The publishing module is configured to publish the target event to the target message partition corresponding to the target consumer node.
[0043] In one exemplary embodiment, the target consumer node determination module includes:
[0044] The candidate consumer node determination unit is configured to determine a preset number of candidate consumer nodes from the one or more preset consumer nodes that have registered message partitions in the target topic;
[0045] The current load determination unit is configured to determine the current load of the message partition corresponding to each candidate consumer node based on the number of current messages in the message partition corresponding to each candidate consumer node.
[0046] The target consumer node determination unit is configured to select candidate consumer nodes whose current load is less than a preset load threshold as the target consumer nodes.
[0047] In one exemplary embodiment, the apparatus further includes:
[0048] The redistribution instruction receiving module is configured to receive redistribution instructions sent by the target consumer node. The redistribution instruction is sent by the target consumer node in response to an anomaly notification. The anomaly notification is sent by the cache server to the target consumer node when an anomaly occurs in the heartbeat data. The heartbeat data is sent by the target consumer node to the cache server at a preset frequency.
[0049] The redistribution instruction response module is configured to respond to the redistribution instruction by publishing the target event to other consumer nodes besides the target consumer node.
[0050] In one exemplary embodiment, the apparatus further includes:
[0051] The unsubscribed success notification receiving module is configured to receive the unsubscribed success notification corresponding to the target event sent by the target consumer node. The unsubscribed success notification is used to indicate that the target consumer node has not stored the event execution status of the target event in a preset database.
[0052] The unsubscribed success notification response module is configured to respond to the unsubscribed success notification by republishing the target event to the target message partition.
[0053] According to a fifth aspect of the present disclosure, an event scheduling apparatus is provided, comprising:
[0054] The target event acquisition module is configured to acquire a target event from the target message partition corresponding to the local consumer node. The target event is published to the corresponding target message partition by the task publishing server. The local consumer node is determined by the task publishing server from one or more preset consumer nodes based on the target topic and the current load of the message partitions corresponding to each of the one or more preset consumer nodes. The target topic is determined by the task publishing server in response to the publication request of the target event, and the target topic corresponds to the event type of the target event. The message partition corresponding to the preset consumer node is obtained by the preset consumer node registering in the corresponding topic, and the corresponding topic represents the topic corresponding to the event type of the preset consumer node. The event type of the preset consumer node represents the event type corresponding to the events that the preset consumer node can process.
[0055] The processing module is configured to perform processing of the target event.
[0056] In one exemplary embodiment, the apparatus further includes:
[0057] The heartbeat data sending module is configured to send heartbeat data to the cache server at a preset frequency;
[0058] The exception notification receiving module is configured to receive the exception notification returned by the cache server to the target consumer node when the heartbeat data is abnormal;
[0059] An exception notification response module is configured to respond to the exception notification by sending a redistribution instruction to the task publishing server, wherein the redistribution instruction instructs the target event to be published to other consumer nodes besides the target consumer node.
[0060] In one exemplary embodiment, the apparatus further includes:
[0061] The storage module is configured to store the event execution status of the target event in a preset database;
[0062] The subscription success notification sending module is configured to send the subscription success notification corresponding to the target event to the task publishing server.
[0063] In one exemplary embodiment, the apparatus further includes:
[0064] The module for sending unsubscribed success notifications is configured to send an unsubscribed success notification corresponding to the target event to the task publishing server if the event execution status is not stored in the preset database.
[0065] In one exemplary embodiment, the apparatus further includes:
[0066] A target load determination module is configured to determine the target load required to process the target event.
[0067] The target load sending module is configured to send the target load to the cache server.
[0068] In one exemplary embodiment, the apparatus further includes:
[0069] The load update instruction sending module is configured to send a load update instruction to the cache server, which records the current load of the message partition corresponding to each of the one or more preset consumer nodes. The load update instruction indicates that the current load of the target message partition should be updated based on the target load.
[0070] According to a sixth aspect of the present disclosure, an electronic device is provided, comprising:
[0071] processor;
[0072] Memory used to store the processor's executable instructions;
[0073] The processor is configured to execute the instructions to implement the event scheduling method as described in any of the above embodiments.
[0074] According to a sixth aspect of the present disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, causes the electronic device to perform an event scheduling method as described in any of the above embodiments.
[0075] According to a seventh aspect of the present disclosure, a computer program product is provided, comprising a computer program, characterized in that, when the computer program is executed by a processor, it implements the event scheduling method described in any of the above embodiments.
[0076] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects:
[0077] In this embodiment, upon responding to a publication request for a target event, a target topic corresponding to the event type of the target event is determined. Then, based on the current load of the message partitions corresponding to the target topic and one or more preset consumer nodes, a target consumer node for consuming the target event is determined. The target event is then published to the target message partition registered by the target message node in the target topic. The target consumer node retrieves the target event from the target message partition and processes it. Since this disclosure does not directly send the target event to the consumer node, but rather publishes the target event to the target message partition in the target topic and waits for the target message node to process it, the triggering of the target event and the execution of the task are completely decoupled. Furthermore, upon responding to a publication request for a target event, the target consumer node for consuming the target event can be directly determined based on the current load of the message partitions corresponding to the target topic and one or more preset consumer nodes. That is, the target consumer node for consuming the target event is determined when the target event is issued, which helps improve system throughput.
[0078] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0079] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0080] Figure 1 This is an application environment diagram illustrating an event scheduling method according to an exemplary embodiment.
[0081] Figure 2 This is a flowchart illustrating an event scheduling method according to an exemplary embodiment.
[0082] Figure 3 This is a flowchart illustrating another event scheduling method according to an exemplary embodiment.
[0083] Figure 4 This is a flowchart illustrating, according to an exemplary embodiment, the storage of associated information and the subsequent sending of a notification to a task publishing server.
[0084] Figure 5 This is a flowchart illustrating the republication of a target event according to an exemplary embodiment.
[0085] Figure 6 This is a flowchart illustrating another event scheduling method according to an exemplary embodiment.
[0086] Figure 7 This is a flowchart illustrating another event scheduling method according to an exemplary embodiment.
[0087] Figure 8 This is a block diagram of an event scheduling device according to an exemplary embodiment.
[0088] Figure 9 This is a block diagram of another event scheduling device according to an exemplary embodiment.
[0089] Figure 10 This is a block diagram illustrating an electronic device for event scheduling according to an exemplary embodiment. Detailed Implementation
[0090] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0091] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0092] Please see Figure 1 , Figure 1 This is an application environment diagram illustrating an event scheduling method according to an exemplary embodiment. The application environment may include a task publishing server 01, a target consumer node 02, and a cache server 03. The target consumer node 02 can communicate with the task publishing server 01 and the cache server 03 via wired or wireless means, which is not limited in this disclosure.
[0093] The task publishing server 01 can select a target consumer node based on the load of the message partitions corresponding to one or more preset consumer nodes, and send the target event to the target message partition corresponding to the target consumer node. Optionally, the task publishing server 01 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0094] Specifically, the target consumer node 02 can be used to retrieve target events from the target message partition and process those events. Optionally, the target consumer node 02 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Optionally, the target consumer node 02 can also be a client, which can include smartphones, desktop computers, tablets, laptops, etc.
[0095] The cache server 03 can receive heartbeat data sent by the target consumer node 02, and when the heartbeat data of the target consumer node is abnormal, it sends an abnormal notification to the target consumer node 02. In response to the abnormal notification, the target consumer node 02 sends a redistribution instruction to the task publishing server 01. The task publishing server 01, in response to the redistribution instruction, publishes the target event to other consumer nodes besides the target consumer node 02 (i.e., reallocates the target event). Optionally, the cache server 03 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0096] It should be noted that, Figure 1 This is merely one application environment for the event scheduling method provided in this disclosure; in practical applications, other application environments may also be included.
[0097] Figure 2 This is a flowchart illustrating an event scheduling method according to an exemplary embodiment. For example... Figure 2 As shown, this event scheduling method is used for Figure 1 The system, which includes a task publishing server 01 and a target consumer node 02, includes the following steps.
[0098] In step S11, the task publishing server responds to the publishing request of the target event and determines the target topic corresponding to the event type of the target event.
[0099] This disclosure is based on an event-driven architecture (EDA), where events can be viewed as messages. Message publishers send different types of events to the target topics corresponding to those event types, and message subscribers receive messages from the topics they have subscribed to. Specifically, a task event can be a publish request carrying a target event sent to the task publishing server. The task publishing server can respond to the publish request and determine the target topic corresponding to the event type of the target event.
[0100] EDA (Event-Driven Architecture) is a software architecture and model used for designing applications. EDA is a way to achieve maximum loose coupling between components or services through events. An event-driven architecture consists of event initiators and event consumers. The event initiator detects or senses an event and represents it as a message. It is unaware of the event consumer or the result of the event. After detecting an event, the event initiator sends it to an event channel, which then transmits the event to the event consumer.
[0101] Specifically, EDA can be based on a publish / subscribe model, which is a messaging infrastructure based on event stream subscriptions. The publish / subscribe model can include message publishers, message topics, and message subscribers. Figure 1 Task publisher server 01 in the context can act as a message publisher in a publish / subscribe model. Figure 1 The target consumer node 02 can act as a message subscriber in the publish / subscribe model.
[0102] An event refers to any significant change in the state of the system's hardware or software. The source of an event can be internal or external input. Events can originate from the user (e.g., clicking a mouse or pressing a key), an external source (e.g., sensor output), or the system (e.g., loading a program).
[0103] The event type of the target event refers to the type to which the target event belongs. For example, if the target event is a calculation event, then the event type is calculation type; if the target event is a save event, then the event type is save type.
[0104] Event types and topics have a corresponding relationship. In one embodiment, a target event can have at least one event type, and correspondingly, the target event can correspond to at least one target topic. For example, if a target event includes a calculation step, then its event type is a calculation type, and its target topic is a calculation topic. If a target event includes both a calculation step and a storage step, then its event type can include both a calculation type and a storage type, and the corresponding target topic can include both a calculation topic and a storage topic.
[0105] In step S13, the task publishing server determines the target consumer node corresponding to the target event from the one or more preset consumer nodes based on the current load of the message partitions corresponding to the target topic and the one or more preset consumer nodes. The message partitions corresponding to the preset consumer nodes are obtained by the preset consumer nodes registering in the corresponding topics. The corresponding topics represent the topics corresponding to the event types of the preset consumer nodes, and the event types of the preset consumer nodes represent the event types corresponding to the events that the preset consumer nodes can process.
[0106] Specifically, each pre-defined consumer node has its own defined event types that it can handle during registration. The corresponding topic refers to the topic corresponding to the event types that the pre-defined consumer node can handle. For example, if a consumer node can handle computation-type events, then the corresponding topic is the computation topic.
[0107] In an optional embodiment, Figure 3 This is a flowchart illustrating another event scheduling method according to an exemplary embodiment. For example... Figure 3 As shown, in step S13 above, the task publishing server determines the target consumer node corresponding to the target event from the one or more preset consumer nodes based on the current load of the message partitions corresponding to the target topic and each of the one or more preset consumer nodes. This may include:
[0108] In step S1301, the task publishing server determines a preset number of candidate consumer nodes from the one or more preset consumer nodes that have registered message partitions in the target topic. The preset number can be set according to the specific situation, such as 1, 3, 5, 100, etc., and this scheme does not limit it.
[0109] In step S1303, the task publishing server determines the current load of the message partition corresponding to each candidate consumer node based on the number of messages in the message partition corresponding to each candidate consumer node.
[0110] In step S1305, the task publishing server selects candidate consumer nodes whose current load is less than a preset load threshold as the target consumer nodes.
[0111] In this embodiment of the disclosure, the preset consumer nodes in the consumer cluster pre-register a dedicated message partition under a corresponding topic. The topic corresponding to a consumer node is the topic corresponding to the event type of that consumer node, and the message partition registered by a consumer node is used to store the events to be processed corresponding to that consumer node. For example, the preset consumer nodes include consumer node A, consumer node B, and consumer node C. The topics corresponding to the event types of consumer nodes A and B are both computation topics, and the topic corresponding to the event type of consumer node C is a storage topic. Then, the topics corresponding to consumer nodes A and B are computation topics, and the topic corresponding to consumer node C is a storage topic. Consumer nodes A and B register dedicated message partitions under the computation topic, and consumer node C registers a dedicated message partition under the storage topic.
[0112] After the task publishing server determines the target topic, it can obtain a preset number of candidate consumer nodes that have registered message partitions under that target topic. Based on the load within the message partitions of each candidate consumer node, the candidate node with a load below a preset load threshold is selected as the target consumer node to process the target event. The load describes the message congestion situation of the message partition; a higher load indicates more severe congestion, and a lower load indicates less severe congestion. For example, if consumer nodes C, D, and E have all registered corresponding message partitions under the target topic, and the load within the message partitions corresponding to consumer nodes C and D is below the preset load threshold, then consumer nodes C and D will be selected as the target consumer nodes.
[0113] It should be noted that the number of target consumer nodes corresponding to the target event is at least one.
[0114] Optionally, the task publishing server includes a task scheduler, which can be used to perform the process of determining the target consumer node.
[0115] In this embodiment, a suitable target consumer node is assigned to handle the target event based on the load of the message partition corresponding to each consumer node. That is, the target consumer node for handling the target event is determined when the target event is issued, avoiding excessive workload on consumer nodes and achieving load balancing for task consumption. Furthermore, when concurrent transactions access a resource simultaneously, data inconsistency may occur. Therefore, data locks are needed to sequentially access data to ensure database consistency. When a target event arrives, consumer nodes compete for the data lock, and ultimately, the consumer node that acquires the data lock processes the target event. However, this method of acquiring data locks can cause the writing of tasks to the database to be queued when there are many tasks to be processed, thus reducing the throughput of the distributed task scheduling system. In contrast, this embodiment determines the target consumer node for handling the target event when it is issued, avoiding the performance bottleneck caused by determining the target consumer node through database lock acquisition and ensuring the throughput of the distributed task scheduling system.
[0116] In step S15, the task publishing server publishes the target event to the target message partition corresponding to the target consumer node.
[0117] In an optional embodiment, in step S15 above, the task publishing server publishing the target event to the target message partition corresponding to the target consumer node may include:
[0118] The task publishing server encodes the target event to obtain the target message;
[0119] The aforementioned task publishing server transmits the aforementioned target message to the message queue;
[0120] The aforementioned task publishing server publishes the aforementioned target message to the aforementioned target message partition based on the aforementioned message queue.
[0121] This disclosure embodiment is based on an event-driven architecture and can introduce a message queue (MQ) that supports a publish / subscribe model. The target event is encoded to obtain the target message, and the target message is sent to the MQ. When the task publishing server decides to let the target consumer node handle the target event, the target event can be sent to the target message partition corresponding to the target consumer node based on the MQ.
[0122] Optionally, the task scheduling server may also include an encoding and publishing message module, which can perform the encoding process described above.
[0123] This disclosure embodiment is based on an event-driven architecture and introduces a message queue (MQ) that supports a publish / subscribe model. The triggering relationship between events and tasks is mapped to the subscription relationship of topic messages, thereby using the message queue to improve the system's throughput and scalability.
[0124] In step S17, the target consumer node obtains the target event from the corresponding target message partition.
[0125] In an optional embodiment, when the target event is encoded into a target message, in step S17 above, the target consumer node obtains the target event from the corresponding target message partition, which may include:
[0126] The aforementioned target consumer nodes obtain the aforementioned target messages from the aforementioned target message partitions;
[0127] The aforementioned target consumer node decodes the aforementioned target message to obtain the aforementioned target event.
[0128] Specifically, when a target event is encoded into a target message, the target consumer node obtains the target message from the target message partition, and then needs to decode it to obtain the target event, thereby realizing the acquisition of the target event and the triggering of the task.
[0129] In an optional embodiment, Figure 4 This is a flowchart illustrating, according to an exemplary embodiment, the storage of event execution status and the subsequent sending of a notification to a task publishing server. For example... Figure 4 As shown, after the target consumer node obtains the target event from the corresponding target message partition, the method may further include:
[0130] In step S21, the target consumer node stores the event execution status of the target event in a preset database.
[0131] In step S23, the target consumer node sends a subscription success notification corresponding to the target event to the task publishing server.
[0132] In another alternative embodiment, the above method may further include:
[0133] If the target consumer node does not store the execution status of the event in the preset database, the target consumer node sends a notification of unsuccessful subscription corresponding to the target event to the task publishing server.
[0134] In response to the aforementioned unsuccessful subscription notification, the task publishing server republishes the aforementioned target event to the aforementioned target message partition.
[0135] Optionally, the event execution status may include information such as whether the target event has been executed, who executed it, and at which stage it was executed. Specifically, the event execution status may include, but is not limited to: the initiator of the target event, the target topic corresponding to the target event, the target consumer node corresponding to the target event, at which stage the target event was executed, the pending execution status (i.e., the todo status, which is the default value when the event execution status is stored in the preset database), the instance processing status (i.e., being processed by the target consumer node), the processing completed status (i.e., the doing status, which has been completed by the target consumer node), the processing failed status (i.e., the failed status, which means the target consumer node failed to process it), and the rescheduled status (i.e., the reseched status, which means the task is republished by the task publishing server).
[0136] Specifically, after the target consumer node stores the event execution status in the database, it can send a successful subscription notification for the target event to the task publishing server. If the target consumer node fails to store the event execution status, it can send a failed subscription notification to the task publishing server. Upon receiving the failed subscription notification, the task publishing server will transmit the target event to the message queue, and then republish the target event to the target message partition based on the message queue.
[0137] In this embodiment, storing the execution status of the target event in a preset database ensures that the target event is not lost. Furthermore, once the target event is stored in the preset database, the task publishing server will not allocate it to other consumer nodes, avoiding the problem of the same event being consumed repeatedly by different consumer nodes, thereby reducing system resource consumption. In addition, if the target event is not stored in the preset database, the target consumer node can send a notification of unsuccessful subscription to the task publishing server. In response to this notification, the task publishing server sends the target event to the target message partition via the aforementioned message queue, thereby ensuring that the target event is successfully sent and avoiding leftover events.
[0138] In an optional embodiment, after the target consumer node obtains the target event from the corresponding target message partition, the method may further include:
[0139] The target consumer nodes mentioned above determine the target load required to process the target events mentioned above.
[0140] The aforementioned target consumer node sends the aforementioned target load to the cache server.
[0141] The aforementioned cache server records the target load.
[0142] In this embodiment of the disclosure, after the target consumer node receives the target event, it calculates the task load required to consume the target event and stores the task load in the cache server.
[0143] In another optional embodiment, after the target consumer node stores the event execution status of the target event in a preset database, the method may further include:
[0144] The aforementioned target consumer node sends a load update instruction to the aforementioned cache server, which records the current load of the message partition corresponding to each of the aforementioned one or more preset consumer nodes;
[0145] In response to the load update command, the cache server updates the current load of the target message partition based on the target load.
[0146] In this embodiment of the disclosure, after the target consumer node stores the target event in a preset database, it can report the arrival of a new task to the cache server and send a load update instruction to the cache server. In response to the load update instruction, the cache server updates the current load of the target message partition according to the target load required to consume the target event.
[0147] In this embodiment, a caching service records the current load of the message partitions corresponding to each consumer node. When a new target event arrives, the load of the target message partition is updated based on the target load required to consume the target event. This ensures that the load of the message partitions corresponding to each consumer node is updated in a timely manner, guaranteeing the accuracy of the load of each consumer node's message partition. Since the task publishing server selects the target consumer node for consuming the target event based on the load of the message partitions corresponding to each consumer node, the real-time update of the message partition load improves the accuracy of the task publishing server in selecting the target consumer node for consuming the target event.
[0148] In step S19, the target consumer node processes the target event.
[0149] In an optional embodiment, in step S19 above, the processing of the target event by the target consumer node may include:
[0150] The aforementioned target consumer node obtains the first processing strategy corresponding to the aforementioned event type.
[0151] The aforementioned target consumption node processes the aforementioned target event according to the first processing strategy described above.
[0152] In this embodiment of the disclosure, the target consumer node may include a task processor, which may record a first mapping relationship between event types and processing strategies. Based on this first mapping relationship, the task processor can obtain a first processing strategy corresponding to the event type of the target event and process the target event according to the first processing strategy.
[0153] Specifically, a target event can correspond to multiple primary processing strategies simultaneously, thereby triggering multiple tasks.
[0154] It should be noted that the embodiments disclosed herein do not limit the execution object that executes the target event. The execution object can be a local thread pool or a distributed task execution framework (e.g., XXL-JOB).
[0155] In another optional embodiment, if the initial state of the event execution status is incomplete, then after the target consumer node processes the target event, the method may further include updating the event execution status. Specifically, updating the event execution status may include:
[0156] When the aforementioned target event is successfully processed, the aforementioned target consumer node updates the event execution status from the initial status to the processing completed status.
[0157] When the above target event processing fails, the above target consumer node obtains the second processing strategy corresponding to the above event type.
[0158] The aforementioned target consumer node processes the aforementioned target event based on the aforementioned second processing strategy.
[0159] If the number of times the target consumer node processes the target event based on the second processing strategy exceeds a preset threshold, and the target event is not successfully processed, the target consumer node will update the event execution status from the initial status to the processing failure status.
[0160] In this embodiment of the disclosure, if the target event is successfully processed, the event execution status in the preset database is updated from the initial status to the processing completed status (i.e., the done status).
[0161] Optionally, the target consumer node may further include a processor corresponding to the second processing strategy. This processor may record the mapping relationship between the event type and the second processing strategy. If the target event is not successfully processed by the first processing strategy in the task processor, the second processing strategy for the target event can be obtained through the processor corresponding to the second processing strategy, and the target event can be further processed according to the second processing strategy.
[0162] Optionally, the second processing strategy can define the number of retries and the time interval for processing the target event, or directly ignore the failure result. If the second processing strategy processes the target event more than a preset threshold number of times, and the target event is still not processed successfully, the target consumer node can update the event execution status in the preset database from the initial status to the processing failure status (i.e., the failed status).
[0163] In this embodiment, the task processor in the target consumer node processes the target event according to the first processing strategy, which improves the success rate of target event processing. If the target event is not successfully processed by the task processor, the processor corresponding to the second processing strategy can further process the target event according to the second processing strategy, which further improves the success rate of target event processing. Furthermore, after the first processing strategy successfully consumes the target event, the event execution status in the database can be preset to a successful processing status. Target events in the successfully processed state do not need to be processed repeatedly, avoiding the problem of high system resource consumption caused by repeated event processing. In addition, the number of processing attempts of the second processing strategy is limited; that is, the second processing strategy can attempt processing multiple times. If the target event is still not successfully processed after reaching the processing threshold, its status information is updated to a failure status, increasing the probability of the target event being successfully processed.
[0164] In an optional embodiment, Figure 5 This is a flowchart illustrating the republication of a target event according to an exemplary embodiment. For example... Figure 5 As shown, the above method may further include:
[0165] In step S31, the target consumer node sends heartbeat data to the cache server at a preset frequency.
[0166] In step S33, when the heartbeat data is abnormal, the cache server sends an abnormal notification to the target consumer node.
[0167] In step S35, the target consumer node responds to the above-mentioned abnormal notification by sending a republishing instruction to the above-mentioned task publishing server.
[0168] In step S37, the task publishing server responds to the republishing instruction by publishing the target event to other consumer nodes besides the target consumer node.
[0169] In this embodiment, the target consumer node can send heartbeat data to the cache server at a preset frequency (e.g., 30 seconds). This heartbeat data represents the connection status between the target consumer node and the cache server. When the heartbeat data is abnormal (e.g., when the connection between the target consumer node and the cache server is interrupted, and the heartbeat data is not sent within the set period), the cache server sends an abnormal notification to the target consumer node. The target consumer node then updates the event execution status to a rescheduled state and issues a republishing instruction to the task publishing server, triggering the task publishing server to publish the incomplete events in the target consumer node to other consumer nodes besides the target consumer node.
[0170] Alternatively, the cause of abnormal heartbeat data may be: the target instance node has a sending failure problem and fails to refresh the heartbeat in time, causing the heartbeat data to expire.
[0171] Optionally, when a target consumer node malfunctions, the load of its message partition stored on the cache server can be deleted, thereby preventing new events from being assigned to the problematic consumer node with abnormal heartbeat data.
[0172] Optionally, the target consumer node may also include a service cluster management module, which can be used to execute the process of sending heartbeat data.
[0173] In this embodiment, when the data of a target consumer node becomes abnormal, that target consumer node is designated as a problematic consumer node. The task publishing server then distributes unprocessed events from this problematic consumer node to other consumer nodes, preventing event backlog and ensuring that every event is processed. Furthermore, when a target consumer node becomes abnormal, the load on the message partition stored in the cache server for that abnormal target consumer node can be removed. This avoids the problem of new events not being processed promptly when new events are assigned to the abnormal target consumer node, ensuring the accuracy of event processing.
[0174] In an optional embodiment, the target consumer node may further include an initialization service module, which is used to initialize the thread pool and the message queue. When the target consumer node starts or restarts, the message queue loads task events that have not been executed by the target consumer node from the target message partition corresponding to the target consumer node, and executes these task events first to ensure that no task events are lost. This embodiment ensures high availability of the consumer node; even if it restarts briefly or the network is unavailable, its unfinished tasks can be re-executed.
[0175] This disclosure, based on an event-driven architecture using a publish / subscribe model, completely decouples event triggering from task execution, significantly improving the throughput of the distributed task scheduling system and enhancing its elastic scalability. The technical solution provided by this disclosure offers at least the following beneficial effects:
[0176] On the one hand, based on the characteristics of message queues, events are consumed rationally as messages, avoiding issues such as event loss or duplicate consumption. On the other hand, by adopting an event-driven framework, event triggering and task execution are completely decoupled, making it easier to maintain code and business logic. Furthermore, based on the publish / subscribe model, the service cluster has high scalability, specifically manifested in: a) when a new consumer node comes online, the message queue automatically assigns new tasks; b) if a consumer node encounters a problem, it will no longer be assigned new tasks, and its assigned tasks will be reassigned to other consumer nodes. Moreover, since the consumer node for an event is determined when it is issued, excessive workload on consumer nodes is avoided, achieving load balancing for task consumption. This also avoids performance and scaling bottlenecks caused by lock contention, resulting in better throughput for sudden surges in requests. In addition, consumer nodes are highly available; even if they briefly restart or the network becomes unreachable, unfinished tasks can be re-executed.
[0177] The following describes an event scheduling method disclosed herein, with the task publishing server as the executing entity. Figure 6 This is a flowchart illustrating another event scheduling method according to an exemplary embodiment. For example... Figure 6 As shown, the event scheduling method may include:
[0178] In step S41, in response to the publication request of the target event, a target topic corresponding to the event type of the target event is determined.
[0179] In step S43, based on the current load of the message partitions corresponding to the target topic and one or more preset consumer nodes, the target consumer node corresponding to the target event is determined from the one or more preset consumer nodes; the message partitions corresponding to the preset consumer node are obtained by the preset consumer node registering in the corresponding topic, the corresponding topic represents the topic corresponding to the event type of the preset consumer node, and the event type of the preset consumer node represents the event type corresponding to the event that the preset consumer node can process.
[0180] In step S45, the target event is published to the target message partition corresponding to the target consumer node.
[0181] Optionally, determining the target consumer node corresponding to the target event from the one or more preset consumer nodes based on the current load of the message partitions corresponding to the target topic and each of the preset consumer nodes includes:
[0182] From the above one or more preset consumer nodes, determine a preset number of candidate consumer nodes that have registered message partitions in the above target topic.
[0183] The current load of the message partition corresponding to each candidate consumer node is determined based on the number of messages in the message partition corresponding to each candidate consumer node.
[0184] Candidate consumer nodes whose current load is less than the preset load threshold will be selected as the target consumer nodes.
[0185] Optionally, the above method may further include:
[0186] The system receives a republishing instruction from the target consumer node, which is sent by the target consumer node in response to an anomaly notification. The anomaly notification is sent by the cache server to the target consumer node when an anomaly occurs in the heartbeat data. The heartbeat data is sent by the target consumer node to the cache server at a preset frequency.
[0187] In response to the above republishing instruction, the above target event is published to other consumer nodes besides the above target consumer node.
[0188] Optionally, the above method may further include:
[0189] Receive a notification of unsubscribed success sent by the target consumer node for the target event. The notification of unsubscribed success is used to indicate that the target consumer node has not stored the event execution status of the target event in the preset database.
[0190] In response to the above unsuccessful subscription notification, the target event is republished to the target message partition.
[0191] The following describes an event scheduling method disclosed herein, with the target consumer node as the execution subject. Figure 7 This is a flowchart illustrating another event scheduling method according to an exemplary embodiment. For example... Figure 7 As shown, the event scheduling method may include:
[0192] In step S51, a target event is obtained from the target message partition corresponding to the local consumer node; the target event is published to the corresponding target message partition by the task publishing server; the local consumer node is determined by the task publishing server from the one or more preset consumer nodes based on the target topic and the current load of the message partitions corresponding to the one or more preset consumer nodes; the target topic is determined by the task publishing server in response to the publication request of the target event, and the target topic corresponds to the event type of the target event; the message partition corresponding to the preset consumer node is obtained by the preset consumer node registering in the corresponding topic, and the corresponding topic represents the topic corresponding to the event type of the preset consumer node, and the event type of the preset consumer node represents the event type corresponding to the events that the preset consumer node can process.
[0193] In step S53, the aforementioned target event is processed.
[0194] In one exemplary embodiment, the above method may further include:
[0195] Heartbeat data is sent to the cache server at a preset frequency.
[0196] Receive the exception notification from the aforementioned cache server to the aforementioned target consumer node when the aforementioned heartbeat data is abnormal.
[0197] In response to the aforementioned anomaly notification, a republishing instruction is sent to the aforementioned task publishing server. The republishing instruction instructs the publishing of the aforementioned target event to other consumer nodes besides the aforementioned target consumer node.
[0198] In one exemplary implementation, after obtaining the target event from the target message partition corresponding to the local consumer node, the method further includes:
[0199] Store the execution status of the aforementioned target events in a preset database.
[0200] Send a subscription success notification corresponding to the above target event to the above task publishing server.
[0201] In one exemplary embodiment, the above method may further include:
[0202] If the execution status of the above-mentioned event is not stored in the above-mentioned preset database, a notification of unsuccessful subscription corresponding to the above-mentioned target event is sent to the above-mentioned task publishing server.
[0203] In one exemplary implementation, after obtaining the target event from the target message partition corresponding to the local consumer node, the method further includes:
[0204] Determine the target workload required to handle the aforementioned target events.
[0205] Send the target load to the cache server.
[0206] In one exemplary embodiment, after storing the event execution status of the target event in a preset database, the method further includes:
[0207] A load update instruction is sent to the aforementioned cache server, which records the current load of the message partition corresponding to each of the one or more preset consumer nodes. The load update instruction instructs the current load of the target message partition to be updated based on the target load.
[0208] In an optional embodiment, this disclosure also provides an event scheduling system, which may include at least a task publishing server and target consumer nodes;
[0209] The task publishing server can be used to respond to a publishing request for a target event, determine a target topic corresponding to the event type of the target event; and determine a target consumer node corresponding to the target event from the one or more preset consumer nodes based on the target topic and the current load of the message partitions corresponding to the one or more preset consumer nodes; the message partitions corresponding to the preset consumer nodes are obtained by the preset consumer nodes registering in the corresponding topics, the corresponding topics representing the topics corresponding to the event type of the preset consumer nodes, and the event type of the preset consumer nodes representing the event types corresponding to the events that the preset consumer nodes can process; and publish the target event to the target message partition corresponding to the target consumer node.
[0210] This target consumer node can be used to retrieve the target events from the corresponding target message partitions and to process the target events.
[0211] Figure 8 This is a block diagram illustrating an event scheduling device according to an exemplary embodiment. (Refer to...) Figure 8 The device may include a publish request response module 61, a target consumer node determination module 63, and a publish module 65.
[0212] The publish request response module 61 is configured to execute a publish request in response to a target event and determine the target topic corresponding to the event type of the target event.
[0213] The target consumer node determination module 63 is configured to determine the target consumer node corresponding to the target event from the one or more preset consumer nodes based on the current load of the message partitions corresponding to the target topic and the one or more preset consumer nodes respectively; the message partitions corresponding to the preset consumer nodes are obtained by the preset consumer nodes registering in the corresponding topics, the corresponding topics representing the topics corresponding to the event type of the preset consumer nodes, and the event type of the preset consumer nodes representing the event type corresponding to the events that the preset consumer nodes can process.
[0214] The publishing module 65 is configured to publish the aforementioned target event to the target message partition corresponding to the aforementioned target consumer node.
[0215] In one exemplary embodiment, the target consumer node determination module may include:
[0216] The candidate consumer node determination unit is configured to determine a preset number of candidate consumer nodes from one or more preset consumer nodes that have registered message partitions in the target topic.
[0217] The current load determination unit is configured to determine the current load of the message partition corresponding to each candidate consumer node based on the number of current messages in the message partition corresponding to each candidate consumer node.
[0218] The target consumer node determination unit is configured to select candidate consumer nodes whose current load is less than a preset load threshold as the aforementioned target consumer nodes.
[0219] In one exemplary embodiment, the above-described apparatus may further include:
[0220] The redistribution instruction receiving module is configured to receive redistribution instructions sent by the target consumer node. The redistribution instructions are sent by the target consumer node in response to an exception notification. The exception notification is sent by the cache server to the target consumer node when an anomaly occurs in the heartbeat data. The heartbeat data is sent by the target consumer node to the cache server at a preset frequency.
[0221] The redistribution instruction response module is configured to respond to the aforementioned redistribution instruction by publishing the aforementioned target event to other consumer nodes besides the aforementioned target consumer node.
[0222] In one exemplary embodiment, the above-described apparatus may further include:
[0223] The module for receiving unsubscribed success notifications is configured to receive unsubscribed success notifications corresponding to the target event sent by the target consumer node. The unsubscribed success notifications are used to indicate that the target consumer node has not stored the event execution status of the target event in the preset database.
[0224] The Unsubscribed Success Notification Response module is configured to respond to the aforementioned Unsubscribed Success Notification by republishing the target event to the aforementioned target message partition.
[0225] Figure 9 This is a block diagram of another event scheduling apparatus according to an exemplary embodiment. (Refer to...) Figure 9 The device may include a target event acquisition module 71 and a processing module 73.
[0226] The target event acquisition module 71 is configured to acquire a target event from the target message partition corresponding to the local consumer node; the target event is published to the corresponding target message partition by the task publishing server; the local consumer node is determined by the task publishing server from one or more preset consumer nodes based on the target topic and the current load of the message partitions corresponding to one or more preset consumer nodes; the target topic is determined by the task publishing server in response to the publication request of the target event, and the target topic corresponds to the event type of the target event; the message partition corresponding to the preset consumer node is registered by the preset consumer node in the corresponding topic, the corresponding topic represents the topic corresponding to the event type of the preset consumer node, and the event type of the preset consumer node represents the event type corresponding to the events that the preset consumer node can process.
[0227] The processing module 73 is configured to perform the processing of the aforementioned target event.
[0228] In one exemplary embodiment, the above-described apparatus may further include:
[0229] The heartbeat data sending module is configured to send heartbeat data to the cache server at a preset frequency.
[0230] The exception notification receiving module is configured to receive exception notifications from the target consumer node returned by the cache server when the heartbeat data is abnormal.
[0231] The exception notification response module is configured to respond to the above exception notification by sending a redistribution instruction to the above task publishing server. The redistribution instruction instructs the publishing of the above target event to other consumer nodes besides the above target consumer node.
[0232] In one exemplary embodiment, the above-described apparatus may further include:
[0233] The storage module is configured to store the event execution status of the aforementioned target event in a preset database;
[0234] The subscription success notification sending module is configured to send the subscription success notification corresponding to the above target event to the above task publishing server.
[0235] In one exemplary embodiment, the above-described apparatus may further include:
[0236] The module for sending unsubscribed success notifications is configured to send an unsubscribed success notification corresponding to the target event to the task publishing server if the execution status of the event is not stored in the preset database.
[0237] In one exemplary embodiment, the above-described apparatus may further include:
[0238] The target load determination module is configured to determine the target load required to process the aforementioned target event.
[0239] The target load sending module is configured to send the aforementioned target load to the cache server.
[0240] In one exemplary embodiment, the above-described apparatus may further include:
[0241] The load update instruction sending module is configured to send a load update instruction to the cache server, which records the current load of the message partition corresponding to each of the one or more preset consumer nodes. The load update instruction indicates that the current load of the target message partition is updated based on the target load.
[0242] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0243] In an exemplary embodiment, an electronic device is also provided, including a processor; a memory for storing processor-executable instructions; wherein, when the processor is configured to execute the instructions stored in the memory, it implements the steps of any of the event scheduling methods described above.
[0244] The electronic device can be a terminal, a server, or a similar computing device. Taking a server as an example... Figure 10This is a block diagram of an electronic device 80 for event scheduling, illustrated according to an exemplary embodiment. The electronic device 80 can vary significantly due to different configurations or performance characteristics. It may include one or more central processing units (CPUs) 81 (CPUs 81 may include, but are not limited to, microprocessors (MCUs) or programmable logic devices (FPGAs), a memory 83 for storing data, and one or more storage media 82 (e.g., one or more mass storage devices) for storing application programs 823 or data 822. The memory 83 and storage media 82 may be temporary or persistent storage. The program stored in the storage media 82 may include one or more modules, each module including a series of instruction operations on the electronic device. Furthermore, the CPU 81 may be configured to communicate with the storage media 82 and execute the series of instruction operations in the storage media 82 on the electronic device 80. Electronic device 80 may also include one or more power supplies 86, one or more wired or wireless network interfaces 85, one or more input / output interfaces 84, and / or one or more operating systems 821, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0245] The input / output interface 84 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the electronic device 80. In one example, the input / output interface 84 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In an exemplary embodiment, the input / output interface 84 may be a radio frequency (RF) module for wireless communication with the Internet.
[0246] Those skilled in the art will understand that Figure 10 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, electronic device 80 may also include components that are more... Figure 10 The more or fewer components shown, or having the same Figure 10 The different configurations shown.
[0247] In an exemplary embodiment, a computer-readable storage medium is also provided, which, when the instructions in the computer-readable storage medium are executed by the processor of an electronic device, enables the electronic device to perform the steps of any of the event scheduling methods described above.
[0248] In an exemplary embodiment, a computer program product is also provided, including a computer program that, when executed by a processor, implements the event scheduling method provided in any of the above embodiments.
[0249] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this disclosure can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0250] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0251] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. An event scheduling method, characterized in that, include: In response to a publication request for a target event, a target topic corresponding to the event type of the target event is determined; The target subject may be one or more; From one or more preset consumer nodes, determine a preset number of candidate consumer nodes that have registered message partitions in the target topic; Based on the current load of the message partition corresponding to each candidate consumer node, the target consumer node corresponding to the target event is determined from the preset number of candidate consumer nodes; the message partition corresponding to the preset consumer node is obtained by the preset consumer node registering in the corresponding topic, the corresponding topic represents the topic corresponding to the event type of the preset consumer node, and the event type of the preset consumer node represents the event type corresponding to the event that the preset consumer node can process; The target event is published to the target message partition corresponding to the target consumer node, so that the target consumer node can obtain the target event from the corresponding target message partition and process the target event. The target message partition is the message partition that receives the target event for the first time.
2. The event scheduling method according to claim 1, characterized in that, The method further includes: The current load of the message partition corresponding to each candidate consumer node is determined based on the number of current messages in the message partition corresponding to each candidate consumer node. The step of determining the target consumer node corresponding to the target event from the preset number of candidate consumer nodes based on the current load of the message partition corresponding to each candidate consumer node includes: The candidate consumer nodes whose current load is less than a preset load threshold among the preset number of candidate consumer nodes are selected as the target consumer nodes.
3. The event scheduling method according to claim 1, characterized in that, The method further includes: The system receives a republishing instruction from the target consumer node, which is sent by the target consumer node in response to an anomaly notification. The anomaly notification is sent by the cache server to the target consumer node when an anomaly occurs in the heartbeat data. The heartbeat data is sent by the target consumer node to the cache server at a preset frequency. In response to the republish instruction, the target event is published to other consumer nodes besides the target consumer node.
4. The event scheduling method according to any one of claims 1 to 3, characterized in that, The method further includes: Receive a non-subscription success notification sent by the target consumer node for the target event. The non-subscription success notification is used to indicate that the target consumer node has not stored the event execution status of the target event to the preset database. In response to the unsuccessful subscription notification, the target event is republished to the target message partition.
5. An event scheduling method, characterized in that, include: Retrieve the target event from the target message partition corresponding to the local consumer node; The target event is published by the task publishing server to the corresponding target message partition; The local consumer node is determined by the task publishing server from a preset number of candidate consumer nodes based on the current load of the message partition corresponding to each candidate consumer node. The task publishing server determines the preset number of candidate consumer nodes that have registered message partitions in the target topic from one or more preset consumer nodes. The target topic is determined by the task publishing server in response to the publishing request of the target event. There are one or more target topics, and the target topic corresponds to the event type of the target event. The message partition corresponding to the preset consumer node is obtained by the preset consumer node registering in the corresponding topic. The corresponding topic represents the topic corresponding to the event type of the preset consumer node, and the event type of the preset consumer node represents the event type corresponding to the events that the preset consumer node can process. The target message partition is the message partition that receives the target event for the first time; Process the target event.
6. The event scheduling method according to claim 5, characterized in that, The method further includes: Heartbeat data is sent to the cache server at a preset frequency; Receive the abnormal notification from the cache server to the local consumer node when the heartbeat data is abnormal; In response to the abnormal notification, a republishing instruction is sent to the task publishing server, which instructs the target event to be published to other consumer nodes besides the local consumer node.
7. The event scheduling method according to claim 5, characterized in that, After obtaining the target event from the target message partition corresponding to the local consumer node, the method further includes: Store the event execution status of the target event in a preset database; Send a subscription success notification corresponding to the target event to the task publishing server.
8. The event scheduling method according to claim 7, characterized in that, The method further includes: If the execution status of the event is not stored in the preset database, a notification of unsuccessful subscription corresponding to the target event is sent to the task publishing server.
9. The event scheduling method according to claim 7 or 8, characterized in that, After obtaining the target event from the target message partition corresponding to the local consumer node, the method further includes: Determine the target workload required to process the target event; Send the target load to the cache server.
10. The event scheduling method according to claim 9, characterized in that, After storing the event execution status of the target event in a preset database, the method further includes: A load update instruction is sent to the cache server, which records the current load of the message partition corresponding to each of the one or more preset consumer nodes. The load update instruction indicates that the current load of the target message partition be updated based on the target load.
11. An event scheduling system, characterized in that, include: Task publishing server and target consumer node; The task publishing server is configured to respond to a publishing request for a target event, determine a target topic corresponding to the event type of the target event; there are one or more target topics; and determine a preset number of candidate consumer nodes from one or more preset consumer nodes that have registered message partitions in the target topic; and determine the target consumer node corresponding to the target event from the preset number of candidate consumer nodes based on the current load of the message partitions corresponding to each candidate consumer node; the message partitions corresponding to the preset consumer node are obtained by the preset consumer node registering in the corresponding topic, the corresponding topic representing the topic corresponding to the event type of the preset consumer node, and the event type representing the event type corresponding to the events that the preset consumer node can process; And a means for publishing the target event to the target message partition corresponding to the target consumer node, so that the target consumer node can obtain the target event from the corresponding target message partition and process the target event; The target message partition is the message partition that receives the target event for the first time; The target consumer node is used to obtain the target event from the corresponding target message partition; And for processing the target event.
12. An event scheduling device, characterized in that, include: The publish request and response module is configured to execute a publish request in response to a target event, and to determine a target topic corresponding to the event type of the target event; the target topic may be one or more. The target consumer node determination module is configured to perform the following actions: First, determine a preset number of candidate consumer nodes from one or more preset consumer nodes that have registered message partitions in the target topic. Then, based on the current load of the message partition corresponding to each candidate consumer node, determine the target consumer node corresponding to the target event from the preset number of candidate consumer nodes. The message partition corresponding to the preset consumer node is obtained by registering the preset consumer node in a corresponding topic. The corresponding topic represents the topic corresponding to the event type of the preset consumer node, and the event type of the preset consumer node represents the event type corresponding to the events that the preset consumer node can process. The publishing module is configured to publish the target event to the target message partition corresponding to the target consumer node, so that the target consumer node can obtain the target event from the corresponding target message partition and process the target event. The target message partition is the message partition that receives the target event for the first time.
13. The event scheduling device according to claim 12, characterized in that, The device further includes: The current load determination unit is configured to determine the current load of the message partition corresponding to each candidate consumer node based on the number of current messages in the message partition corresponding to each candidate consumer node. The target consumer node determination module includes: The target consumer node determination unit is configured to select candidate consumer nodes whose current load is less than a preset load threshold from the preset number of candidate consumer nodes as the target consumer nodes.
14. The event scheduling device according to claim 12, characterized in that, The device further includes: The redistribution instruction receiving module is configured to receive redistribution instructions sent by the target consumer node. The redistribution instruction is sent by the target consumer node in response to an anomaly notification. The anomaly notification is sent by the cache server to the target consumer node when an anomaly occurs in the heartbeat data. The heartbeat data is sent by the target consumer node to the cache server at a preset frequency. The redistribution instruction response module is configured to respond to the redistribution instruction by publishing the target event to other consumer nodes besides the target consumer node.
15. The event scheduling apparatus according to any one of claims 12 to 14, characterized in that, The device further includes: The unsubscribed success notification receiving module is configured to receive the unsubscribed success notification corresponding to the target event sent by the target consumer node. The unsubscribed success notification is used to indicate that the target consumer node has not stored the event execution status of the target event in a preset database. The unsubscribed success notification response module is configured to respond to the unsubscribed success notification by republishing the target event to the target message partition.
16. An event scheduling device, characterized in that, include: The target event acquisition module is configured to retrieve target events from the target message partition corresponding to the local consumer node; The target event is published by the task publishing server to the corresponding target message partition; the local consumer node is determined by the task publishing server from a preset number of candidate consumer nodes based on the current load of the message partition corresponding to each candidate consumer node; the task publishing server determines the preset number of candidate consumer nodes that have registered message partitions in the target topic from one or more preset consumer nodes; the target topic is determined by the task publishing server in response to the publication request of the target event, and there are one or more target topics, which correspond to the event type of the target event; the message partition corresponding to the preset consumer node is obtained by the preset consumer node registering in the corresponding topic, and the corresponding topic represents the topic corresponding to the event type of the preset consumer node, and the event type of the preset consumer node represents the event type corresponding to the events that the preset consumer node can process; The target message partition is the message partition that receives the target event for the first time; The processing module is configured to perform processing of the target event.
17. The event scheduling device according to claim 16, characterized in that, The device further includes: The heartbeat data sending module is configured to send heartbeat data to the cache server at a preset frequency; An exception notification receiving module is configured to receive an exception notification from the cache server to the local consumer node when the heartbeat data is abnormal. An exception notification response module is configured to respond to the exception notification by sending a redistribution instruction to the task publishing server, wherein the redistribution instruction instructs the target event to be published to other consumer nodes besides the local consumer node.
18. The event scheduling device according to claim 16, characterized in that, The device further includes: The storage module is configured to store the event execution status of the target event in a preset database; The subscription success notification sending module is configured to send the subscription success notification corresponding to the target event to the task publishing server.
19. The event scheduling device according to claim 18, characterized in that, The device further includes: The module for sending unsubscribed success notifications is configured to send an unsubscribed success notification corresponding to the target event to the task publishing server if the event execution status is not stored in the preset database.
20. The event scheduling device according to claim 18 or 19, characterized in that, The device further includes: A target load determination module is configured to determine the target load required to process the target event. The target load sending module is configured to send the target load to the cache server.
21. The event scheduling device according to claim 20, characterized in that, The device further includes: The load update instruction sending module is configured to send a load update instruction to the cache server, which records the current load of the message partition corresponding to each of the one or more preset consumer nodes. The load update instruction indicates that the current load of the target message partition should be updated based on the target load.
22. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the event scheduling method as described in any one of claims 1 to 10.
23. A computer-readable storage medium, wherein when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device performs the event scheduling method as described in any one of claims 1 to 10.
24. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the event scheduling method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Message processing method and device based on message queue system
CN107197015A