A method for implementing an aggregate message sending buffer pool
By splitting and caching the signature key in Redis, combined with distributed deployment and load balancing, the stability and reliability issues of internal message sending within enterprises are resolved, achieving efficient and orderly message sending and system scalability.
Patent Information
- Application Number
- CN202211509110.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-11-29
AI Technical Summary
Existing technologies cannot effectively handle the caching and sending needs of different types of messages from various channels within an enterprise, especially under high concurrency conditions, making it difficult to guarantee the stability and reliability of the system.
A signing key is generated by signing an agreement, messages are segmented into small packets and cached in Redis, a distributed deployment and load balancing mechanism is adopted, the sending density is calculated according to message type and priority, Redis is used for secure temporary storage, and breakpoint resume and server elastic scaling are realized.
It enables efficient and orderly message sending, supports high concurrency, ensures system stability and reliability, and simplifies message customization processing.
Smart Images

Figure CN115801723B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of data processing, and in particular to a method for realizing an aggregated message sending buffer pool. Background Art
[0002] When some business systems are running, they need to send messages to users accurately and in batches in real time or at a fixed time. However, due to the various changes in the content and type of messages, there is a need for the sending channels to be able to be flexibly expanded or reduced. For example, messages include TV device information, SMS information, WeChat information, etc. Messages are all outward-looking B2C messages that directly connect to users, so the volume is in the tens of millions, which places high requirements on the stability, security, and reliability of the system. Therefore, specific verification and cache settings are required before sending to the corresponding operation service interface, so that the system can carry the needs of caching and sending information from various channels within the enterprise and extended channels, but there is no such solution in the existing technology. Summary of the invention
[0003] The purpose of the present invention is to provide a method for realizing an aggregated message sending buffer pool, so that the system can carry different types of messages from various channels within the enterprise and meet the needs of information caching and sending of future expansion channels.
[0004] The present invention solves the above problems through the following technical solutions:
[0005] A method for implementing an aggregate message sending buffer pool, comprising:
[0006] Step S100: After the business party signs the agreement with the message platform, the message platform generates a signature key corresponding to the business party according to the business content and sets the upper limit of the number of requests sent by the business party per day, the message priority msg_level and the message type msg_type. The business party accesses the message platform in an encrypted manner.
[0007] Step S200: After receiving the request, the message platform cuts different message chains into message packets of set sizes according to the message type msg_type carried in the request, and sets a uid for the message packet to mark which batch the message packet comes from; and calculates the sending density of message forwarding according to the message priority msg_level carried in the request;
[0008] Step S300, store the message packet into redis for caching, and the message platform processes it regularly according to the data size of the cache data pool: access redis to retrieve the message packet and cache it into the memory. If the uid of the message packet is not continuous, it is necessary to retrieve the message packet from redis again. If the uid of the message packet is continuous, send the message packet according to the sending density. After successful sending, delete the message in redis.
[0009] If the message platform receives too many batch messages at the same time, the message platform sets the sending time to be delayed according to the preset overall delay value.
[0010] When cutting message packets, the number of message packets is equal to the message chain length / the set length threshold rounded up.
[0011] The calculation method of sending density is: the total number of received messages is scientifically counted, divided into base and power k, and the number is counted in ten thousand. The priority value is If there are two batches of messages of the same type, and their priority values are a and b respectively, then the ratio of their sending densities is a / b.
[0012] When an interruption occurs while the business party is sending a batch message, if the business party continues to start sending within the set interval until the message platform receives the message end flag end_tag of the batch message, it is considered to be the same batch message. If the business party does not continue to send within the set interval or the message platform does not receive the message end flag end_tag of the batch message, it is considered that the batch message has failed to be sent, the received messages in the batch message are cleared, and the business party needs to resend it.
[0013] The same redis is used to record the message end tag of batch messages, synchronize the message end tag between different servers, and the server checks the end tag in redis when receiving batch messages to achieve synchronization between different servers. Therefore, if the message pressure is too high, the server can be elastically expanded. The messages received and processed by one server are load balanced on the gateway kong according to the current CPU and memory usage. If the CPU usage is greater than 80% or the memory usage is greater than 80% (which can be flexibly assigned according to the server configuration), a new service is started on the new server and the load balancing of the gateway kong is added to reduce the pressure on a single server.
[0014] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0015] The present invention unifies the input standard, divides the message by caching and other methods, and then sends the message at a set time, so that the message sending will be more orderly, the access is convenient, the message customization is simple, and the supported message sending volume is very high. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION
[0017] The present invention is further described in detail below in conjunction with examples, but the embodiments of the present invention are not limited thereto.
[0018] Example:
[0019] Combined with Figure 1 As shown, a method for implementing an aggregate message sending buffer pool includes:
[0020] 1. Different data sources sign an agreement with the message platform. After the agreement is signed, the backend of the message platform generates the corresponding signature key according to the business content. The business party can use the same output format of the interface document and access the message platform in an encrypted manner;
[0021] When signing the agreement, the backend will assign the corresponding daily maximum number of messages sent, business message priority msg_level and message type msg_type according to the needs of the business party. msg_level is given a five-level value (1-5) based on the estimate, and msg_type is determined based on whether the TV message, WeChat message or SMS message is sent;
[0022] 2. The message platform classifies different message chains according to msg_type (one message chain refers to one request, because if 1000 message requests are sent 1000 times, the consumption is very high, so 1000 messages can be sent at the same time, and then the message platform will divide them into, for example, 100*10, and then aggregate and send them), and cuts the message chain into message packets of a set length. For example, if the length is set to 10, if the length of the message chain sent is 1000, it will be divided into 100 message packets. When the message packets are generated, the uid value is given to determine the order of the messages. If the length of the message chain is not a multiple of 10, for example, 155 messages are sent at one time, it will be divided into 16 packets.
[0023] 3. When each batch of messages comes in, the algorithm is used to determine the processing intensity based on the msg_level it carries:
[0024] The total number of received batch messages is scientifically counted into base and power k. The number is counted in ten thousand. The priority value is msg_level*√base k / Ttime , T time is the timeline, √base k Indicates the base value of the kth power after the square root, such as 5*10 k Here 5 is base, which refers to 5w. If k=1, it is 10 to the power of 1, and the total amount is 50w data. k=2 is 10 to the power of 2, which is 5 million data.
[0025] There are two ways to determine the density:
[0026] Case 1: Batch messages are of the same type. For example, there are two groups of batch messages of the same type, A and B. According to the quantity, msg_level, T time The priority value of group A is calculated as a, and the priority value of group B is calculated as b, and the sending density of the two is set to a / b. For example, a / b = 10, then every time 10 A packets are sent out, only one B packet is sent out.
[0027] Case 2: Batch messages are of different types. For example, when two groups of batch messages of different types, C and D, come in, their sending densities are only related to the characteristic values of their messages (total quantity, sending time, etc.), and their sending densities are not comparable.
[0028] 4. After the message platform receives and processes the message packets, it stores the message packets in redis for caching. The timer of the message platform will process the messages in batches according to the size of the data pool and the records through periodic polling. If the message is lost, the message platform will access redis to retrieve the message packets for re-memory caching. If the message is sent normally, the system will delete the cached messages. If the message UID is not continuous, that is, the message is lost anyway, the message platform needs to retrieve the unsent messages from redis and continue to send them.
[0029] 5. When the message platform receives too many batch messages at the same time, the message platform will infinitely delay the sending time according to the overall delay value. The overall delay value is set by the system configuration. The basic setting value is 1 week, that is, if the queue messages cannot be sent in a week, an error will be returned to the newly entered message. If the setting value is larger, such as 1 month, then the newly entered message will be completed within one month according to the sequence;
[0030] 6. When the message platform receives batch messages, it performs breakpoint-resume transmission. The message packets can wait for 5 minutes. If the business party continues to send messages within 5 minutes, and the message platform finally receives the message end tag of the batch message, the system defaults to receiving all the messages in this batch. If the message sending is interrupted for more than 5 minutes or the end_tag is not received, all the packets in this batch will be deleted and the messages will not be sent out.
[0031] 7. When deploying the business, a distributed deployment method is adopted to go online. The same redis is used to record end_tag to synchronize the end flag of batch messages between different servers. When the server receives a batch message, it goes to redis to check end_tag to achieve synchronization between different servers. Therefore, if the message pressure is too high, the server can be elastically expanded. The messages received and processed by one server, the operation and maintenance end performs load balancing on the gateway kong according to the current CPU and memory usage. If the CPU usage is greater than 80% or the memory usage is greater than 80% (which can be flexibly allocated according to the server configuration), a new service is started on the new server and the load balancing of the gateway kong is added to reduce the pressure on a single server.
[0032] The advantages of the present invention are:
[0033] Unified message entry: Use the msg_type field to distinguish the incoming message type, and distinguish it during subsequent processing. After unification, the entry is single, and the amount of parallel processing can be expanded through distributed deployment. In addition, elastic load deployment can be performed based on the server pressure value of operation and maintenance.
[0034] Use the non-relational database redis for secure temporary caching: After a large number of messages enter, they will be initially processed. At this time, if there are network fluctuations or other problems, a fast channel for temporary caching is needed. Using redis to temporarily store a large number of messages can speed up the processing speed of upstream and downstream data and process them at a high hit rate.
[0035] Message type and priority processing: By judging the fields, the messages are processed into a pile of packets. At the same time, the priority field msg_level is judged to process the sending interval, so as to dynamically share the sending pressure.
[0036] Parallel priority processing: Depending on the message type, the sending density of the same type of messages is divided according to msg_level. Three types of messages can be sent simultaneously without conflict.
[0037] Although the present invention is described herein with reference to the illustrative embodiments of the present invention, the above embodiments are only preferred embodiments of the present invention, and the embodiments of the present invention are not limited to the above embodiments. It should be understood that those skilled in the art can design many other modifications and embodiments, which will fall within the scope and spirit of the principles disclosed in this application.
Claims
1. A method for implementing an aggregate message sending buffer pool, characterized in that: include: Step S100: After the business party signs the agreement with the message platform, the message platform generates a signature key corresponding to the business party according to the business content and sets the upper limit of the number of requests sent by the business party per day, the message priority msg_level and the message type msg_type. The business party accesses the message platform in an encrypted manner. Step S200: After receiving the request, the message platform cuts different message chains into message packets of set sizes according to the message type msg_type carried in the request, and sets a uid for the message packet to mark which batch the message packet comes from; and calculates the sending density of message forwarding according to the message priority msg_level carried in the request; Step S300, store the message packet into redis for caching, and the message platform processes it regularly according to the data size of the cache data pool: access redis to retrieve the message packet and cache it into the memory. If the uid of the message packet is not continuous, it is necessary to retrieve the message packet from redis again. If the uid of the message packet is continuous, send the message packet according to the sending density. After successful sending, delete the message in redis.
2. The method for implementing an aggregate message sending buffer pool according to claim 1, characterized in that: If the message platform receives too many batch messages at the same time, the message platform sets the sending time to be delayed according to the preset overall delay value.
3. The method for implementing an aggregate message sending buffer pool according to claim 1, characterized in that: When cutting message packets, the number of message packets is equal to the message chain length / the set length threshold rounded up.
4. The method for implementing an aggregate message sending buffer pool according to claim 1, characterized in that: The calculation method of sending density is: the total number of received messages is scientifically counted, divided into base and power k, and the number is counted in ten thousand. The priority value is msg_level*√base k / T time , where T time is the timeline, base is the total number of messages; if there are two batches of messages of the same type, and their priority values are a and b respectively, then the ratio of their sending densities is a / b.
5. The method for implementing an aggregate message sending buffer pool according to claim 1, characterized in that: When an interruption occurs while the business party is sending a batch message, if the business party continues to start sending within the set interval until the message platform receives the message end flag end_tag of the batch message, it is considered to be the same batch message. If the business party does not continue to send within the set interval or the message platform does not receive the message end flag end_tag of the batch message, it is considered that the batch message has failed to be sent, the received messages in the batch message are cleared, and the business party needs to resend it.
6. The method for implementing an aggregate message sending buffer pool according to claim 5, characterized in that: The same redis is used to record the message end flag end_tag of batch messages, and the message end flag end_tag between different servers is synchronized. When the server receives batch messages, it checks the end_tag in redis to achieve synchronization between different servers.
