Message attribute-based message distribution method and device, equipment and medium
By assigning to different task queues according to message attributes and dynamically adjusting the distribution speed, the problem of message accumulation and processing capability limitation in the existing message queue architecture is solved, and efficient and stable message distribution is achieved.
Patent Information
- Application Number
- CN202411964613.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-15
AI Technical Summary
In the existing message queue architecture, multiple different message attributes share the same queue, resulting in message accumulation and processing capabilities limitations, affecting other types of message consumption, and may even lead to business interruption or system crash.
By receiving multiple messages to be distributed, they are assigned to different task queues according to the message attributes, and the messages in the task queue are split into high priority, medium priority, and low priority subqueues according to the priority. Use the service cluster to distribute messages and dynamically adjust the distribution speed according to the service performance of each service node.
It effectively avoids mutual interference between tasks, significantly improves concurrent processing efficiency and resource utilization, prevents message accumulation and service interruption, and ensures the operational stability and efficiency of the distribution system.
Smart Images

Figure CN119835231A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication technology, and in particular to a message distribution method, device, electronic device and storage medium based on message attributes. Background Art
[0002] With the rapid development of the Internet, data exchange and message notification have become increasingly important in modern enterprises. In order to achieve efficient asynchronous communication and system decoupling, message queues are widely used in enterprise products and services, becoming one of the core components supporting large-scale distributed systems. Message queues play a vital role in ensuring efficient system availability, reducing latency, and improving concurrent processing capabilities. With the continuous advancement of technology and the continuous growth of business needs, the application scenarios and scale of message queues are becoming increasingly complex, further increasing the requirements for queue performance and reliability.
[0003] However, in the existing message queue architecture, there are usually multiple different message attributes sharing the same queue, that is, different types of messages are sent to the same queue for processing. This design may cause message accumulation and processing capacity limitations in the queue when there are a large number of messages with a certain attribute, affecting the consumption of other types of messages. If the message backlog in the queue cannot be processed in time, subsequent messages may also be delayed due to waiting for processing, which may even cause business interruption or system crash in serious cases. Summary of the invention
[0004] In view of this, an embodiment of the present application provides a message distribution method, device, electronic device and storage medium based on message attributes, which are used to solve at least one technical problem.
[0005] An embodiment of the present application provides a message distribution method based on message attributes, comprising: receiving multiple messages to be distributed, the messages to be distributed comprising: message attributes and priorities; distributing the messages to be distributed to different task queues according to the message attributes, and the task queues are processed independently; splitting the messages to be distributed in the task queue into multiple sub-queues according to the message attributes and priorities, the sub-queues comprising: one or more of a high priority queue, a medium priority queue and a low priority queue; utilizing a service cluster associated with the messages to be distributed, distributing the messages to be distributed to target users, wherein the service cluster comprises multiple service nodes, and controlling the distribution speed of the messages to be distributed according to the service performance of each service node.
[0006] The method as described above further includes: configuring different processing resources for the task queue according to the message attributes of the message to be distributed in the task queue, and the message attributes of the message to be distributed include: one or more of the source department and timeliness requirements of the message to be distributed.
[0007] The method as described above further includes: calculating a first score based on the importance of the source department of the message to be distributed; calculating a second score based on the timeliness requirement of the message to be distributed; calculating a third score based on the number of messages to be distributed in the task queue; calculating a fourth score based on the data size of the messages to be distributed in the task queue; calculating a resource requirement score based on the first score, the second score, the third score and the fourth score and the corresponding weight values; and configuring the processing resources of the corresponding task queue according to the resource requirement score.
[0008] The method as described above controls the distribution speed of the messages to be distributed according to the service performance of each service node, including: calculating the service performance score of each service node according to the processor utilization rate, memory utilization rate and number of concurrent requests of each service node; comparing the service performance scores of all service nodes to determine the minimum service performance score; and dynamically adjusting the distribution speed of the messages to be distributed according to the minimum service performance score.
[0009] The method as described above further comprises: when the message to be distributed is an urgent message, according to the message attribute of the urgent message, it is distributed to the corresponding task queue; the current message distribution task in the task queue is interrupted, and the distribution task of the urgent message is processed preferentially.
[0010] According to the method described above, the to-be-distributed messages are distributed to different task queues according to the source departments in the message attributes, and the task queues are processed independently.
[0011] According to the method described above, the number of high priority queues in the sub-queue is determined according to the importance of the source department in the message attribute.
[0012] According to another aspect of the present application, a message distribution device based on message attributes is proposed, including: a receiving module, used to receive multiple messages to be distributed, and the messages to be distributed include: message attributes and priorities; an allocation module, used to distribute the messages to be distributed to different task queues according to the message attributes, and the task queues are processed independently; a splitting module, used to split the messages to be distributed in the task queue into multiple sub-queues according to the message attributes and priorities, and the sub-queues include: one or more of a high priority queue, a medium priority queue and a low priority queue; a distribution module, used to distribute the messages to be distributed to target users by using a service cluster associated with the messages to be distributed, wherein the service cluster includes multiple service nodes, and the distribution speed of the messages to be distributed is controlled according to the service performance of each service node.
[0013] According to another aspect of the present application, an electronic device is provided, which includes a processor and a memory, wherein a computer program instruction set is stored in the memory, and when the processor executes the computer program instruction set in the memory, the message distribution method based on message attributes as described above is implemented.
[0014] According to another aspect of the present application, a computer-readable storage medium is provided, wherein a computer program instruction set is stored on the computer-readable storage medium, and when the computer program instruction set is executed by a processor, the message distribution method based on message attributes as described above is implemented.
[0015] In the solution of the present application, messages are allocated according to their different attributes and divided into independent task queues. This method can avoid mutual interference between tasks, and based on the above-mentioned refined management, it can significantly improve concurrent processing efficiency and resource utilization. Furthermore, the present application dynamically adjusts the message distribution speed to adapt to the processing capacity of downstream service nodes, effectively preventing message accumulation or service interruption caused by node overload, thereby ensuring the operational stability and efficiency of the distribution system. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The preferred embodiments of the present invention will be further described in detail below with reference to the accompanying drawings, wherein:
[0017] Figure 1 It is a flow chart of a message distribution method based on message attributes according to an embodiment of the present application.
[0018] Figure 2 It is a flowchart of a method for configuring processing resources according to an embodiment of the present application.
[0019] Figure 3 It is a flow chart of a method for controlling the distribution speed of messages to be distributed according to an embodiment of the present application.
[0020] Figure 4 It is a flowchart of the existing method for queue message distribution.
[0021] Figure 5 It is a flowchart of queue message distribution according to an embodiment of the present application.
[0022] Figure 6 is to use Figure 4 Traffic monitoring diagram of message distribution using the method in .
[0023] Figure 7 is to use Figure 5 Traffic monitoring diagram of message distribution using the method in .
[0024] Figure 8 It is the traffic monitoring diagram before and after the improvement of the message distribution method.
[0025] Fig. 9 It is a structural diagram of a message distribution device based on message attributes according to an embodiment of the present application.
[0026] Fig.10 It is a schematic diagram of the hardware structure principle of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] In the following detailed description, reference may be made to the various specification drawings that are part of the present application and are used to illustrate specific embodiments of the present application. In the accompanying drawings, similar reference numerals describe substantially similar components in different figures. The various specific embodiments of the present application are described below in sufficient detail so that a person of ordinary skill in the art with relevant knowledge and skills in the art can implement the technical solutions of the present application. It should be understood that other embodiments may also be used or structural, logical or electrical changes may be made to the embodiments of the present application.
[0029] The message of this application refers to the content carrier delivered to the target user through a specific channel, which usually contains specific information content and the purpose of sending. In business scenarios, messages include but are not limited to: push notifications, text messages, emails, in-site letters, coupons, etc., which are designed to complete target tasks such as promotions, reminders, notifications or services. The core feature of the message is that it needs to be processed by the system and queued, and finally sent to the designated target user through downstream services.
[0030] The message attributes of this application are used to describe the characteristics and requirements of the message. These attributes may include the source department of the message (such as the operations department, the marketing department), the business type (such as sending email notifications, sending SMS notifications, etc.), timeliness requirements (such as requiring all to be sent within 2-5 hours), etc. By setting message attributes, the messaging system can classify, route, and process messages according to these tags.
[0031] The priority of this application refers to the priority queue, which is a special data structure. It is different from the traditional first-in-first-out (FIFO) queue, but determines the processing order according to the priority of the elements. In a priority queue, each operation is performed on the element with the highest priority, rather than in the order in which the elements enter the queue.
[0032] The service cluster of this application refers to a collection of multiple service nodes that work together to provide a specific function or service architecture. Service clusters are usually used to improve system performance, availability, and fault tolerance, and are common in distributed systems and microservice architectures.
[0033] Figure 1 FIG. 1 is a flow chart of a message distribution method based on message attributes according to an embodiment of the present application. Figure 1 As shown, the method includes:
[0034] Step S110, receiving a plurality of messages to be distributed, wherein the messages to be distributed include: message attributes and priorities;
[0035] Step S120, allocating the to-be-distributed message to different task queues according to the message attributes, and the task queues are processed independently;
[0036] Step S130, splitting the to-be-dispatched messages in the task queue into a plurality of sub-queues according to the message attributes and priorities, wherein the sub-queues include: one or more of a high priority queue, a medium priority queue, and a low priority queue;
[0037] Step S140, using the service cluster associated with the message to be distributed, distributes the message to be distributed to the target user, wherein the service cluster includes multiple service nodes, and the distribution speed of the message to be distributed is controlled according to the service performance of each service node.
[0038] In step S110, multiple messages to be distributed are received, each of which carries message attributes and priority. The message attributes include the source department, business type, and timeliness requirements of the message, which are used to characterize the characteristics of the message. The priority is used to indicate the urgency of message processing.
[0039] In step S120, the messages to be distributed are allocated to different task queues according to the message attributes. Different task queues are independent of each other to ensure that different types of messages can be processed in parallel. For example, messages from different departments can be allocated to different task queues. Messages of different business types can also enter corresponding task queues based on their specific needs. For example, messages from the finance department are allocated to the finance queue. This allocation method based on message attributes can effectively isolate the processing flow of different types of messages and avoid interference between tasks. At the same time, through the design of independent task queues, the concurrency of message processing and the utilization of processing resources can be improved, thereby significantly improving the overall execution efficiency.
[0040] In step S130, in each task queue, the messages are further divided into multiple sub-queues based on the priority of the messages. For example, the high priority queue is used to store the most urgent messages, the medium priority queue is used to store the generally urgent messages, and the low priority queue is used to store the ordinary messages.
[0041] In step S140, the distribution speed of the message to be distributed is controlled according to the service performance of the service node to prevent the problem of message accumulation and service crash in the downstream service node, thereby ensuring the efficiency of message distribution and the stability of the system. For example, when the load of a service node is low, the speed of distributing messages to it is increased; when a service node is close to its performance limit, the speed of distributing messages to it is reduced.
[0042] In the above method, messages are allocated according to their different attributes and divided into independent task queues. This method can avoid mutual interference between tasks. At the same time, based on the above-mentioned refined management, it can significantly improve concurrent processing efficiency and resource utilization. Furthermore, the present application dynamically adjusts the message distribution speed to adapt to the processing capacity of downstream service nodes, effectively preventing message accumulation or service interruption caused by node overload, thereby ensuring the operational stability and efficiency of the distribution system.
[0043] According to an embodiment of the present application, the messages to be distributed are allocated to different task queues according to the source departments in the message attributes, and the task queues are processed independently.
[0044] In the existing distribution system, a large number of messages to be distributed from different departments are concentrated in a task queue and processed in a first-in-first-out manner. However, this distribution method is prone to the following problems: when a department needs to send a large number of messages, its distribution task may occupy queue resources for a long time. Messages from other departments must wait until the tasks of the previous department are all processed before they can be distributed, resulting in low overall distribution efficiency and unable to meet the needs of multiple departments to handle business at the same time.
[0045] In order to solve the above problems, the present invention proposes a message distribution method for allocating task queues based on the source department in the message attributes. For example, the attribute of the message from the operation department is identified as "operation department"; the attribute of the message from the business department is identified as "business department"; the attribute of the message from the marketing department is identified as "marketing department", and the 10 million messages to be distributed from the operation department are allocated to the "operation department task queue"; the 5 million messages to be distributed from the business department are allocated to the "business department task queue"; the 2 million messages to be distributed from the marketing department are allocated to the "marketing department task queue", and each task queue is processed independently.
[0046] This application allocates task queues for messages to be distributed according to the source department, so that the message distribution tasks of different departments do not interfere with each other, which significantly improves the distribution efficiency. Through the independent processing of task queues, the distribution delay problem caused by the blocking of a single queue in the existing system is solved, and the needs of concurrent processing of services by multiple departments are met. Finally, the method of this application is suitable for scenarios that need to handle massive message distribution, such as push notifications for C-end users, cross-departmental task scheduling, etc.
[0047] Furthermore, the number of high-priority queues in the subqueue is determined according to the importance of the source department in the message attributes. Employees from different departments can send messages to users according to business needs. This application allocates the number of high-priority queues according to the importance of different departments. The higher the importance of the department, the more high-priority queues can be allocated, and the higher the efficiency of sending messages. For example: a general department can use 3 high-priority queues at the same time; an important department can use 6 high-priority queues at the same time. In the above manner, the importance of different departments is effectively distinguished, ensuring that messages from important departments can be processed first, thereby improving the efficiency of message distribution and the timeliness of business response.
[0048] The importance of a department needs to be judged based on information from the following dimensions:
[0049] (1) Criticality of departmental business: The degree to which the department's core business affects the company's overall operations. For example, a sales department that is directly related to revenue growth or a customer service department that is related to customer satisfaction can be defined as a critical department;
[0050] (2) Urgency and priority processing needs of departmental messages: Departments usually need to send messages with a certain degree of urgency, such as tax notices handled by the finance department or compliance notices by the legal department, which may need to be processed with priority;
[0051] (3) Historical performance indicators: Based on past queue processing records, the processing resource requirements of certain departments are analyzed. For example, by monitoring which departments take the longest time to complete tasks or put the most pressure on the system, their importance levels can be adjusted.
[0052] According to an embodiment of the present application, different processing resources are configured for the task queue according to the message attributes of the message to be distributed in the task queue, and the message attributes of the message to be distributed include: one or more of the source department and timeliness requirements of the message to be distributed.
[0053] The processing resources of this application can be dynamically allocated using thread pool technology. Thread pool is a technology used for concurrent programming. It creates a group of threads in advance and stores them in a pool so that threads can be quickly allocated to perform tasks when needed. When the task is completed, the thread will be put back into the pool for subsequent use, which can effectively reduce the overhead of thread creation and destruction and improve the execution efficiency of the program. At the same time, the number of threads configured can be dynamically adjusted according to the processing needs of each department to ensure that different departments can complete tasks within a reasonable time.
[0054] Different departments will be assigned different numbers of threads depending on the source department of the message to be distributed. Each thread is only responsible for processing the message queue of that department. In this way, the use of processing resources can be accurately controlled according to the actual needs of each department. If the message to be distributed has a high timeliness requirement, this application will prioritize the scheduling of processing resources to be allocated to that department. For example, when the timeliness of the message is high, the number of threads in the department may be temporarily increased to ensure that high-priority messages are processed quickly. For example, based on the source department and timeliness requirements of the distributed message, the message queue belonging to Department A is allocated 4 threads to process the task, consuming 40% of the processing resources; the message queue belonging to Department B is allocated 2 threads, consuming 20% of the processing resources; the message queue belonging to Department C is allocated 1 thread, consuming 10% of the processing resources.
[0055] This application configures different processing resources according to the message attributes of the messages to be distributed in the task queue (such as the source department and timeliness requirements), accurately controls the use of processing resources, improves the system's parallel processing capabilities and execution efficiency, reduces thread management overhead, and optimizes overall performance.
[0056] Figure 2 FIG. 1 is a flow chart of a method for configuring processing resources according to an embodiment of the present application. Figure 2 As shown, the method includes:
[0057] Step S210, calculating a first score according to the importance of the source department of the message to be distributed;
[0058] Step S220, calculating a second score according to the timeliness requirement of the message to be distributed;
[0059] Step S230, calculating a third score according to the number of messages to be distributed in the task queue;
[0060] Step S240, calculating a fourth score according to the data size of the message to be distributed in the task queue;
[0061] Step S250, calculating a resource demand score according to the first score, the second score, the third score, the fourth score and the corresponding weight values;
[0062] Step S260: configuring processing resources of the corresponding task queue according to the resource demand score.
[0063] In step S210, before calculating the first score, it is necessary to evaluate the importance of the source department. This importance can be calculated based on the criticality of the department's business, the urgency and priority processing requirements of the department's messages, and historical performance indicators, etc., to obtain an importance score. The first score is calculated based on the importance score, wherein the importance score is positively correlated with the first score. When calculating the importance score, it can be rated based on the criticality of the department's business, the urgency and priority processing requirements of the department's messages, and historical performance indicators, etc., and different levels are assigned different scores, and then the importance score is calculated by weighted summation based on the weights of each indicator. Of course, it is also possible to use a relationship function based on the relationship between each indicator and the importance score, and use the relationship function and the corresponding score of the indicator to calculate the importance sub-score of the corresponding part, and summarize the sub-scores of multiple indicators to calculate the importance score.
[0064] In step S220, the timeliness requirement indicates the time frame within which the message needs to be processed (for example, all messages need to be sent within 3 hours or within one day). According to the urgency of the timeliness, the message is quantified or assigned different timeliness scores, i.e., the second score. More urgent messages will receive higher scores to ensure that the system processes these messages first.
[0065] In step S230, the more messages there are, the heavier the processing load of the queue is, and thus a higher processing resource configuration is required. The third score reflects the current load of the message queue, and can reasonably allocate processing resources according to the size of the queue.
[0066] In step S240, the data size of the message reflects the complexity and resource consumption of message processing. Larger data packets require more computing resources and time to process, and therefore require higher processing resource configuration.
[0067] In step S250, after completing the calculation of the above four scores, the application will perform a comprehensive calculation based on each score and the preset weight value to obtain the final resource demand score. Each score has a different weight in the calculation, and the weight value can be adjusted according to specific business needs. By weighted summation, multiple factors can be comprehensively considered to obtain a reasonable resource demand score.
[0068] In step S260, based on the resource requirement score, the system will decide how many processing resources (e.g., number of threads) to allocate to process the messages in the queue. If the resource requirement score is high, the system will allocate more threads for processing to ensure that the tasks in the queue can be completed in a timely and efficient manner. On the contrary, if the resource requirement score is low, fewer threads will be allocated to avoid unnecessary waste of resources.
[0069] Through the above steps, the present embodiment can accurately calculate the resource requirements of the task queue, and intelligently configure the processing resources according to factors such as the message attributes, the number of messages and the data size in the task queue. This resource allocation method based on message attributes can effectively improve the resource utilization of the system, reduce resource waste, and ensure efficient processing of tasks.
[0070] Figure 3 FIG. 1 is a flow chart of a method for controlling the distribution speed of messages to be distributed according to an embodiment of the present application. Figure 3 As shown, the method includes:
[0071] Step S310, calculating the service performance score of each service node according to the processor utilization rate, memory utilization rate and number of concurrent requests of each service node;
[0072] Step S320, comparing the service performance scores of all service nodes to determine the minimum service performance score;
[0073] Step S330: dynamically adjust the distribution speed of the message to be distributed according to the minimum service performance score.
[0074] In step S310, the processor usage rate is used to measure the current CPU resource usage of the node; the memory usage rate is used to measure the memory resource usage of the node; and the number of concurrent requests is used to measure the number of requests processed by the node at the same time. The above indicators can reflect the current load of each node. Combining this information, the system will calculate the service performance score of each service node. In addition, the score can be combined with the weight of each indicator to calculate the service performance indicator.
[0075] In step S320, the minimum service performance score represents the node with the most load or resource shortage. The purpose of this step is to determine the weakest link of the system so as to take corresponding resource adjustment measures. Specifically, first, the performance scores of all service nodes are traversed, and then the node with the minimum performance score is found; finally, the minimum score value is determined as the basis for subsequent adjustments.
[0076] In step S330, if the minimum service performance score is low, it indicates that some nodes are heavily loaded, and the system should reduce the distribution speed of the messages to be distributed to avoid overload and ensure stable operation of the system. On the contrary, when the minimum service performance score is high, it indicates that the system load is light and the messages can be distributed faster. When adjusting the distribution speed, a distribution rate coefficient can be set to make a proportional adjustment based on the difference between the minimum service performance score and the preset performance standard.
[0077] The above method realizes the calculation of service performance score based on the processor utilization, memory utilization and number of concurrent requests of each service node, and then dynamically adjusts the distribution speed of the messages to be distributed. This method can automatically optimize the allocation of system resources under different loads, ensure the efficiency and stability of message processing, and effectively improve the performance of the entire system.
[0078] According to one embodiment of the present application, when the message to be distributed is an emergency message, it is assigned to the corresponding task queue according to the message attributes of the emergency message; the current message distribution task in the task queue is interrupted, and the distribution task of the emergency message is processed first.
[0079] In the task queue, there are usually multiple messages to be processed. When the system receives an urgent message, the urgent message needs to be processed first. To this end, the message distribution task currently being executed in the task queue will be interrupted according to the priority of the urgent message. It will be inserted at the front of the queue and processed first. This queue-jumping mechanism ensures that the urgent message can be processed in the shortest time. By sending messages from the same department in the queue, it can ensure that the urgent message is processed in time without affecting the normal execution of messages from other departments. This mechanism effectively improves the response speed and flexibility of handling urgent tasks.
[0080] The implementation methods and advantages of the embodiments of the present application are described above through multiple embodiments. The specific processing process of the embodiments of the present application is described in detail below with reference to specific examples.
[0081] This application takes the marketing system as an example. Every day, employees from different departments need to send marketing information. Their approach is to first identify a group of people (target users), the number of which ranges from 1 to 10 million, and then send message notifications to these people, such as text messages, emails, in-site messages, and coupons, etc. For example, departments A, B, and C have employees A1, A2, B1, C1, C2, and C3 respectively.
[0082] Employee A1 sends 3 million email messages once, 2 million SMS messages, 200,000 coupon messages, and 7 million email messages. Similarly, employees A2, B1, C1, C2, and C3 will also send similar message push messages. For example, a total of 150 million messages are sent and pushed at different times of the day. These 150 million push messages will be distributed using the following two methods.
[0083] Figure 4 This is a flow chart of the existing method for queue message distribution. Figure 4 As shown in the figure, the process of queue message distribution includes:
[0084] 1. Circle people
[0085] Determine the target user group to which push information needs to be sent. The size of this target user group can range from 1 to 10 million. The circle can be defined by designated departments or employees based on business needs.
[0086] 2. Queue Routing
[0087] Queue routing is used to combine the above-defined groups of people and generate a consumption queue A for the messages to be distributed according to the first-in-first-out principle.
[0088] 3. Consumption
[0089] When the message to be distributed is added to the "consumption queue A", it enters the consumption stage. Message consumption means that the consumer node calculates and processes the message. The messages in the queue will be distributed to multiple consumer nodes for processing (marked as "consumption node 1", "consumption node 2"... "consumption node n" in the figure). Each consumer node can correspond to a computing node, which is responsible for taking out the message from the queue and processing it.
[0090] 4. Call the service cluster
[0091] When processing messages, consumer nodes call downstream service clusters to complete specific business operations, such as sending emails, text messages, push notifications, in-site messages, or distributing coupons. The figure shows "service cluster a", "service cluster b", "service cluster c", and "service cluster h". These service clusters correspond to different business needs. For example, service cluster a is responsible for sending emails; service cluster b is responsible for sending text messages; service cluster c is responsible for pushing coupons.
[0092] Figure 5 FIG. 1 is a flow chart of queue message distribution according to an embodiment of the present application. Figure 5 As shown in the figure, the process of queue message distribution includes:
[0093] 1. Circle people
[0094] The work content is the same as the above-mentioned circle of people, so I will not repeat it here.
[0095] 2. Queue Routing
[0096] Depending on the source department of the message, the messages of each department will be classified into different queues. Queue routing divides these messages into multiple queues, such as operation queues, marketing queues, etc. The queues of each department can be divided into high priority queues and low priority queues according to the priority. For example, the messages of departments A, B and C are divided into three department queues according to the department, and each department queue is divided into high priority queues and low priority queues. The queues of departments A, B and C are independent.
[0097] 3. Queue consumption
[0098] Different processing resources will be allocated to each department's queue according to its importance, and the number of allocated threads will be strictly controlled. For example, 4 threads are allocated to the queue of department A, 2 threads are allocated to the queue of department B, and 1 thread is allocated to the queue of department C to process and consume messages in the corresponding queues. Assuming that a thread consumes 10% of CPU resources when running, then the queue of department A consumes 40% of resources, the queue of department B consumes 20% of resources, and the queue of department C consumes 10% of resources.
[0099] 4. Call the service cluster
[0100] The corresponding service cluster is called according to the business dimension to complete the actual sending of the message. Even if the queue of each department is split into multiple sub-queues, it is still regarded as an overall dimension from the business perspective and calls the same downstream service. When distributing messages through the downstream service cluster, the flow will be limited according to the service performance of the downstream service cluster to avoid overload.
[0101] Traffic shaping technology can be used to limit traffic based on the service performance of the downstream service cluster. Traffic shaping is a measure to actively adjust the traffic output rate. Its main function is to limit traffic and bursts so that messages are sent out at a relatively uniform rate. Traffic shaping can be done using buffers and token buckets. When the message (message) is sent too fast, it is first cached in the buffer, and then the buffered messages are sent evenly under the control of the token bucket.
[0102] Figure 6 is to use Figure 4 Traffic monitoring diagram of message distribution using the method in . Figure 7 is to use Figure 5 Traffic monitoring diagram of message distribution using the method in . Figure 6 and Figure 7 The horizontal axis is the time axis, which records the number of messages distributed by the distribution system at different times, and the vertical axis is the number of messages sent at the corresponding time, which is the flow rate, in millions (Mil).
[0103] Depend on Figure 6 From the data, we can see that using the existing method to record the message distribution traffic from August 11 to September 9, the peak of message distribution is concentrated between 10 million and 15 million, and the peak fluctuation is large. The maximum peak value of message distribution is close to 35 million, which is 2-3 times the usual peak value. The daily push volume is between 30 million and 50 million.
[0104] Depend on Figure 7 From the data in, we can see that using the method of this application, the message distribution traffic from December 4 to December 11 was recorded, and the peak of message distribution was concentrated between 15 million and 20 million, and the peak distribution was even, and the overall fluctuation was relatively stable. The daily message push volume can reach 150 million.
[0105] It can be seen that after the optimization of this application, the numerical stability of the peak indicator of sending messages has been improved, the fluctuation range has been reduced, and the message consumption speed is higher, and the message backlog has been reduced by more than 30%. Compared with before the improvement, the number of messages sent per day could not reach the order of 100 million, but after the improvement, the task of sending messages at the 100 million level can be completed before 5 pm.
[0106] Figure 8 This is a flow monitoring diagram before and after the message distribution method is improved. Figure 8 In the figure, the horizontal axis is the time axis, which records the number of messages distributed by the distribution system at different times, and the total axis is the number of messages sent at the corresponding time, which is the flow rate, and the unit is thousand (k). Figure 8 The first area 810 and the second area 820 are included. The first area 810 uses the existing method to record the traffic monitoring situation from August 1 to September 23, which is represented by a red line; the second area 820 uses the method of the present application to record the traffic monitoring situation from October 1 to December 8, which is represented by an orange line.
[0107] Depend on Figure 8From the data in , we can see that after optimization, the maximum flow peak of the distribution system has decreased. This shows that the optimization measures have effectively controlled the excessive growth of flow and avoided the potential risk of overload. In addition, the optimized flow curve is smoother and has less fluctuation. This shows that the optimized distribution system can better cope with flow fluctuations and improve overall stability.
[0108] Corresponding to the method embodiment of the present application, the present application also provides a message distribution device based on message attributes, such as Fig. 9 As shown, the message distribution device 100 includes:
[0109] The receiving module 110 is used to receive a plurality of messages to be distributed from a database of messages to be distributed, wherein the messages to be distributed include: message attributes and priorities;
[0110] An allocation module 120, for allocating the to-be-distributed messages to different task queues according to the message attributes, and the task queues are processed independently;
[0111] A splitting module 130, for splitting the to-be-distributed messages in the task queue into a plurality of sub-queues according to the message attributes and priorities, wherein the sub-queues include: one or more of a high priority queue, a medium priority queue, and a low priority queue;
[0112] The distribution module 140 is used to distribute the message to be distributed to the target user by using the service cluster associated with the message to be distributed, wherein the service cluster includes multiple service nodes, and controls the distribution speed of the message to be distributed according to the service performance of each service node.
[0113] Fig.10 It is a schematic diagram of the hardware structure principle of an electronic device according to an embodiment of the present application. The electronic device can be implemented as a server or various other terminal devices, such as a desktop personal computer, a tablet computer, a laptop computer, a mobile phone, etc., including a processor 601 and a memory 602. The memory 602 stores a program instruction set. When the processor 601 executes the program instruction set on the memory 602, any of the aforementioned message distribution methods based on message attributes is implemented.
[0114] Specifically, the processor 601 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiment of the present invention.
[0115] The memory 602 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 602 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 602 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 602 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 602 is a non-volatile solid-state memory.
[0116] The memory may include a read-only memory (ROM), a random access memory (RAM), a disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the message distribution method based on message attributes provided by the present invention.
[0117] In one example, the electronic device may further include a communication interface 603 and a bus 604. The processor 601, the memory 602, and the communication interface 603 are connected through the bus 604 and complete the communication between each other. The communication interface 603 is mainly used to realize the communication between the modules, devices, units and / or devices in the embodiment of the present invention. The bus 604 includes hardware, software or both, and couples the components of the online data traffic billing device to each other. For example, but not limitation, the bus may include an accelerated graphics port (AGP) or other graphics bus, an enhanced industrial standard architecture (EISA) bus, a front-end bus (FSB), a hypertransport (HT) interconnect, an industrial standard architecture (ISA) bus, an infinite bandwidth interconnect, a low pin count (LPC) bus, a memory bus, a micro channel architecture (MCA) bus, a peripheral component interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a serial advanced technology attachment (SATA) bus, a video electronics standard association local (VLB) bus or other suitable buses or a combination of two or more of these. Where appropriate, the bus 604 may include one or more buses. Although embodiments of the present invention describe and illustrate a particular bus, the present invention contemplates any suitable bus or interconnect.
[0118] The present invention also provides a computer-readable storage medium having computer program instructions stored thereon, and the computer program instructions can be executed by a processor to implement any of the message distribution methods based on message attributes in the aforementioned embodiments. The computer-readable storage medium can be any medium that can tangibly contain or store computer-executable instructions for use by or in combination with an instruction execution system, device, and equipment. The storage medium can be a transient computer-readable storage medium or a non-transient computer-readable storage medium. Non-transient computer-readable storage media may include, but are not limited to, magnetic storage devices, optical storage devices, and / or semiconductor storage devices. Examples of corresponding embodiments of such storage devices include, for example, magnetic disks, optical disks based on CD, DVD, or Blu-ray technology, and persistent solid-state memories such as flash memory, solid-state drives, and the like.
[0119] The present invention also provides a computer program product, which includes a set of computer program instructions, and when the computer program instruction set is executed by a processor, any one of the message distribution methods based on message attributes in the above embodiments is implemented. The computer program product includes but is not limited to application installation packages published on websites and application stores, application plug-ins, and small programs that can be run in certain applications.
[0120] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0121] The above embodiments are only used to illustrate the present invention, but not to limit the present invention. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the scope of the present invention. Therefore, all equivalent technical solutions should also fall within the scope of the present invention.
Claims
1. A message distribution method based on message attributes, characterized in that: include: Receiving a plurality of messages to be distributed, wherein the messages to be distributed include: message attributes and priorities; Allocate the to-be-dispatched messages to different task queues according to the message attributes, and process the task queues independently; Splitting the messages to be distributed in the task queue into a plurality of sub-queues according to the message attributes and priorities, the sub-queues comprising: one or more of a high priority queue, a medium priority queue and a low priority queue; The message to be distributed is distributed to a target user by using a service cluster associated with the message to be distributed, wherein the service cluster includes a plurality of service nodes, and the distribution speed of the message to be distributed is controlled according to the service performance of each service node.
2. The method according to claim 1, characterized in that Further including: Different processing resources are configured for the task queue according to the message attributes of the message to be distributed in the task queue, wherein the message attributes of the message to be distributed include: one or more of the source department and timeliness requirement of the message to be distributed.
3. The method according to claim 2, characterized in that Further including: A first score is calculated based on the importance of the source department of the message to be distributed; A second score is calculated according to the timeliness requirement of the message to be distributed; A third score is calculated according to the number of messages to be distributed in the task queue; A fourth score is calculated based on the data size of the message to be distributed in the task queue; The resource demand score is calculated according to the first score, the second score, the third score, the fourth score and the corresponding weight values; Configure the processing resources of the corresponding task queue according to the resource requirement score.
4. The method according to claim 1, characterized in that: According to the service performance of each service node, the distribution speed of the messages to be distributed is controlled by: Calculate the service performance score of each service node based on the processor utilization, memory utilization and number of concurrent requests of each service node; Compare the service performance scores of all service nodes and determine the minimum service performance score; The distribution speed of the messages to be distributed is dynamically adjusted according to the minimum service performance score.
5. The method according to claim 1, characterized in that Further including: When the message to be distributed is an urgent message, it is allocated to the corresponding task queue according to the message attribute of the urgent message; The current message distribution task in the task queue is interrupted, and the distribution task of the emergency message is processed first.
6. The method according to claim 1, characterized in that The messages to be distributed are distributed to different task queues according to the source departments in the message attributes, and the task queues are processed independently.
7. The method according to claim 1, characterized in that The number of high priority queues in the subqueue is determined according to the importance of the source department in the message attribute.
8. A message distribution device based on message attributes, characterized in that: include: A receiving module, used for receiving a plurality of messages to be distributed, wherein the messages to be distributed include: message attributes and priorities; An allocation module, used for allocating the to-be-distributed messages to different task queues according to the message attributes, and the task queues are processed independently; A splitting module, used for splitting the to-be-distributed messages in the task queue into a plurality of sub-queues according to the message attributes and priorities, wherein the sub-queues include: one or more of a high priority queue, a medium priority queue and a low priority queue; The distribution module is used to distribute the message to be distributed to the target user by using the service cluster associated with the message to be distributed, wherein the service cluster includes multiple service nodes, and the distribution speed of the message to be distributed is controlled according to the service performance of each service node.
9. An electronic device, characterized in that: It includes a processor and a memory, wherein a computer program instruction set is stored in the memory, and when the processor executes the computer program instruction set in the memory, the message distribution method based on message attributes described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: in, The computer-readable storage medium stores a computer program instruction set, and when the computer program instruction set is executed by a processor, the message distribution method based on message attributes described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Message processing method and electronic equipment
CN121050905A