An event-driven service message processing and routing method, device, computer equipment and readable storage medium for improving system elasticity
Through intelligent message distribution algorithm and routing strategy, the service node weights and call paths are dynamically adjusted, which solves the problem of insufficient elasticity of traditional systems under high concurrency and failure, and achieves stable and efficient system operation and continuity of business processes.
Patent Information
- Application Number
- CN202510542658.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2045-04-28
AI Technical Summary
Under the traditional architecture, the system is not elastic when facing high concurrency and failure, and the service message processing and routing efficiency are low, resulting in slow response or crash, making it difficult to meet user needs.
The intelligent message distribution algorithm is used to determine the message distribution weight, select the target service node based on the weight, dynamically adjust the call path in combination with the intelligent routing strategy, and transfer requests in the event of failure, support message retry and dead letter queue mechanisms, and monitor performance indicators in real time to trigger the tuning strategy.
Improve system flexibility, enhance the ability to respond to high concurrency and faults, ensure the stable and efficient operation of the system, and ensure the continuity of key business processes and user experience.
Smart Images

Figure CN120075302B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of message processing, and in particular to an event-driven service message processing and routing method, apparatus, computer equipment, and readable storage medium for improving system flexibility. Background Art
[0002] With the advancement of information technology, distributed systems are growing in scale and complexity, and inter-service dependencies are becoming increasingly complex. Traditional architectures lack resilience to high concurrency and failures, and service message processing and routing are inefficient, severely impacting system performance and stability. Traditional approaches fail to rationally allocate processing tasks, often leading to overloaded services, slow responses, and even service crashes. This makes it difficult to meet user demands for fast system responses and stable operation. Summary of the Invention
[0003] The object of the present invention is to provide an event-driven service message processing and routing method, apparatus, computer equipment and readable storage medium that improve system flexibility.
[0004] In a first aspect, an embodiment of the present invention provides an event-driven service message processing and routing method for improving system flexibility, comprising:
[0005] Get pending messages;
[0006] Determine the message distribution weight of the to-be-processed message for each service node using an intelligent message distribution algorithm;
[0007] Determine the target service node based on the message distribution weight, execute the business logic of the message to be processed and return the result.
[0008] In a possible implementation, the intelligent message distribution algorithm is: ,in, is an exponential decay function based on the rate of change of the backlog messages of service node i, is the assigned weight of service node i at time t, is the inherent priority of the message, is the real-time load rate of node i, is the rate of change of the message backlog of node i, 、 is the adaptive coefficient, is the elasticity factor, is the attenuation coefficient, is the total number of service nodes.
[0009] In one possible implementation, the method further includes:
[0010] On the basis that the message to be processed needs to make a service call, a call routing path is dynamically determined based on an intelligent routing strategy.
[0011] In a possible implementation, the intelligent routing strategy is to dynamically adjust the call path between services based on the dependencies and load conditions between services;
[0012] The method further comprises:
[0013] If a service failure occurs in the call routing path, the service call request is transferred to a normal service node.
[0014] In one possible implementation, the method further includes:
[0015] When the pending message fails to be sent, it will automatically retry until the pending message is processed;
[0016] The method also includes:
[0017] If the pending message cannot be processed, the pending message is placed in a dead letter queue.
[0018] In one possible implementation, the method further includes:
[0019] Monitor the operating status and performance indicators of all services according to the preset monitoring cycle;
[0020] When the operating status and performance indicators of any service reach the potential abnormality threshold, the preset performance tuning and fault recovery strategies are triggered.
[0021] In a possible implementation, determining a target service node based on a message distribution weight, executing service logic of the message to be processed, and returning a result includes:
[0022] Determine a target service node based on the message distribution weight;
[0023] Processing the to-be-processed message by the target service node based on a unified event processing interface and a unified event processing process;
[0024] After the processing of the pending message is completed, the processing result is returned to the caller of the pending message.
[0025] In a second aspect, an embodiment of the present invention provides an event-driven service message processing and routing device for improving system flexibility, comprising:
[0026] The acquisition module is used to obtain messages to be processed;
[0027] A distribution module, configured to determine a message distribution weight of the to-be-processed message for each service node using an intelligent message distribution algorithm;
[0028] The execution module is used to determine the target service node based on the message distribution weight, execute the business logic of the message to be processed and return the result.
[0029] In a third aspect, an embodiment of the present invention provides a computer device, comprising a processor and a non-volatile memory storing computer instructions, wherein when the computer instructions are executed by the processor, the computer device executes the method described in the first aspect.
[0030] In a fourth aspect, an embodiment of the present invention provides a readable storage medium, wherein the readable storage medium includes a computer program, and when the computer program is executed, the computer device where the readable storage medium is located is controlled to execute the method described in the first aspect.
[0031] Compared to existing technologies, the present invention offers the following advantages: The disclosed event-driven service message processing and routing method, apparatus, computer device, and readable storage medium for enhancing system resilience employ a method, apparatus, and computer device, and utilizes an intelligent message distribution algorithm to obtain pending messages, determine the message distribution weights for each service node based on the status of each node, and finally select a target service node based on the weights, execute the pending message business logic, and return the results. This method achieves reasonable message distribution and efficient processing, improves system resilience, enhances the system's ability to cope with high concurrency and failures, and ensures stable and efficient system operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly describes the drawings required for use in the embodiments. It should be understood that the following drawings illustrate only certain embodiments of the present invention and should not be construed as limiting the scope of the present invention. Those skilled in the art can, without inventive effort, derive other relevant drawings from these drawings.
[0033] Figure 1 A schematic flow chart of the steps of an event-driven service message processing and routing method for improving system flexibility provided by an embodiment of the present invention;
[0034] Figure 2 A schematic diagram of the overall workflow provided by an embodiment of the present invention;
[0035] Figure 3 A schematic block diagram of the structure of an event-driven service message processing and routing device for improving system flexibility provided by an embodiment of the present invention;
[0036] Figure 4A schematic block diagram of the structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings of the embodiments of the present invention. It should be understood that the described embodiments are only a portion of the embodiments of the present invention, not all of them. Generally, the components of the embodiments of the present invention described and illustrated in the drawings herein may be arranged and designed in a variety of different configurations.
[0038] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0039] In order to solve the technical problems in the above background technology, Figure 1 This is a flow chart of an event-driven service message processing and routing method for improving system elasticity provided by an embodiment of the present disclosure. The event-driven service message processing and routing method for improving system elasticity is introduced in detail below.
[0040] Step S201, obtaining a message to be processed;
[0041] Step S202: Determine the message distribution weight of the to-be-processed message for each service node using an intelligent message distribution algorithm;
[0042] Step S203: determine the target service node based on the message distribution weight, execute the service logic of the message to be processed and return the result.
[0043] In the embodiment of the present invention, for example, a server environment of a large e-commerce platform generates a massive amount of messages every day. These messages cover various user operations, such as product browsing, ordering, payment, and review, as well as various internal system events, such as inventory updates and logistics status changes.
[0044] For example, when a user browses products on an e-commerce platform, the server records this browsing behavior and generates a corresponding message. This message contains detailed information such as the user's ID, the product information browsed, and the browsing time. At this point, the server receives a message to be processed.
[0045] For example, when a product's inventory changes, the inventory management system sends an inventory change message to the server. This message may include the product's SKU, the quantity changed, the time of the change, and the reason for the change (e.g., a sale, restocking, etc.). The server also places this message in its pending message queue.
[0046] For example, after the payment process is completed, the payment system will send a payment success message to the server. This message contains key information such as the order number, payment amount, payment method, and payment time, and the server receives it as a pending message.
[0047] Servers typically have a message receiving queue that receives messages from various sources. This queue can be a memory-based queue, such as RabbitMQ or Kafka. Kafka, for example, offers high throughput and scalability, making it ideal for handling massive message volumes like those on e-commerce platforms. Each business system sends messages to designated Kafka topics, and servers subscribe to these topics to obtain pending messages.
[0048] When a server retrieves pending messages from a message queue, it removes them in a specific order (such as first-in, first-out). While retrieving messages, the server performs preliminary validation and parsing. For example, it checks whether the message format is correct and contains required fields. If the message format is incorrect, the server may mark it as an exception and log the relevant information for subsequent analysis and processing. For correctly formatted messages, the server passes them on to further processing.
[0049] In the server architecture of an e-commerce platform, there are multiple service nodes with different functions, such as product service nodes, order service nodes, user service nodes, inventory service nodes, etc. These service nodes each undertake different business logic processing tasks.
[0050] For example, when a server receives a product browsing message, the intelligent message distribution algorithm begins its work. The algorithm first analyzes the message type to determine if it's a product-related message. It then examines the current load of each product service node. Suppose that product service node A is currently processing relatively few requests, while product service node B is nearing its processing capacity limit. Based on this real-time load information, the algorithm assigns a higher message distribution weight to product service node A, such as 70%, and a lower weight to product service node B, such as 30%.
[0051] Let's look at inventory change messages. The intelligent message distribution algorithm considers the dependencies between the inventory service node and other related service nodes (such as the order service node and the logistics service node). If the current order service node is busy processing a large number of order creation requests, while the inventory service node is relatively idle, the algorithm will assign a higher weight to the inventory service node to ensure that inventory change messages are processed promptly, avoiding problems with subsequent order processing due to inaccurate inventory information. The algorithm also takes into account the priority of the message. For example, if it is an urgent inventory warning message indicating that a certain product is about to be out of stock, the algorithm will increase the weight of this message when it is distributed to the inventory service node, giving it priority processing.
[0052] For payment success messages, the intelligent message distribution algorithm assigns weights to the order service node and user service node based on their business needs and current load. The order service node needs to update the order status to paid, while the user service node may need to update information such as the user's spending history and account balance. Assuming the order service node is currently under moderate load and the user service node is under light load, the algorithm might assign 60% weight to the order service node and 40% to the user service node. This ensures timely updates of order status while also maximizing the synchronization of user-related information.
[0053] The intelligent message distribution algorithm also considers differences in service node processing capabilities when determining message distribution weights. Different service nodes may have varying processing speeds and throughputs due to factors such as hardware configuration and software optimization. For example, the newly upgraded Product Service Node C utilizes more efficient caching technology and algorithm optimizations, processing product-related messages 30% faster than other Product Service Nodes. Therefore, when distributing product-related messages, the algorithm will appropriately increase the weight of Product Service Node C to fully leverage its processing advantages and improve overall system processing efficiency.
[0054] Continuing with the example of product browsing messages, based on the weights determined by the intelligent message distribution algorithm, assume that Product Service Node A receives a 70% weight and Product Service Node B receives a 30% weight. The server uses a random number generator or other probabilistic selection algorithm to determine the target service node based on these weights. If the generated random number falls within the weight range corresponding to Product Service Node A (e.g., 0-70), Product Service Node A is selected as the target service node.
[0055] After receiving the product browsing message, Product Service Node A begins executing the corresponding business logic. It first queries the database for detailed information about the product, including its name, description, price, and image. It then updates the product's browsing statistics, incrementing the number of views by 1. Next, it may recommend related products based on the user's browsing history and behavior. For example, if the user frequently browses electronics, Product Service Node A will filter out popular products from the electronics category or products similar to the currently viewed item as recommendations.
[0056] After completing these business logic processes, Product Service Node A returns the results to the server. These results may include detailed product information and a list of recommended products. The server then passes these results to the front-end application for display to the user.
[0057] For inventory change messages, if the target service node determined by weight is an inventory service node, upon receiving the message, the inventory service node will first verify the legitimacy of the inventory change. For example, it will check whether the inventory reduction exceeds the current actual inventory quantity. If so, an error message will be returned. If the inventory change is legal, the inventory service node will update the inventory data in the database and log the inventory change. At the same time, it will check whether the inventory change has triggered the inventory warning mechanism. If the inventory quantity of a certain product falls below the set warning threshold, the inventory service node will generate an inventory warning message and send it to the relevant management system to notify staff to restock in a timely manner. After completing these operations, the inventory service node will return the result of the successful inventory change to the server.
[0058] In the payment success message processing scenario, if the order service node is selected as the target service node, upon receiving the message, the order service node will query the order details based on the order number. After confirming the order information is correct, it will update the order status to "paid" and record relevant information such as the payment time. At the same time, the order service node may trigger a series of subsequent operations, such as notifying the logistics system to prepare for shipment and updating the order's financial information. After completing these business logic processes, the order service node returns a successful order status update result to the server. The server then feeds this result back to the payment system and front-end application, notifying the user that the payment was successful and the order has entered the subsequent processing flow.
[0059] If an error occurs while executing the business logic for a pending message, such as a database query failure or a network connection interruption, the target service node will handle the error accordingly. It may attempt to retry the operation, such as requerying the database or reestablishing the network connection. If multiple retries fail, the target service node returns an error message to the server, which will log the error and may take further action, such as notifying the system administrator or placing the message in a dead letter queue for subsequent analysis and processing.
[0060] The detailed scenario examples above illustrate how this approach works in a real-world e-commerce platform server environment. By rationally acquiring pending messages, intelligently determining message distribution weights, and accurately selecting target service nodes and executing the corresponding business logic, this approach effectively improves system resilience and responsiveness, ensuring stable and efficient operation of the e-commerce platform despite massive message volumes and complex business scenarios.
[0061] In an embodiment of the present invention, the intelligent message distribution algorithm is:
[0062] ,in, is an exponential decay function based on the rate of change of the backlog messages of service node i, is the assigned weight of service node i at time t, is the intrinsic priority of the message (static parameter, 0.5≤ ≤1.5), is the real-time load rate of node i (CPU / memory comprehensive index), is the rate of change of the message backlog of node i, 、 is the adaptive coefficient (the sum of the two = 1), is the elasticity factor (default 0.2, adaptive growth is activated when the system load is > 70%), is the attenuation coefficient (controls the sensitivity of the backlog effect and is positively correlated with the node computing power), is the total number of service nodes.
[0063] In this embodiment of the present invention, for example, assume that this is a server for a large online education platform. The platform has numerous service nodes, such as course service nodes, user service nodes, and homework service nodes, which process various messages, such as course registration and homework submission.
[0064] The server receives a pending message about a student submitting an assignment. This message has an inherent priority, such as a higher priority due to an approaching deadline.
[0065] At this point, the server begins to use the intelligent message distribution algorithm to determine the message distribution weight of each service node.
[0066] For course service node i, the server first calculates the exponential decay function value associated with the rate of change of its backlog messages. Assume that the course service node is currently processing a large number of course update messages, resulting in a high rate of change in the backlog and a high real-time load. According to the formula, as the backlog increases, the exponential decay function value decreases.
[0067] However, the backlog of job service node j has a small change rate and low real-time load. In the algorithm, its exponential decay function value is relatively large.
[0068] The inherent priority of the message affects the weight assigned to each node. Since the inherent priority of the message submitted by the job is high, the weight of the relevant node will be increased when calculating the weight assigned to each node.
[0069] The adaptive coefficient will be adjusted based on the long-term operation status of the system and the characteristics of different service nodes. For example, if the platform has recently experienced many job-related issues and needs to focus on ensuring job processing, the adaptive coefficient related to the job service node will be appropriately increased.
[0070] The elasticity factor and decay coefficient combine to consider system elasticity and message processing stability. To ensure greater system resilience under load fluctuations, the elasticity factor is adjusted appropriately; to prevent drastic weight changes, the decay coefficient is appropriately set.
[0071] After calculation, the job service node is determined to be the target service node because of its small backlog message change rate and low real-time load, and has a higher allocation weight.
[0072] After receiving the message, the homework service node executes the business logic of the homework submission, such as storing the homework data in the database, checking whether the format is correct, etc. After completion, it returns the successful processing result to the server, and the server then feeds back the result to the student client.
[0073] In the embodiments of the present invention, the following implementation modes are also provided.
[0074] On the basis that the message to be processed needs to make a service call, a call routing path is dynamically determined based on an intelligent routing strategy.
[0075] In the embodiment of the present invention, for example, taking the server of an online travel booking platform as an example, the platform covers multiple services such as hotel booking, air ticket booking, and attraction ticket booking, and each service is provided by a different service node.
[0076] The server receives a pending message about a user booking a hotel. While processing the message, it determines whether a service call is needed. For example, it calls the hotel inventory service node to confirm the availability of rooms at the selected hotel, or calls the price service node to obtain the real-time room rate.
[0077] At this point, the server dynamically determines the call routing path based on the intelligent routing strategy, which takes into account the dependencies between services and the load of each service node.
[0078] For hotel inventory service nodes, assume there are multiple nodes currently providing this service. Node A recently underwent a hardware upgrade, increasing its processing power, but its load is currently at 70%. Node B, however, has slightly lower processing power and is currently at 40%. The intelligent routing strategy considers Node B's relatively low load and the high real-time requirements of the hotel inventory service. If processing delays in Node A due to high load could affect the user experience, it will favor Node B.
[0079] At the same time, the hotel booking message also needs to call the price service node. The platform has domestic price service nodes and international price service nodes. Since this reservation is for a domestic hotel, the intelligent routing strategy gives priority to the domestic price service node based on the dependencies between services.
[0080] Furthermore, the intelligent routing strategy monitors service status in real time. If, during the routing process, a previously selected service node experiences a failure, such as a network outage at Hotel Inventory Service Node B, the intelligent routing strategy will immediately reassess and redirect the call to another available Hotel Inventory Service Node, such as Node A, ensuring the booking process remains unaffected.
[0081] For example, if tourism in a certain region of China has recently increased, hotel bookings in that region will increase, leading to increased load on the nodes handling hotel-related services in that region. Intelligent routing policies will dynamically adjust and redirect some booking message calls to other, less-loaded, similar service nodes, achieving load balancing.
[0082] By dynamically determining the call routing path based on intelligent routing strategies, the server can efficiently coordinate calls between service nodes, improve the efficiency and stability of the system in processing reservation messages, and provide users with a smooth hotel reservation service experience.
[0083] In the embodiment of the present invention, the intelligent routing strategy is to dynamically adjust the calling path between services according to the dependency relationship and load conditions between services;
[0084] The embodiments of the present invention also provide the following implementation methods.
[0085] If a service failure occurs in the call routing path, the service call request is transferred to a normal service node.
[0086] In the embodiment of the present invention, a comprehensive e-commerce server is taken as an example, which supports a series of services such as product display, ordering, payment, logistics, etc.
[0087] When the server receives a pending order message from a user, it needs to make multiple service calls to confirm the order. For example, it needs to call the inventory service to confirm product availability, call the price service to obtain the latest product price, and call the user service to verify user information.
[0088] Based on intelligent routing strategies, the server begins dynamically determining the call routing path. For example, when calling the inventory service, an e-commerce platform has multiple inventory service nodes responsible for inventory management in different regions. Suppose that Inventory Service Node A in South China is responsible for inventory in South China and its load is currently 30%, while Inventory Service Node B in East China is responsible for inventory in East China and its load is 70%. Since the user placing the order is in South China, based on inter-service dependencies, Inventory Service Node A in South China should be prioritized. Furthermore, considering that Node A has a lower load and can process requests more efficiently, the call path is determined to be Node A.
[0089] For price services, the platform has real-time price service node C and historical price service node D. Because placing an order requires obtaining real-time prices, the real-time price service node C is determined to be called based on the service dependency relationship.
[0090] However, unexpected situations may arise during the actual call process. For example, when the server is about to call inventory service node A in South China, the intelligent routing strategy detects that node A has experienced a sudden network failure and is unable to provide normal service. At this point, the server immediately implements emergency measures and transfers the inventory service call request to inventory service node B in East China. Although node B is relatively heavily loaded, it is still selected to handle the request to ensure the continuity of the order process.
[0091] Similarly, if, when calling the real-time price service node C, it is found that node C is temporarily unable to respond due to a data processing anomaly, the server will quickly transfer the price service call request to the backup real-time price service node E (assuming such a backup node exists) based on the intelligent routing strategy, ensuring that the product price information can be obtained in time and the order process can be completed.
[0092] By dynamically adjusting the call path based on inter-service dependencies and load conditions, and promptly transferring call requests to normal service nodes when service failures occur, the e-commerce server can effectively ensure the smooth progress of key business processes such as ordering, improve system stability and reliability, and provide users with an uninterrupted shopping service experience.
[0093] In the embodiments of the present invention, the following implementation modes are also provided.
[0094] When the pending message fails to be sent, it will automatically retry until the pending message is processed;
[0095] In the embodiments of the present invention, the following implementation modes are also provided.
[0096] If the pending message cannot be processed, the pending message is placed in a dead letter queue.
[0097] In the embodiment of the present invention, illustratively, a server of a large financial trading platform is taken as an example, and the platform carries multiple businesses such as stock trading and fund trading.
[0098] The server receives a pending stock purchase message from a user. To process this message, the server needs to interact with multiple systems, such as sending a trade instruction to the stock exchange and confirming the user's funds with the fund management system.
[0099] When sending trading instructions to the stock exchange, the message may fail to be sent due to network fluctuations, stock exchange system busyness, etc. In this case, the server follows the established rules and automatically retries.
[0100] During the first retry, the server reestablishes the network connection with the stock exchange and resends the stock buy order. If this retry fails, the server does not give up immediately but instead attempts a second time at a set interval. This interval may be set based on system configuration and empirical values. For example, starting with 1 second, the retry interval may double with each retry to avoid excessive network resource usage due to a large number of ineffective retries within a short period of time.
[0101] During the second retry, the server will check the network status, command format, and other aspects to ensure that there are no other potential issues affecting message delivery. If the second retry fails, the server will proceed to the third retry, repeating the above check and delivery steps.
[0102] In this way, the server keeps retrying automatically until the stock buy instruction is successfully sent to the stock exchange and confirmed, which means that the pending message is processed.
[0103] However, there are also extreme cases where the server cannot successfully process the pending message despite repeated retries, such as due to abnormal user account information or trading rules restrictions. For example, after multiple retries, it is discovered that the user's account has been frozen due to illegal operations. In this case, the stock purchase message can no longer be processed according to the normal process.
[0104] In this case, the server places the pending message in a dead letter queue. This queue is specifically designed to store unprocessed messages. Messages placed in the dead letter queue are tagged with a detailed reason for failure, such as "Account frozen, preventing transaction."
[0105] Subsequently, the platform's operations and maintenance personnel or relevant business departments can regularly review the dead letter queue, analyze the reasons for unprocessed messages, and address the issues accordingly. For example, if a transaction fails due to a frozen account, the transaction message may be reprocessed after contacting the user to resolve the account issue. Through this automatic retry and dead letter queue mechanism, the financial trading platform server can effectively manage abnormal situations while ensuring transaction reliability.
[0106] In the embodiments of the present invention, the following implementation modes are also provided.
[0107] Monitor the operating status and performance indicators of all services according to the preset monitoring cycle;
[0108] When the operating status and performance indicators of any service reach the potential abnormality threshold, the preset performance tuning and fault recovery strategies are triggered.
[0109] In the embodiment of the present invention, a large video streaming server is taken as an example. The server is responsible for processing a series of services such as video uploading, transcoding, storage, and distribution to user terminals.
[0110] The server monitors the operating status and performance indicators of all services at a preset monitoring interval, such as every 5 minutes. For video transcoding services, the server focuses on monitoring performance indicators such as CPU usage, memory usage, and transcoding task processing speed. For video distribution services, monitored indicators include network bandwidth utilization, concurrent connections, and response time.
[0111] At one point, the monitoring system detected that the CPU usage of the video transcoding service reached 85%, while the preset potential abnormality threshold was 80%. At the same time, the memory usage was also approaching the system-set potential abnormality threshold. This indicated that the operating status and performance indicators of the video transcoding service had reached the potential abnormality threshold.
[0112] At this point, the server immediately triggers the execution of pre-set performance tuning and fault recovery strategies. For the video transcoding service, due to high CPU usage, the server first attempts to dynamically adjust the priority of transcoding tasks. It pauses some transcoding tasks that don't require high real-time performance, prioritizing those that will be pushed to the user. Simultaneously, the server checks system resource allocation and discovers that high memory usage may be due to improper transcoding algorithm cache settings. It then adjusts the transcoding algorithm's cache strategy to free up some memory space.
[0113] If the above measures fail to effectively improve the performance of the video transcoding service, the server will further implement a fault recovery strategy. It will start a backup transcoding server node and offload some transcoding tasks to the backup node for processing. This will increase processing resources, reduce the load on the primary transcoding server, and gradually restore its performance indicators to normal range.
[0114] For example, when monitoring the video distribution service, network bandwidth utilization reached 95%, exceeding the preset 90% potential anomaly threshold, and response times also began to increase. The server triggered a preset strategy, first optimizing network routing. Using intelligent routing algorithms, it avoided congested links and selected smoother paths to distribute video data. If network bandwidth remained limited, the server would prioritize videos based on user viewing history and real-time demand. For less-demand videos, the server would distribute them at a lower resolution to reduce bandwidth usage and ensure smooth viewing for the majority of users.
[0115] By monitoring the service operation status and performance indicators according to the preset monitoring cycle and promptly triggering the preset performance tuning and fault recovery strategies when the potential abnormality threshold is reached, the video streaming server can maintain stable and efficient operation and provide users with a high-quality video service experience.
[0116] In the embodiment of the present invention, the determination of the target service node based on the message distribution weight, the execution of the service logic of the message to be processed and the return of the result can be implemented through the following examples.
[0117] Determine a target service node based on the message distribution weight;
[0118] Processing the to-be-processed message by the target service node based on a unified event processing interface and a unified event processing process;
[0119] After the processing of the pending message is completed, the processing result is returned to the caller of the pending message.
[0120] In an embodiment of the present invention, for example, taking a server of a large-scale food delivery platform as an example, the server needs to process various pending messages from merchants, riders, and users.
[0121] When a server receives a pending message for a user's order, it first determines the target service node based on the message distribution weight. Consider a food delivery platform's business architecture, where order processing services are collaboratively performed by multiple service nodes, including order dispatch nodes and inventory check nodes. The server uses an intelligent message distribution algorithm, taking into account factors such as each node's real-time load and business dependencies, to determine the message distribution weight. For example, order dispatch node A, with its low load and high processing efficiency, is assigned a higher message distribution weight and is therefore selected as the target service node for processing the order message.
[0122] Next, the target service node processes the pending message based on the unified event processing interface and the unified event processing process. After receiving the message, the order allocation node A receives the order message through the unified event processing interface. This unified event processing interface ensures that different types of messages can enter the processing process in a standardized manner. Then, in accordance with the unified event processing process, the order allocation node A first verifies the integrity of the order information, including product details, user address, contact number, etc. After confirmation, the real-time location and busy status of the rider are queried, and the order is assigned to the most suitable rider based on factors such as distance and busyness. Throughout the entire processing process, whether it is the verification of order information or the assignment of riders, the established unified event processing process is followed to ensure the accuracy and consistency of the processing.
[0123] After processing the pending message, Order Assignment Node A returns the processing result to the caller of the pending message. This caller is the user-related system that originally initiated the order request (such as the server behind the user's mobile app). Order Assignment Node A returns information about the successful assignment of the order to the rider, such as the rider's name, contact information, and estimated time of arrival, as the processing result. This allows users to view the assigned rider and related delivery progress information on the app, completing the entire order message process from receipt and processing to result feedback, ensuring the efficient operation of food delivery services.
[0124] In order to more clearly describe the solution provided by the embodiment of the present invention, a relatively complete implementation method is provided below. Figure 2 , Figure 2 A schematic diagram of the overall workflow provided by an embodiment of the present invention.
[0125] 1. Structure and function of the technical solution:
[0126] The present invention aims to propose an event-driven architecture technology that decouples service dependencies and improves system resilience and responsiveness. The technical solution consists of the following key modules:
[0127] Message Distribution Module: Responsible for efficient message distribution based on message type, priority, target service, and other information. By introducing an intelligent message distribution algorithm, this module can dynamically adjust the distribution strategy to ensure even distribution of messages across different services. It also supports mechanisms such as message retries and dead letter queues to ensure reliable message delivery.
[0128] Business Logic Processing Module: By defining a unified event processing interface and process, we achieve modularization and componentization of business logic. Developers only need to write event processing logic without having to worry about underlying details such as message distribution and processing, thus simplifying the development process and improving development efficiency.
[0129] Intelligent Routing Module: Dynamically adjusts the call path between services based on inter-service dependencies, load conditions, and other information. This module can perceive service status in real time, implement service load balancing and failover, and support automatic service discovery and registration, reducing the complexity of service management.
[0130] System Monitoring and Tuning Module: This module monitors the system's operating status, performance indicators, and other information in real time. Through automated performance tuning and fault recovery strategies, it promptly identifies and addresses potential issues, improving system stability and reliability.
[0131] 2. Working principle:
[0132] Message distribution mechanism optimization:
[0133] An intelligent message distribution algorithm is introduced, which dynamically adjusts the distribution strategy based on information such as message type, priority, target service, and real-time load conditions to ensure that messages are evenly distributed among different services.
[0134] Supports message retry mechanism. When message sending fails, it will automatically retry to ensure reliable message delivery.
[0135] Set up a dead letter queue. For messages that cannot be successfully processed, put them into the dead letter queue for subsequent analysis and processing.
[0136] Simplified business logic processing flow:
[0137] Define a unified event processing interface and process to modularize and componentize business logic. Developers only need to write event processing logic without having to worry about underlying details such as message distribution and processing.
[0138] In this way, the development process can be greatly simplified, development efficiency can be improved, and the complexity of system maintenance can be reduced.
[0139] Introduction of intelligent routing technology:
[0140] An intelligent routing algorithm is introduced, which dynamically adjusts the call path between services based on information such as the dependencies between services and load conditions.
[0141] Real-time perception of service status enables load balancing and failover of services. When a service fails, the intelligent routing algorithm automatically transfers requests to other available services, ensuring system continuity and stability.
[0142] Supports automatic discovery and registration of services, reducing the complexity of service management.
[0143] 3 Workflow:
[0144] Message reception and distribution:
[0145] The system receives messages from various services and passes them to the intelligent message distribution module.
[0146] The intelligent message distribution module selects an appropriate distribution strategy based on the message type, priority, target service, and real-time load conditions, and distributes the message to the corresponding service.
[0147] Business logic processing:
[0148] The received message is passed to the unified event processing interface.
[0149] According to the definition of the event processing process, call the corresponding event processing logic for processing.
[0150] After processing is complete, the result is returned to the caller.
[0151] Intelligent routing and calling:
[0152] During the business logic processing, if other services need to be called, the intelligent routing module will dynamically select the optimal calling path based on information such as the dependencies between services and load conditions.
[0153] If a service fails, the intelligent routing module will automatically transfer requests to other available services.
[0154] System monitoring and tuning:
[0155] The system monitoring module monitors the system's operating status, performance indicators and other information in real time.
[0156] When potential problems are discovered, the tuning strategy is automatically triggered to optimize and adjust the system.
[0157] Supports automated performance tuning and fault recovery strategies to improve system stability and reliability.
[0158] 4. The structure, connection relationship and functional relationship of each component of the technical solution:
[0159] Message distribution module: As one of the core components of the event-driven architecture, it connects to all services and is responsible for message reception, distribution, and retry mechanisms. This module uses intelligent algorithms to achieve efficient message distribution, ensuring that messages are accurately and quickly delivered to the target service.
[0160] Business Logic Processing Module: Connected to the Message Dispatching Module, it receives messages and executes the corresponding business logic. By defining a unified event processing interface and process, this module modularizes and componentizes business logic, simplifying the development process.
[0161] Intelligent Routing Module: Connected to the service registry and service callers, it dynamically adjusts the call paths between services based on information such as inter-service dependencies and load conditions. This module uses intelligent algorithms to achieve service load balancing and failover, improving system resilience and reliability.
[0162] System Monitoring and Tuning Module: Connected to all services, it monitors the system's operational status and performance metrics in real time. This module uses automated performance tuning and fault recovery strategies to promptly identify and address potential issues, further improving system stability and reliability.
[0163] The clear connections and functional distribution between these components together form the event-driven architecture of this technical solution. By optimizing message distribution mechanisms, streamlining business logic processing, and introducing intelligent routing technologies, this technical solution achieves efficient asynchronous communication between services, reduces inter-service dependencies, and improves system resilience and responsiveness.
[0164] It is worth noting that the intelligent message distribution algorithm provided by the embodiment of the present invention not only distributes messages based on information such as message type, priority, and target service, but also dynamically adjusts the distribution strategy based on real-time load conditions to ensure that messages are evenly distributed among different services, effectively avoiding message accumulation and processing delays.
[0165] Furthermore, by defining a unified event processing interface and process, the business logic is modularized and componentized. Developers only need to focus on the event processing logic itself, without having to worry about the underlying message distribution and processing details. This simplifies the development process, improves development efficiency, and reduces the complexity of system maintenance and upgrades.
[0166] Furthermore, intelligent routing algorithms can dynamically adjust the call paths between services based on inter-service dependencies, load conditions, and other information, achieving load balancing and failover. This improves system resilience and reliability, ensuring rapid service recovery in the event of a failure and ensuring business continuity.
[0167] In summary, the intelligent message distribution algorithm proposed in this patent application addresses the inefficient message distribution, message backlog, and processing delays inherent in existing technologies. By introducing an intelligent algorithm, the distribution strategy is dynamically adjusted based on information such as message type, priority, target service, and real-time load, achieving efficient message distribution. This innovation not only improves message processing efficiency but also reduces the risk of message backlog and processing delays, significantly enhancing system responsiveness and overall performance.
[0168] In existing technologies, developers need to focus on underlying details when handling complex business logic, which prolongs the development cycle. This patent application achieves modularization and componentization of business logic by defining a unified event processing interface and process. This innovation simplifies the development process, allowing developers to simply write event processing logic without having to worry about underlying details such as message distribution and processing, thereby improving development efficiency. Furthermore, this modular and componentized design makes the system easier to maintain and expand, reducing the complexity of system maintenance.
[0169] Faced with large-scale service dependencies and high-concurrency scenarios, existing message distribution and processing mechanisms are often inefficient, prone to service failures and performance bottlenecks. The intelligent routing algorithm in this patent application dynamically adjusts the call path between services based on information such as inter-service dependencies and load conditions, achieving service load balancing and failover. This innovation not only improves the system's resilience and reliability, but also reduces the complexity of service management, enabling the system to better cope with high-concurrency scenarios and sudden failures.
[0170] Please refer to Figure 3 , Figure 3 An event-driven service message processing and routing device 110 for improving system flexibility provided in an embodiment of the present invention includes:
[0171] Acquisition module 1101, used to obtain a message to be processed;
[0172] A distribution module 1102 is configured to determine a message distribution weight of the to-be-processed message for each service node using an intelligent message distribution algorithm;
[0173] The execution module 1103 is used to determine the target service node based on the message distribution weight, execute the service logic of the message to be processed and return the result.
[0174] It should be noted that the implementation principles of the aforementioned event-driven service message processing and routing device 110 for enhancing system resilience can be referenced with the implementation principles of the aforementioned event-driven service message processing and routing method for enhancing system resilience, and will not be elaborated upon here. It should be understood that the division of the various modules of the aforementioned device is merely a division of logical functions. In actual implementation, they may be fully or partially integrated into a single physical entity, or physically separated. Furthermore, these modules may be implemented entirely in the form of software invoked by a processing element; or entirely in the form of hardware; or some modules may be implemented in the form of software invoked by a processing element, while others may be implemented in hardware. For example, the event-driven service message processing and routing device 110 for enhancing system resilience may be a separate processing element, or may be integrated into a chip of the aforementioned device. Furthermore, it may be stored in the form of program code in the memory of the aforementioned device, and invoked and executed by a processing element of the aforementioned device to perform the functions of the aforementioned event-driven service message processing and routing device 110 for enhancing system resilience. The implementation of the other modules is similar. Furthermore, these modules may be fully or partially integrated together, or implemented independently. The processing element described herein may be an integrated circuit with signal processing capabilities. During implementation, each step of the above method or each module above may be completed by an integrated logic circuit of hardware in a processor element or by instructions in the form of software.
[0175] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code on a processing element, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0176] The embodiment of the present invention provides a computer device 100, which includes a processor and a non-volatile memory storing computer instructions. When the computer instructions are executed by the processor, the computer device 100 executes the aforementioned event-driven service message processing and routing device 110 for improving system flexibility. Figure 4 As shown, Figure 4This is a block diagram of a computer device 100 according to an embodiment of the present invention. The computer device 100 includes an event-driven service message processing and routing device 110 for improving system flexibility, a memory 111 , a processor 112 , and a communication unit 113 .
[0177] In order to achieve data transmission or interaction, the memory 111, the processor 112 and the communication unit 113 are electrically connected to each other directly or indirectly. For example, the electrical connection between these elements can be achieved through one or more communication buses or signal lines. The event-driven service message processing and routing device 110 for improving system resilience includes at least one software function module that can be stored in the memory 111 in the form of software or firmware or solidified in the operating system (OS) of the computer device 100. The processor 112 is used to execute the event-driven service message processing and routing device 110 for improving system resilience stored in the memory 111, such as the software function modules and computer programs included in the event-driven service message processing and routing device 110 for improving system resilience.
[0178] An embodiment of the present invention provides a readable storage medium, which includes a computer program. When the computer program is executed, the computer device where the readable storage medium is located is controlled to execute the aforementioned event-driven service message processing and routing device 110 for improving system flexibility.
[0179] For illustrative purposes, the foregoing description has been made with reference to specific embodiments. However, the above illustrative discussion is not intended to be exhaustive or to limit the present disclosure to the precise forms disclosed. Numerous modifications and variations are possible in light of the above teachings. These embodiments have been selected and described in order to best illustrate the principles of the present disclosure and its practical application, thereby enabling those skilled in the art to best utilize the present disclosure and to utilize various embodiments with various modifications as appropriate for the specific application contemplated.
Claims
1. An event-driven service message processing and routing method for improving system flexibility, characterized in that: include: Get pending messages; Determine the message distribution weight of the to-be-processed message for each service node using an intelligent message distribution algorithm; Determine the target service node based on the message distribution weight, execute the business logic of the message to be processed and return the result; The intelligent message distribution algorithm is: ,in, is an exponential decay function based on the rate of change of the backlog messages of service node i, is the assigned weight of service node i at time t, is the inherent priority of the message, is the real-time load rate of node i, is the rate of change of the message backlog of node i, 、 is the adaptive coefficient, is the elasticity factor, is the attenuation coefficient, is the total number of service nodes.
2. The method according to claim 1, characterized in that The method also includes: On the basis that the message to be processed needs to make a service call, a call routing path is dynamically determined based on an intelligent routing strategy.
3. The method according to claim 2, characterized in that The intelligent routing strategy dynamically adjusts the calling path between services based on the dependencies and load conditions between services; The method further comprises: If a service failure occurs in the call routing path, the service call request is transferred to a normal service node.
4. The method according to claim 1, wherein The method also includes: When the pending message fails to be sent, it will automatically retry until the pending message is processed; The method also includes: If the pending message cannot be processed, the pending message is placed in a dead letter queue.
5. The method according to claim 1, characterized in that The method further comprises: Monitor the operating status and performance indicators of all services according to the preset monitoring cycle; When the operating status and performance indicators of any service reach the potential abnormality threshold, the preset performance tuning and fault recovery strategies are triggered.
6. The method according to claim 1, characterized in that The process of determining the target service node based on the message distribution weight, executing the service logic of the message to be processed and returning the result includes: Determine a target service node based on the message distribution weight; Processing the to-be-processed message by the target service node based on a unified event processing interface and a unified event processing process; After the processing of the pending message is completed, the processing result is returned to the caller of the pending message.
7. An event-driven service message processing and routing device for improving system flexibility, characterized in that: include: The acquisition module is used to obtain messages to be processed; A distribution module, configured to determine a message distribution weight of the to-be-processed message for each service node using an intelligent message distribution algorithm; The execution module is used to determine the target service node based on the message distribution weight, execute the business logic of the message to be processed and return the result; The intelligent message distribution algorithm is: ,in, is an exponential decay function based on the rate of change of the backlog messages of service node i, is the assigned weight of service node i at time t, is the inherent priority of the message, is the real-time load rate of node i, is the rate of change of the message backlog of node i, 、 is the adaptive coefficient, is the elasticity factor, is the attenuation coefficient, is the total number of service nodes.
8. A computer device, characterized in that: The computer device includes a processor and a non-volatile memory storing computer instructions. When the computer instructions are executed by the processor, the computer device executes the method according to any one of claims 1 to 6.
9. A readable storage medium, characterized in that: The readable storage medium includes a computer program, and when the computer program is executed, the computer device where the readable storage medium is located is controlled to execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Load balancing method and device based on dynamic weight, equipment and storage medium
CN119668840A