Event-driven service message processing and routing method and device for improving system flexibility, computer equipment and readable storage medium
Through intelligent message distribution algorithm and intelligent routing strategy, the message distribution weight and call routing path are dynamically adjusted, which solves the problem of insufficient system flexibility under the traditional architecture, and achieves efficient message processing and system stability improvement.
Patent Information
- Application Number
- CN202510542658.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-04-28
AI Technical Summary
Under the traditional architecture, distributed systems are insufficient in the face of high concurrency and failures, and have low service message processing and routing efficiency, which affects system performance and stability.
The intelligent message distribution algorithm and intelligent routing strategy are adopted to dynamically determine the message distribution weight and call routing paths to ensure the reasonable allocation and efficient processing of messages, and to automatically transfer when service failures.
Through intelligent message distribution and routing strategies, efficient message processing and system elasticity are achieved, system response capabilities to high concurrency and faults are enhanced, and system stability and efficient operation are ensured.
Smart Images

Figure CN120075302A_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, device, computer device, and readable storage medium for improving system resilience. Background Art
[0002] With the development of information technology, the scale and complexity of distributed systems have been increasing continuously, and the dependency relationships between services are intricate. Under the traditional architecture, the system lacks resilience in the face of high concurrency and failures, and the efficiency of service message processing and routing is low, seriously affecting the performance and stability of the system. The traditional method cannot reasonably allocate processing tasks, often resulting in overloading of some services, slow response or even service crashes, making it difficult to meet the user's requirements for fast response and stable operation of the system. Summary of the Invention
[0003] The purpose of the present invention is to provide an event-driven service message processing and routing method, device, computer device, and readable storage medium for improving system resilience.
[0004] In a first aspect, an embodiment of the present invention provides an event-driven service message processing and routing method for improving system resilience, including: Obtaining a message to be processed; Using an intelligent message distribution algorithm to determine the message distribution weights of the message to be processed for each service node; Determining a target service node based on the message distribution weights, executing the service logic of the message to be processed, and returning the result.
[0005] In a possible implementation manner, the intelligent message distribution algorithm is: , where is an exponential decay function based on the backlog message change rate of service node i, is the allocation 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 change rate of the message backlog of node i, , are adaptive coefficients, is an elasticity factor, is a decay coefficient, is the total number of service nodes.
[0006] In a possible implementation manner, the method further includes: Based on the intelligent routing strategy, dynamically determining the call routing path on the basis that the message to be processed needs to perform a service call.
[0007] In a possible implementation, the intelligent routing algorithm adjusts the call paths between services dynamically according to the dependency relationships and load conditions between services; The method further includes: If a service failure occurs in the call routing path, transfer the service call request to a normal service node.
[0008] In a possible implementation, the method further includes: When the processing of the message to be processed fails, it will be automatically retried until the processing of the message to be processed is completed; The method further includes: If the message to be processed cannot be processed, put the message to be processed into the dead letter queue.
[0009] In a possible implementation, the method further includes: Monitor the running status and performance metrics corresponding to all services according to a preset monitoring period; When the running status and performance metrics corresponding to any service reach the potential anomaly threshold, trigger the execution of a preset performance tuning and fault recovery strategy.
[0010] In a possible implementation, 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 the target service node based on the message distribution weight; Process the message to be processed by the target service node based on the unified event processing interface and the unified event processing process; After the processing of the message to be processed is completed, return the processing result to the caller of the message to be processed.
[0011] In a second aspect, an event-driven service message processing and routing device for enhancing system resilience provided by an embodiment of the present invention includes: An acquisition module, configured to acquire a message to be processed; A distribution module, configured to determine the message distribution weight of the message to be processed for each service node by using an intelligent message distribution algorithm; An execution module, configured to determine a target service node based on the message distribution weight, execute the service logic of the message to be processed and return the result.
[0012] In a third aspect, an embodiment of the present invention provides a computer device, which 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 described in the first aspect.
[0013] Fourthly, an embodiment of the present invention provides a readable storage medium, which includes a computer program. When the computer program runs, it controls the computer device where the readable storage medium is located to execute the method described in the first aspect.
[0014] Compared with the prior art, the beneficial effects provided by the present invention include: adopting an event-driven service message processing and routing method, device, computer device, and readable storage medium for enhancing system elasticity disclosed by the present invention. By obtaining the message to be processed, then using the intelligent message distribution algorithm to determine the distribution weight of the message for each node according to the status of each service node, and finally selecting the target service node based on the weight to execute the service logic of the message to be processed and return the result. Through this method, reasonable message allocation and efficient processing are achieved, the system elasticity is enhanced, the system's ability to handle high concurrency and faults is strengthened, and the stable and efficient operation of the system is ensured. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can also be obtained based on these drawings without creative efforts.
[0016] Figure 1 It is a schematic flow chart of the steps of the event-driven service message processing and routing method for enhancing system elasticity provided by the embodiment of the present invention; Figure 2 It is a schematic overall work flow chart provided by the embodiment of the present invention; Figure 3 It is a schematic structural block diagram of the event-driven service message processing and routing device for enhancing system elasticity provided by the embodiment of the present invention; Figure 4 It is a schematic structural block diagram of the computer device provided by the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0017] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Usually, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0018] The following will describe in detail the specific embodiments of the present invention with reference to the drawings.
[0019] To solve the technical problems in the foregoing background art,Figure 1 It is a schematic flowchart 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 will be introduced in detail below.
[0020] Step S201: Obtain the message to be processed; Step S202: Use an intelligent message distribution algorithm to determine the message distribution weights of the message to be processed for each service node; Step S203: Determine the target service node based on the message distribution weights, execute the service logic of the message to be processed, and return the result.
[0021] In an embodiment of the present invention, exemplarily, in the server environment of a large e-commerce platform, a huge amount of messages are generated every day. These messages cover various operations of users, such as product browsing, placing orders, payment, evaluation, etc., as well as various events within the system, such as inventory updates, logistics status changes, etc.
[0022] For example, when a user browses products on the e-commerce platform, the server will record this browsing behavior and generate a corresponding message. This message contains detailed data such as the user's identifier, the product information browsed, and the browsing time. At this time, the server obtains a message to be processed.
[0023] Another example is that when the inventory of a certain product changes, the inventory management system will send an inventory change message to the server. This message may include the SKU code of the product, the quantity of inventory change, the time of inventory change, and the reason for the inventory change (such as sales, replenishment, etc.). The server will also include this message in the message queue to be processed.
[0024] For another 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, payment time, etc., and the server receives it as a message to be processed.
[0025] The server usually sets up a message receiving queue, which is responsible for receiving messages from various different sources. This queue can be a memory-based queue, such as message queue systems like RabbitMQ and Kafka. Taking Kafka as an example, it has advantages such as high throughput and scalability, and is very suitable for processing scenarios with a huge amount of messages like an e-commerce platform. Each business system sends messages to the specified topic in Kafka, and the server obtains the messages to be processed by subscribing to these topics.
[0026] When the server retrieves the messages to be processed from the message queue, it fetches the messages from the queue in a certain order (such as first-in, first-out). While retrieving the messages, the server conducts preliminary verification and parsing of the messages. For example, it checks whether the message format is correct and whether it contains the necessary fields, etc. If the message format is incorrect, the server may mark it as an abnormal message and record relevant logs for subsequent analysis and processing. For messages with correct formats, the server will pass them on to the subsequent processing flow.
[0027] 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.
[0028] Taking the product browsing message as an example, when the server obtains this message, the intelligent message distribution algorithm will start to work. This algorithm first analyzes the type of the message to determine that it is a message related to products. Then, it checks the load conditions of each current product service node. Suppose the product service node A is currently handling a relatively small number of requests, while the product service node B is already approaching the upper limit of its processing capacity. The algorithm will, based on this real-time load information, assign a higher message distribution weight, such as 70%, to the product service node A, and a lower weight, such as 30%, to the product service node B.
[0029] Looking at the inventory change message again. The intelligent message distribution algorithm will take into account the dependencies between the inventory service node and other relevant service nodes (such as the order service node and the logistics service node). If the current order service node is busy handling 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 the inventory change message can be processed in a timely manner and to avoid problems in subsequent order processing due to inaccurate inventory information. At the same time, the algorithm will also consider the priority of the message. For example, if it is an urgent inventory warning message indicating that certain products are about to be out of stock, the algorithm will increase the weight of this message distributed to the inventory service node and give priority to processing this message.
[0030] For the payment success message, the intelligent message distribution algorithm will assign weights according to the business requirements and current load conditions of the order service node and the user service node. The order service node needs to update the order status to paid, and the user service node may need to update the user's consumption records and account balances, etc. Suppose the order service node currently has a moderate load while the user service node has a light load. The algorithm may assign a 60% weight to the order service node and a 40% weight to the user service node. This can ensure the timely update of the order status while also taking into account the synchronous update of user-related information.
[0031] When determining the message distribution weight, the intelligent message distribution algorithm also takes into account the processing capacity differences of service nodes. Different service nodes may have different processing speeds and throughputs due to factors such as hardware configuration and software optimization level. For example, the newly upgraded commodity service node C has adopted more efficient caching technology and algorithm optimization, and its processing speed for commodity-related messages is 30% faster than that of other commodity service nodes. Then, when distributing commodity-related messages, the algorithm will appropriately increase the weight of commodity service node C to give full play to its processing advantages and improve the overall system processing efficiency.
[0032] Continuing with the example of commodity browsing messages, according to the weights determined by the intelligent message distribution algorithm above, assume that commodity service node A has obtained 70% of the weight and commodity service node B has obtained 30% of the weight. The server uses a random number generator or other probability selection algorithms to determine the target service node based on these weights. If the generated random number falls within the weight interval corresponding to commodity service node A (for example, the interval of 0 - 70), then commodity service node A is selected as the target service node.
[0033] After receiving the commodity browsing message, commodity service node A starts to execute the corresponding business logic. It first queries the detailed information of the commodity from the database, including the name, description, price, picture, etc. of the commodity. Then, it updates the browsing volume statistics data of the commodity, incrementing the browsing times of the commodity by 1. Next, it may recommend relevant commodities according to the user's browsing history and behavior patterns. For example, if the user often browses electronic products, commodity service node A will screen out some popular commodities or commodities similar to the currently browsed commodity from the electronic product category as the recommendation results.
[0034] After completing these business logic processes, commodity service node A returns the processing results to the server. The returned results may include the detailed information of the commodity and the recommended commodity list, etc. After receiving the results, the server passes them to the front-end application for display to the user.
[0035] For inventory change messages, if the target service node determined according to the weight is the inventory service node. After receiving the message, the inventory service node will first verify the legality of the inventory change. For example, it checks whether the quantity of inventory reduction exceeds the current actual inventory quantity, and if so, returns an error message. If the inventory change is legal, the inventory service node will update the inventory data in the database and record the log of the inventory change. At the same time, it checks whether the inventory warning mechanism is triggered due to this inventory change. If the inventory quantity of a certain commodity is lower than the set warning threshold, the inventory service node will generate an inventory warning message and send it to the relevant management system to notify the staff to replenish the stock in a timely manner. After completing these operations, the inventory service node will return the result of successful inventory change to the server.
[0036] In the processing scenario of the payment success message, if the order service node is selected as the target service node. After receiving the message, the order service node will query the detailed information of the order according to the order number. After confirming that 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, updating the financial information of the order, etc. After completing these business logic processes, the order service node will return the result of successful order status update to the server. The server will then feedback this result to the payment system and the front-end application to inform the user that the payment is successful and the order has entered the subsequent processing process.
[0037] If an error occurs during the execution of the business logic of the pending message, such as a database query failure or a network connection interruption, the target service node will handle it according to the specific error situation. It may try to retry the operation, such as querying the database again or re-establishing the network connection. If multiple retries still fail, the target service node will return an error message to the server, and the server will record this error and may take further measures, such as notifying the system administrator and putting the message into the dead letter queue for subsequent analysis and processing.
[0038] Through the above detailed scenario examples, it can be seen the specific operation process in the actual e-commerce platform server environment. This method effectively improves the elasticity and response speed of the system by reasonably obtaining the pending messages, intelligently determining the message distribution weight, accurately selecting the target service node and executing the corresponding business logic, ensuring that the e-commerce platform can operate stably and efficiently in the face of a large number of messages and complex business scenarios.
[0039] In the embodiment of the present invention, the intelligent message distribution algorithm is: , where is an exponential decay function based on the backlog message change rate of service node i is the allocation weight of service node i at time t, is the inherent priority of the message (static parameter, 0.5 ≤ ≤ 1.5), is the real-time load rate of node i (comprehensive CPU / memory metric), is the change rate of the message backlog volume of node i, , are the adaptive coefficients (the sum of the two = 1), is the elasticity factor (default 0.2, activated for adaptive growth when the system load > 70%), is the decay coefficient (controls the sensitivity of the backlog impact, positively correlated with the node's computing power), is the total number of service nodes.
[0040] In an embodiment of the present invention, by way of example, it is assumed that this is a server of a large online education platform. The platform has numerous service nodes, such as course service nodes, user service nodes, homework service nodes, etc., which process various types of messages, such as course registration, homework submission, etc.
[0041] The server obtains a to-be-processed message of a student submitting homework. This message has its inherent priority. For example, due to approaching the deadline, the inherent priority is relatively high.
[0042] At this time, the server starts to use the intelligent message distribution algorithm to determine the message distribution weights of each service node.
[0043] For course service node i, the server first calculates the value of the exponential decay function related to its backlog message change rate. Assume that the course service node is currently processing a large number of course update messages, with a relatively large change rate of the backlog volume and a relatively high real-time load rate. According to the formula, since the backlog messages increase, the value of the exponential decay function becomes smaller.
[0044] For homework service node j, its change rate of the backlog message volume is small and its real-time load rate is low. In the algorithm, the value of its exponential decay function is relatively large.
[0045] The inherent priority of the message affects the allocation weights of each node. Since the inherent priority of this homework submission message is high, the weights of relevant nodes will be increased when calculating the allocation weights of each node.
[0046] The adaptive coefficients will be adjusted according to the long-term operation status of the system and the characteristics of different service nodes. For example, if there are more homework-related problems on the platform recently and it is necessary to focus on ensuring homework processing, the adaptive coefficients related to the homework service nodes will be appropriately increased.
[0047] The elasticity factor and the attenuation coefficient comprehensively consider the system elasticity and the message processing stability. If it is desired that the system has better elasticity under load changes, the elasticity factor will be appropriately adjusted; to avoid overly drastic changes in weights, the attenuation coefficient will be reasonably set.
[0048] After calculation, due to factors such as the small change rate of backlogged messages and the low real-time load of the job service node, the assigned weight is relatively high, and it is determined as the target service node.
[0049] After the job service node receives a message, it executes the business logic of job submission, such as storing job data in the database and checking whether the format is correct, etc. After completion, it returns a successful processing result to the server, and the server then feedbacks the result to the student client.
[0050] In the embodiment of the present invention, the following implementation manners are also provided.
[0051] Based on the need to perform service invocation for the to-be-processed message, a call routing path is dynamically determined based on the intelligent routing strategy.
[0052] In the embodiment of the present invention, by way of example, taking the server of an online travel reservation platform as an example, the platform covers various services such as hotel reservation, flight ticket reservation, scenic spot ticket reservation, etc., and each service is provided by different service nodes.
[0053] The server obtains a to-be-processed message of a user's hotel reservation. During the process of processing this message, it is confirmed that service invocation is required, such as invoking the hotel inventory service node to confirm whether the rooms of the selected hotel are available for reservation, and invoking the price service node to obtain the real-time room rate, etc.
[0054] At this time, the server dynamically determines the call routing path based on the intelligent routing strategy. The intelligent routing strategy comprehensively considers information such as the dependency relationship between services and the load conditions of each service node.
[0055] For the hotel inventory service node, assume that there are currently multiple nodes providing hotel inventory services. Node A recently underwent a hardware upgrade and its processing capacity has increased, but its current load has reached 70%; Node B has slightly weaker processing capacity and its load is 40%. The intelligent routing strategy takes into account that the load of Node B is relatively low, and the hotel inventory service has high requirements for real-time performance. If Node A experiences processing delays due to high load, it may affect the user experience, so it tends to select Node B.
[0056] At the same time, the hotel reservation message also needs to invoke the price service node. The platform has a domestic price service node and an international price service node. Since this reservation is for a domestic hotel, the intelligent routing strategy preferentially selects the domestic price service node according to the dependency relationship between services.
[0057] In addition, the intelligent routing strategy can also perceive the service status in real time. If, during the process of determining the routing path, it is found that a certain originally selected service node suddenly fails, for example, the network of hotel inventory service node B is interrupted. The intelligent routing strategy will immediately re-evaluate and switch the call path to other available hotel inventory service nodes, such as node A, to ensure that the reservation process is not affected.
[0058] For another example, if the tourism popularity in a certain domestic region has recently increased and the hotel reservation messages in this region have increased, resulting in an increase in the load of the nodes processing hotel-related services in this region. The intelligent routing strategy will dynamically adjust and direct the call paths of some reservation messages to other service nodes of the same type with relatively lower load to achieve load balancing.
[0059] By dynamically determining the call routing path based on the intelligent routing strategy in this way, the server can efficiently coordinate the calls between various service nodes, improve the efficiency and stability of the system in processing reservation messages, and provide users with a smooth hotel reservation service experience.
[0060] In the embodiment of the present invention, the intelligent routing algorithm strategy is to dynamically adjust the call paths between services according to the dependency relationship and load situation between services; The embodiment of the present invention also provides the following implementation manners.
[0061] If a service failure occurs in the call routing path, transfer the service call request to a normal service node.
[0062] In the embodiment of the present invention, by way of example, taking a comprehensive e-commerce server as an example, this server supports a series of services such as product display, placing orders, payment, and logistics.
[0063] After the server obtains the order placement pending message of the user, it is confirmed that multiple service calls are required during the processing of this message. For example, it is necessary to call the inventory service to confirm the product inventory, call the price service to obtain the latest price of the product, call the user service to verify the user information, etc.
[0064] The server starts to dynamically determine the call routing path according to the intelligent routing strategy. Taking the call to the inventory service as an example, there are multiple inventory service nodes in the e-commerce platform responsible for inventory management in different regions. Assume that the inventory service node A in the South China region is responsible for the product inventory in the South China region, and its current load is 30%; while the inventory service node B in the East China region is responsible for the product inventory in the East China region, and the load is 70%. Since the address of the user placing the order this time is in the South China region, according to the dependency relationship between services, the inventory service node A in the South China region should be called first. At the same time, considering that the load of node A is relatively low and it can process requests more efficiently, the determined call path is node A.
[0065] For price services, the platform has a real-time price service node C and a historical price service node D. Since placing an order requires obtaining real-time prices, according to the service dependency, the real-time price service node C is determined to be called.
[0066] However, during the actual call process, unexpected situations may occur. For example, when the server is about to call the inventory service node A in South China, the intelligent routing strategy detects that node A has a sudden network failure and cannot provide services normally. At this time, the server immediately executes emergency measures and transfers the inventory service call request to the inventory service node B in East China. Although the load of node B is relatively high, in order to ensure the continuity of the order placement process, it is still selected to process the request.
[0067] Similarly, if when calling the real-time price service node C, it is found that node C is temporarily unresponsive due to data processing exceptions, the server will, according to the intelligent routing strategy, quickly transfer the price service call request to the backup real-time price service node E (assuming such a backup node exists) to ensure that the commodity price information can be obtained in time and the order placement process can be completed.
[0068] Through such a mechanism of dynamically adjusting the call path according to the service dependencies and load conditions, and transferring the call request to a normal service node in a timely manner when a service failure occurs, the e-commerce server can effectively ensure the smooth progress of key business processes such as order placement, improve the stability and reliability of the system, and provide users with an uninterrupted shopping service experience.
[0069] In the embodiment of the present invention, the following implementation manners are also provided.
[0070] When the to-be-processed message fails to be sent, it will be automatically retried until the to-be-processed message is processed. In the embodiment of the present invention, the following implementation manners are also provided.
[0071] If the to-be-processed message cannot be processed, the to-be-processed message will be put into the dead letter queue.
[0072] In the embodiment of the present invention, exemplarily, taking the server of a large financial trading platform as an example, the platform undertakes various services such as stock trading and fund trading.
[0073] The server receives a to-be-processed stock purchase message submitted by a user. During the process of processing this message, the server needs to interact with multiple systems, such as sending trading instructions to the stock exchange and confirming the user's funds with the fund management system.
[0074] In the link of sending trading instructions to the stock exchange, the message may fail to be sent due to reasons such as network fluctuations and the busy system of the stock exchange. At this time, the server follows the established rules and automatically retries.
[0075] When the server makes the first retry, it will re - establish the network connection with the stock exchange and send the stock purchase order again. If this sending still fails, the server will not give up immediately. Instead, it will perform a second retry at a set time interval. This time interval may be set according to the system configuration and empirical values. For example, starting from 1 second initially, the retry interval doubles each time to avoid excessive occupation of network resources by a large number of ineffective retries in a short period.
[0076] During the second retry process, the server will check again whether the network status, instruction format, etc. are normal to ensure that there are no other potential problems affecting the message sending. If the second retry still fails, the server will continue with the third retry, repeating the above - mentioned checking and sending steps.
[0077] In this way, the server continuously retries automatically until the stock purchase order is successfully sent to the stock exchange and confirmed, that is, the pending message is processed.
[0078] However, there are also extreme cases. For example, due to reasons such as abnormal user account information and trading rule restrictions, the server cannot successfully process the pending message no matter how many retries are made. For example, after multiple retries, it is found that the user account is frozen due to illegal operations. At this time, the stock purchase message actually cannot be processed according to the normal process.
[0079] In this case, the server will put the pending message into the dead - letter queue. The dead - letter queue is specifically used to store these unprocessable messages. The messages put into the dead - letter queue will be marked with detailed failure reasons, such as "the transaction cannot proceed due to account freezing", etc.
[0080] Subsequently, the platform's operation and maintenance personnel or relevant business departments can regularly check the dead - letter queue, analyze the reasons for these unprocessable messages, and solve the problems targeted. For example, for a transaction failure caused by account freezing, after contacting the user to solve the account problem, the transaction message may be re - processed. Through this automatic retry and dead - letter queue mechanism, the financial trading platform server can effectively manage abnormal situations while ensuring the reliability of transactions.
[0081] In the embodiments of the present invention, the following implementation manners are also provided.
[0082] Monitor the running status and performance metrics corresponding to all services according to a preset monitoring period; When the running status and performance metrics corresponding to any service reach the potential anomaly threshold, trigger the execution of a preset performance tuning and fault recovery strategy.
[0083] In an embodiment of the present invention, by way of example, taking a large video streaming server as an example, this server is responsible for handling a series of services such as video upload, transcoding, storage, and distribution to the user side.
[0084] The server monitors the running status and performance metrics corresponding to all services according to a preset monitoring period, such as every 5 minutes. For the video transcoding service, the server focuses on monitoring performance metrics such as its CPU usage rate, memory occupancy, and the processing speed of transcoding tasks. For the video distribution service, the monitored metrics include network bandwidth utilization rate, concurrent connection number, and response time, etc.
[0085] At a certain moment, the monitoring system detects that the CPU usage rate of the video transcoding service has reached 85%, while the preset potential anomaly threshold is 80%, and at the same time, the memory occupancy is also approaching the system-set potential anomaly threshold. This indicates that the running status and performance metrics of the video transcoding service have reached the potential anomaly threshold.
[0086] At this time, the server immediately triggers the execution of the preset performance tuning and fault recovery strategies. For the video transcoding service, due to the too high CPU usage rate, the server first tries to dynamically adjust the priority of transcoding tasks. It will pause some transcoding tasks with low real-time requirements and give priority to processing those video transcoding tasks that are about to be pushed to the user side. At the same time, the server will check the system resource allocation situation and find that the high memory occupancy may be due to the unreasonable cache setting of the transcoding algorithm, so it adjusts the cache strategy of the transcoding algorithm to release some memory space.
[0087] If the above measures fail to effectively improve the performance of the video transcoding service, the server will further adopt a fault recovery strategy. It will start a standby transcoding server node and divert some transcoding tasks to the standby node for processing. In this way, by increasing the processing resources and reducing the load on the main transcoding server, its performance metrics gradually return to the normal range.
[0088] Another example is that when monitoring the video distribution service, it is found that the network bandwidth utilization rate has reached 95%, exceeding the preset potential anomaly threshold of 90%, and the response time also starts to become longer. The server triggers the preset strategy and first optimizes the network routing. Through an intelligent routing algorithm, it avoids congested network links and selects a more unobstructed path to distribute video data. If the network bandwidth is still tight, the server will classify the videos according to the user's viewing history and real-time needs, and reduce the resolution of videos with low viewing requirements for distribution to reduce bandwidth occupancy and ensure that most users can watch videos smoothly.
[0089] In this way, by monitoring the running status and performance metrics of the service according to a preset monitoring period and triggering the preset performance tuning and fault recovery strategies in a timely manner when the potential anomaly threshold is reached, the video streaming media server can maintain stable and efficient operation and provide users with a high-quality video service experience.
[0090] In the embodiment of the present invention, 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 following example can be used for implementation.
[0091] Determine the target service node based on the message distribution weight; Process the message to be processed by the target service node based on the unified event processing interface and the unified event processing flow; After the processing of the message to be processed is completed, return the processing result to the caller of the message to be processed.
[0092] In the embodiment of the present invention, by way of example, taking the server of a large food delivery platform as an example, the server needs to process various messages to be processed from merchants, riders and users.
[0093] After the server obtains a message to be processed for a user's order, it first determines the target service node according to the message distribution weight. Assume that in the business architecture of the food delivery platform, the order processing service is completed by multiple service nodes working together, including order allocation nodes, inventory check nodes, etc. The server uses an intelligent message distribution algorithm to determine the message distribution weight by combining factors such as the real-time load and business dependencies of each node. For example, the order allocation node A has a low load and high processing efficiency, and is given a high message distribution weight, so it is determined as the target service node for processing this order placement message.
[0094] Next, process the message to be processed by the target service node based on the unified event processing interface and the unified event processing flow. After receiving the message, the order allocation node A receives the order placement message through the unified event processing interface. This unified event processing interface ensures that different types of messages can enter the processing flow in a standardized manner. Then, according to the unified event processing flow, the order allocation node A first verifies the integrity of the order information, including product details, user address, contact phone number, etc. After confirming that it is correct, it queries the real-time location and busy status of the rider, and allocates the order to the most suitable rider according to factors such as distance and busyness. In the whole processing process, whether it is the verification of the order information or the allocation of the rider, it follows the established unified event processing flow to ensure the accuracy and consistency of the processing.
[0095] After the processing of the message to be processed is completed, the order allocation node A returns the processing result to the caller of the message to be processed. Here, the caller is the user-related system that initially initiated the order placement request (such as the server side behind the user's mobile APP). The order allocation node A returns information such as the rider's name, contact information, and estimated arrival time, which indicates that the order has been successfully allocated to the rider, as the processing result. In this way, the user can see on the APP that the order has been allocated a rider and the relevant delivery progress information, thus completing the entire process of receiving, processing, and result feedback of the order placement message, ensuring the efficient operation of the food delivery service.
[0096] To more clearly describe the solution provided by the embodiments of the present invention, the following provides a relatively complete implementation manner. Please refer to Figure 2 , Figure 2 which is the overall workflow schematic diagram provided by the embodiments of the present invention.
[0097] 1. Structure and functions of the technical solution: The embodiments of the present invention aim to propose an event-driven architecture technology that decouples service dependencies and improves system elasticity and response speed. The technical solution mainly consists of the following key modules: Message distribution module: Responsible for efficiently distributing messages according to information such as the type, priority, and target service of the message. By introducing an intelligent message distribution algorithm, this module can dynamically adjust the distribution strategy to ensure the uniform distribution of messages among different services and support mechanisms such as message retry and dead letter queue to ensure the reliable delivery of messages.
[0098] Business logic processing module: By defining a unified event processing interface and event processing flow, it realizes the modularization and componentization of business logic. Developers only need to write event processing logic without paying attention to underlying details such as message distribution and processing, thus simplifying the development process and improving development efficiency.
[0099] Intelligent routing module: Dynamically adjusts the call path between services according to information such as service dependencies and load conditions. This module can perceive the service status in real time, realize load balancing and fault transfer of services, and at the same time support automatic discovery and registration of services, reducing the complexity of service management.
[0100] System monitoring and tuning module: Monitors information such as the running status and performance metrics of the system in real time. Through automated performance tuning and fault recovery strategies, it can timely detect and handle potential problems, improving the stability and reliability of the system.
[0101] 2. Working principle: Optimization of the message distribution mechanism: Introduce an intelligent message distribution algorithm that dynamically adjusts the distribution strategy based on information such as the type, priority, and target service of the message, as well as the real-time load situation, to ensure the uniform distribution of messages among different services.
[0102] Support the message retry mechanism. When the message sending fails, it will be automatically retried to ensure the reliable delivery of the message.
[0103] Set up a dead letter queue. For messages that cannot be successfully processed, they will be put into the dead letter queue for subsequent analysis and processing.
[0104] Simplify the business logic processing flow: Define a unified event handling interface and event handling process to achieve the modularization and componentization of business logic. Developers only need to write the event handling logic without concerning about the underlying details such as message distribution and processing.
[0105] In this way, the development process can be greatly simplified, the development efficiency can be improved, and at the same time, the complexity of system maintenance can be reduced.
[0106] Introduce intelligent routing technology: Introduce an intelligent routing algorithm that dynamically adjusts the call path between services based on information such as the dependency relationship and load situation between services.
[0107] Perceive the service status in real time to achieve service load balancing and failover. When a service fails, the intelligent routing algorithm will automatically transfer the request to other available services to ensure the continuity and stability of the system.
[0108] Support the automatic discovery and registration of services, reducing the complexity of service management.
[0109] 3 Workflow: Message reception and distribution: The system receives messages from various services and passes them to the intelligent message distribution module.
[0110] The intelligent message distribution module selects an appropriate distribution strategy based on information such as the type, priority, and target service of the message, as well as the real-time load situation, and distributes the message to the corresponding service.
[0111] Business logic processing: The received message is passed to the unified event handling interface.
[0112] According to the definition of the event handling process, the corresponding event handling logic is called for processing.
[0113] After the processing is completed, the result is returned to the caller.
[0114] Intelligent routing and call: During the business logic processing, if other services need to be called, the intelligent routing module will dynamically select the optimal call path based on information such as the dependency relationship and load situation between services.
[0115] If a certain service fails, the intelligent routing module will automatically transfer the request to other available services.
[0116] System monitoring and tuning: The system monitoring module monitors the running status, performance metrics and other information of the system in real time.
[0117] When potential problems are detected, the tuning strategy is automatically triggered to optimize and adjust the system.
[0118] Support automated performance tuning and fault recovery strategies to improve the stability and reliability of the system.
[0119] 4. The component structures, connection relationships and functional relationships of the technical solution: Message distribution module: As one of the core components of the event-driven architecture, it is connected to all services and is responsible for message receiving, distribution and retry mechanisms. This module realizes efficient message distribution through intelligent algorithms to ensure that messages can be accurately and quickly delivered to the target service.
[0120] Business logic processing module: It is connected to the message distribution module and is responsible for receiving the distributed messages and performing corresponding business logic processing. By defining a unified event processing interface and process, this module realizes the modularization and componentization of business logic, simplifying the development process.
[0121] Intelligent routing module: It is connected to the service registry and service callers. It dynamically adjusts the call path between services according to information such as the dependency relationship and load situation between services. This module realizes service load balancing and fault transfer through intelligent algorithms, improving the elasticity and reliability of the system.
[0122] System monitoring and tuning module: It is connected to all services and is responsible for real-time monitoring of the running status and performance metrics of the system. Through automated performance tuning and fault recovery strategies, this module can timely detect and handle potential problems, further improving the stability and reliability of the system.
[0123] Through clear connection relationships and functional distributions among components, they jointly constitute the event-driven architecture of this technical solution. By optimizing the message distribution mechanism, simplifying the business logic processing process, introducing intelligent routing and other technical means, this technical solution realizes efficient asynchronous communication between services, reduces the dependency degree between services, and improves the elasticity and response speed of the system.
[0124] It should be noted that the intelligent message distribution algorithm provided by the embodiments of the present invention not only distributes messages according to information such as the type, priority, and target service of the messages, but also dynamically adjusts the distribution strategy in combination with the real-time load situation to ensure that the messages are evenly distributed among different services, effectively avoiding message accumulation and processing delays.
[0125] In addition, by defining a unified event processing interface and process, the modularization and componentization of business logic are realized. Developers only need to focus on the event processing logic itself and do not need to care about the underlying message distribution and processing details. This simplifies the development process, improves the development efficiency, and at the same time reduces the complexity of system maintenance and upgrade.
[0126] Furthermore, the intelligent routing algorithm can dynamically adjust the call path between services according to information such as the dependency relationship and load situation between services, realizing load balancing and fault transfer of services. This improves the elasticity and reliability of the system, ensures that the service can quickly recover in case of failure, and guarantees the continuity of business.
[0127] In summary, the intelligent message distribution algorithm in this patent application is proposed to address the problems of low message distribution efficiency, easy message accumulation, and processing delays in the prior art. By introducing intelligent algorithms, and according to information such as the type, priority, and target service of the messages, as well as the real-time load situation, the distribution strategy is dynamically adjusted to achieve efficient message distribution. This innovation not only improves the efficiency of message processing, but also reduces the risk of message accumulation and processing delays, thus significantly enhancing the response speed and overall performance of the system.
[0128] In the prior art, when developers handle complex business logic, they need to focus on the underlying details, resulting in an extended development cycle. This patent application realizes the modularization and componentization of business logic by defining a unified event processing interface and process. This innovation simplifies the development process, enabling developers to only write event processing logic without having to pay attention to underlying details such as message distribution and processing, thereby improving the development efficiency. At the same time, this modular and componentized design also makes the system easier to maintain and expand, reducing the complexity of system maintenance.
[0129] In the face of large-scale service dependencies and high-concurrency scenarios, the message distribution and processing mechanisms in the prior art are often not efficient enough, prone to service failures and performance bottlenecks. The intelligent routing algorithm in this patent application dynamically adjusts the call path between services according to information such as the dependency relationship and load situation between services, realizing load balancing and fault transfer of services. This innovation not only improves the elasticity and reliability of the system, but also reduces the complexity of service management, enabling the system to better handle high-concurrency scenarios and sudden failures.
[0130] Please refer to Figure 3 , Figure 3An event-driven service message processing and routing device 110 for enhancing system elasticity provided by an embodiment of the present invention includes: An acquisition module 1101, configured to acquire a message to be processed; A distribution module 1102, configured to determine the message distribution weights of the message to be processed for each service node by using an intelligent message distribution algorithm; An execution module 1103, configured to determine a target service node based on the message distribution weights, execute the service logic of the message to be processed, and return a result.
[0131] It should be noted that the implementation principle of the foregoing event-driven service message processing and routing device 110 for enhancing system elasticity may refer to the implementation principle of the foregoing event-driven service message processing and routing method for enhancing system elasticity, which will not be elaborated herein. It should be understood that the division of each module of the above device is only a logical function division. In actual implementation, it may be fully or partially integrated into a physical entity, or physically separated. And these modules can all be implemented in the form of software called by a processing element; they can also all be implemented in the form of hardware; or some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the event-driven service message processing and routing device 110 for enhancing system elasticity can be a separately established processing element, or can be integrated in a certain chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a certain processing element of the above device to perform the functions of the foregoing event-driven service message processing and routing device 110 for enhancing system elasticity. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together or independently implemented. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed by the integrated logic circuit in the processor element or the instruction in the form of software.
[0132] 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 (ASIC), or one or more microprocessors (digital signal processors, DSP), or one or more field programmable gate arrays (FPGA), etc. For another example, when a module above is implemented in the form of a processing element scheduling program code, 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).
[0133] 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 4 The computer device 100 provided in the embodiment of the present invention is a structural block diagram. 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.
[0134] 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 elasticity 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 elasticity 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 elasticity.
[0135] An embodiment of the present invention provides a readable storage medium, which includes a computer program. When the computer program is running, it controls the computer device where the readable storage medium is located to execute the aforementioned event-driven service message processing and routing device 110 for improving system elasticity.
[0136] For purposes of illustration, 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 disclosure to the precise forms disclosed. Numerous modifications and variations are possible in light of the above teachings. The embodiments were chosen and described in order to best explain the principles of the disclosure and its practical application, to thereby enable those skilled in the art to best utilize the disclosure and to utilize various embodiments with various modifications as are suited to the particular 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.
2. The method according to claim 1, characterized in that 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 allocation weight of service node i at time t, is the intrinsic priority of the message, is the real-time load rate of node i, is the rate of change of message backlog of node i, , is the adaptive coefficient, is the elasticity factor, is the attenuation coefficient, is the total number of service nodes.
3. 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.
4. The method according to claim 3, characterized in that The intelligent routing strategy is to dynamically adjust the calling path between services according to the dependency 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.
5. The method according to claim 1, characterized in that 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.
6. 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 abnormal threshold, the preset performance tuning and fault recovery strategies are triggered.
7. The method according to claim 1, characterized in that The step 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 flow; After the processing of the pending message is completed, the processing result is returned to the caller of the pending message.
8. An event-driven service message processing and routing device for improving system flexibility, characterized in that: include: The acquisition module is used to obtain the messages to be processed; A distribution module, used to determine the message distribution weight of the to-be-processed message for each service node by 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.
9. A computer device, characterized in that: The computer device comprises 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 7.
10. 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 7.
Citation Information
Patent Citations
Multi-machine-room message load balancing processing method and device
CN114124962A
Method and device for dynamically adjusting weight of message queue
CN115150340A
Data pushing method and device and electronic equipment
CN118413569A
Message center system and message queue management method thereof
CN119166378A
Load balancing method and device based on dynamic weight, equipment and storage medium
CN119668840A