Message pushing method and related equipment
By obtaining and analyzing the operating status and information of long-connected service nodes, point-to-point push of messages is realized, which solves the problems of waste of node resources and inaccurate message push, improves efficiency and reliability, and supports dynamic expansion and shrinking of capacity.
Patent Information
- Application Number
- CN202410873962.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-12-17
AI Technical Summary
In a high concurrency service system, each long-connected service node needs to consume and parse each message, resulting in waste of node resources, and the client corresponding to the message cannot be accurately determined during the message push process, resulting in waste of resources and difficulty in troubleshooting abnormalities .
By obtaining the operating status and long connection information of each long connection service node, analyzing the receiver identification information of the message to be pushed, finding and pushing it to the target node that establishes a long connection with the message receiver, realizing point-to-point accurate push of messages and reducing resources Consumption and quickly locate abnormal nodes through heartbeat detection and status maintenance.
It is realized that each long-connected service node only needs to process the messages from the message recipients that establish a connection with it, reduce resource consumption, improve the efficiency and reliability of message push, simplify the abnormality check process, and support dynamic expansion and shrinking to cope with business peaks. Lower period.
Smart Images

Figure CN119155342A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a message push method and related equipment. Background Art
[0002] The business system needs to push messages to the client. For high-concurrency business systems, multiple nodes are generally used to push messages generated by the business system to the corresponding clients. For the client, the client can generally only establish a long connection with one of the nodes.
[0003] In order to accurately push messages to the corresponding clients, the current practice is generally: each node consumes the message and parses the message to determine whether the client corresponding to the message has established a persistent connection with itself. If a persistent connection is established, the message is pushed to the client through the persistent connection, otherwise, the message is discarded. This approach requires each node to consume and parse the message, which greatly wastes node resources. Summary of the invention
[0004] In view of the above, it is necessary to provide a message push method and related equipment, which can solve the problem that each node has to consume messages during the message push process, resulting in a waste of node resources.
[0005] In a first aspect, the present application provides a message push method, which is applied to a message push device, the message push device is used to communicate with a long connection service cluster, the long connection service cluster includes multiple long connection service nodes, each long connection service node is used to establish a long connection with one or more message recipients, the message push method includes: obtaining the running status of each long connection service node, and receiving the long connection information reported by each long connection service node, the long connection information includes the identification information of the long connection service node and the identification information of the message recipient that establishes a long connection with the long connection service node; parsing the message to be pushed to obtain the identification information of the message recipient corresponding to the message to be pushed; according to the received long connection information and the identification information of the message recipient corresponding to the message to be pushed, searching from multiple long connection service nodes for the identification information of the first target long connection service node that establishes a long connection with the message recipient corresponding to the message to be pushed; when the running status of the first target long connection service node is normal, based on the identification information of the first target long connection service node, the message to be pushed is pushed to the first target long connection service node, so that the message to be pushed is pushed to the message recipient corresponding to the message to be pushed through the first target long connection service node.
[0006] By adopting the above technical solution, each long connection service node does not need to consume every message generated by the message producer. Each long connection service node only needs to process the messages pushed by the message push device, that is, it only needs to consume the messages of the message recipient with which it has established a long connection, thereby realizing point-to-point precise message push and reducing the consumption of resources (CPU resources, memory resources, etc.). Moreover, since there is no need to configure each long connection service node to subscribe to messages, it is easier and faster to expand / shrink the long connection service node when facing the peak or trough period of message generation of the message producer. Moreover, by setting the message push device to push messages to the corresponding long connection service node when the long connection service node is in normal status, it can avoid meaninglessly pushing messages to the corresponding long connection service node.
[0007] In a possible implementation, the message push method also includes: determining the business concurrency coefficient of the long connection service cluster based on the long connection information reported by each long connection service node; if the business concurrency coefficient of the long connection service cluster is greater than or equal to a first threshold, sending an expansion notification to the long connection service cluster so that the long connection service cluster is expanded based on the expansion notification; if the business concurrency coefficient of the long connection service cluster is less than or equal to a second threshold, sending a reduction notification to the long connection service cluster so that the long connection service cluster is reduced based on the reduction notification, and the first threshold is greater than the second threshold.
[0008] By adopting the above technical solution, based on the long connection information reported by each long connection service node, the business concurrency coefficient of the long connection service cluster is determined, and the business concurrency coefficient can be used to indicate the overall size of the number of long connections of the long connection service nodes in the long connection service cluster. If the business concurrency coefficient of the long connection service cluster is greater than or equal to the first threshold, it indicates that the long connection service nodes in the long connection service cluster have established a large number of long connections, and the number of long connections is approaching the threshold. In order to avoid subsequent message forwarding congestion, an expansion notification is sent to the long connection service cluster so that the long connection service cluster can be expanded based on the received expansion notification. If the business concurrency coefficient of the long connection service cluster is less than or equal to the second threshold, it indicates that the long connection service nodes in the long connection service cluster have established a small number of long connections. In order to avoid wasting node resources, a reduction notification is sent to the long connection service cluster so that the long connection service cluster can be reduced based on the reduction notification. If the business concurrency coefficient of the long connection service cluster is greater than the second threshold and less than the first threshold, it indicates that the number of long connections of each long connection service node in the long connection service cluster is appropriate. In this case, there is no need to expand or reduce the capacity of the long connection service cluster, and the message push device does not send an expansion notification or a reduction notification to the long connection service cluster. The long connection service cluster can maintain the number of long connection service nodes unchanged.
[0009] In a possible implementation, identification information reported by each persistent connection service node after startup is received and stored; heartbeat detection is performed with each persistent connection service node; if the heartbeat detection result of a first persistent connection service node among multiple persistent connection service nodes is a detection abnormality, the stored identification information of the first persistent connection service node is deleted, or a preset mark is added to the stored identification information of the first persistent connection service node.
[0010] By adopting the above technical solution, by configuring the long connection service node to report its own identification information after startup, it is convenient to obtain the number and information of the long connection service nodes currently started by the system, and maintain the reported identification information based on the heartbeat detection result, so as to obtain the current number of valid long connections and valid long connection service nodes in the system, and facilitate the troubleshooting of abnormal problems when abnormalities occur in message push later.
[0011] In a possible implementation, after receiving the long connection information reported by each long connection service node, the message push method further includes: storing the received long connection information; updating the stored long connection information based on the long connection disconnection information reported by each long connection service node or the identification information of the abnormally operating long connection service node, wherein the long connection disconnection information is used to indicate that a long connection service node disconnects a long connection with a message recipient.
[0012] By adopting the above technical solution, by maintaining the reported long connection information, it is convenient to know the current number of valid long connections in the system, and to quickly locate on which long connection service node the long connection of the message recipient is established, so as to facilitate the abnormal problem troubleshooting when an abnormality occurs in message push.
[0013] In a possible implementation, the message push method also includes: when the operating status of the first target persistent connection service node is abnormal, discarding the message to be pushed; or when the identification information of the first target persistent connection service node that establishes a persistent connection with the message recipient corresponding to the message to be pushed is not found, discarding the message to be pushed.
[0014] By adopting the above technical solution, based on the immediacy of message push, messages that are delayed too long may not need to be pushed to the message recipient. By setting the operating status of the first target long connection service node to be abnormal, or when the identification information of the first target long connection service node that establishes a long connection with the message recipient corresponding to the message is not found, the message to be pushed is directly discarded to avoid meaningless message push.
[0015] In a possible implementation, the message push method also includes: when the operating status of the first target long connection service node is abnormal operation, selecting a backup long connection service node from the remaining long connection service nodes except the first target long connection service node based on preset rules, wherein the message recipient corresponding to the message to be pushed can maintain or disconnect the long connection with the first target long connection service node based on the heartbeat detection result with the first target long connection service node; sending the identification information of the backup long connection service node to the long connection service cluster to trigger the backup long connection service node to establish a long connection with the message recipient corresponding to the message to be pushed; when receiving the long connection information associated with the message recipient corresponding to the message to be pushed reported by the backup long connection service node, pushing the message to be pushed to the backup long connection service node, so as to push the message to be pushed to the message recipient corresponding to the message to be pushed through the backup long connection service node.
[0016] By adopting the above technical solution, when the operation state of the first target long connection service node is abnormal, the backup mechanism is used to try to push the message to the corresponding message recipient, which can maximize the possibility that the message generated by the message producer is successfully pushed to the corresponding message recipient. For example, the backup mechanism includes selecting a backup long connection service node from the remaining long connection service nodes except the first target long connection service node based on a preset rule, and establishing a long connection with the message recipient corresponding to the message to be pushed through the backup long connection service node. The preset rule can be to select the backup long connection service node based on the number of long connections of the long connection service node and / or the available resources of the long connection service node.
[0017] In a possible implementation, the preset rule includes: selecting the standby persistent connection service node based on the number of persistent connections of the persistent connection service node and / or based on available resources of the persistent connection service node, where the available resources include one or more of CPU resources, memory resources, and network bandwidth resources.
[0018] By adopting the above technical solution, a backup long connection service node can be selected based on the number of long connections of the long connection service node and / or the available resources of the long connection service node, so that the selected backup long connection service node has a lower load or has lower available resources, so as to push messages faster and improve the timeliness of message push.
[0019] In a possible implementation, the message push method also includes: when the operating status of the first target long connection service node is abnormal operation, storing the first duration of the message to be pushed, wherein the message recipient corresponding to the message to be pushed can maintain or disconnect the long connection with the first target long connection service node based on the heartbeat detection result with the first target long connection service node; when the long connection information associated with the message recipient corresponding to the message to be pushed is received within the first duration, based on the associated long connection information, determining the identification information of the second target long connection service node among multiple long connection service nodes for establishing a long connection with the message recipient corresponding to the message to be pushed, and pushing the message to be pushed to the second target long connection service node, so as to push the message to be pushed to the message recipient corresponding to the message to be pushed through the second target long connection service node; when the long connection information associated with the message recipient corresponding to the message to be pushed is not received within the first duration, discarding the message to be pushed.
[0020] By adopting the above technical solution, when the operating status of the first target long connection service node is abnormal operation, the first duration of the message to be pushed is stored. If the long connection information associated with the message recipient corresponding to the message to be pushed is received within the first duration, it indicates that the message recipient corresponding to the message to be pushed has established a long connection with other long connection service nodes (referred to as the second target long connection service node) in the long connection service cluster after disconnecting the long connection with the first target long connection service node, and then the message to be pushed can be pushed to the message recipient through the second target long connection service node, which can maximize the possibility of the message generated by the message producer being successfully pushed to the corresponding message recipient.
[0021] In a second aspect, an embodiment of the present application provides a message push device, which is used to communicate with a long connection service cluster, the long connection service cluster includes multiple long connection service nodes, each long connection service node is used to establish a long connection with one or more message recipients, and the message push device includes: an acquisition module, which is used to acquire the running status of each long connection service node, and receive the long connection information reported by each long connection service node, the long connection information includes the identification information of the long connection service node and the identification information of the message recipient that establishes a long connection with the long connection service node; a parsing module, which is used to parse the message to be pushed and obtain the identification information of the message recipient corresponding to the message to be pushed; a search module, which is used to search for the identification information of the first target long connection service node that establishes a long connection with the message recipient corresponding to the message to be pushed from multiple long connection service nodes according to the received long connection information and the identification information of the message recipient corresponding to the message to be pushed; a push module, which is used to push the message to be pushed to the first target long connection service node based on the identification information of the first target long connection service node when the running status of the first target long connection service node is normal, so as to push the message to be pushed to the message recipient corresponding to the message to be pushed through the first target long connection service node.
[0022] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory and a processor, wherein the memory is used to store computer-readable instructions; the processor is used to read the computer-readable instructions and implement the method provided by the first aspect and its optional implementation method.
[0023] In a fourth aspect, an embodiment of the present application provides a computer storage medium storing computer-readable instructions, and the computer-readable instructions, when executed by a processor, implement the method provided by the first aspect and its optional implementation.
[0024] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes computer-readable instructions. When the computer-readable instructions are executed by a processor, the method provided by the first aspect and its optional implementation method is implemented.
[0025] The technical effects obtained by the above-mentioned second, third, fourth and fifth aspects are similar to the technical effects obtained by the corresponding technical means in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0027] Figure 1 A schematic diagram of the architecture of a message push system provided in one embodiment of the present application;
[0028] Figure 2 A schematic diagram of the architecture of a message push system provided in another embodiment of the present application;
[0029] Figure 3 A flowchart of a message push method provided in one embodiment of the present application;
[0030] Figure 4 A schematic diagram of the architecture of a message push system provided in yet another embodiment of the present application;
[0031] Figure 5 A schematic diagram of the architecture of a message push system provided in yet another embodiment of the present application;
[0032] Figure 6 A flowchart of a message push method provided by another embodiment of the present application;
[0033] Figure 7 A flowchart of a message push method provided in another embodiment of the present application;
[0034] Figure 8 A schematic diagram of a possible application scenario of the message push method provided in one embodiment of the present application;
[0035] Fig. 9 A functional module diagram of a message push device provided in one embodiment of the present application;
[0036] Fig.10 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0037] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0038] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, words such as "exemplary", "or", "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "or", "for example" is intended to present related concepts in a concrete way.
[0039] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by technicians in the technical field of the present application. The terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. It should be understood that, unless otherwise specified in the present application, " / " means or. For example, A / B can represent A or B. "And / or" in the present application is only a kind of association relationship describing associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. "At least one" means one or more. "Multiple" means two or more than two. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, a, b and c seven situations. It should be understood that the order of the steps shown in the flowchart of this article can be changed, and some can also be omitted.
[0040] Message middleware: A supporting software system that provides synchronous or asynchronous, reliable message transmission for business systems in a network environment based on queue and message passing technology. It is mainly used to implement functions such as cross-system information transmission, high-concurrency traffic peak shaving, and asynchronous data processing. For example, when applied to distributed systems, message middleware can use efficient and reliable asynchronous information transmission mechanisms to integrate the remaining subsystems in the distributed system.
[0041] Message producer: produces messages and places them in the message queue.
[0042] Message consumer: consumes messages and reads messages from the message queue.
[0043] Persistent connection: A data path that can continuously send and receive messages after being established based on one or more protocols such as Transmission Control Protocol (TCP) / User Datagram Protocol (UDP) / Quick UDP Internet Connections (QUIC) / Client-Server Full-Duplex Communication Protocol (WebSocket).
[0044] In the related technology, the business system has the need to push messages to the client. For business systems with high concurrency, in order to ensure that messages can be pushed to the corresponding client in a timely manner, a long connection service cluster is generally deployed between the business system and the client to push messages. The long connection service cluster may include multiple long connection service nodes. As a message producer, the business system produces messages that need to be pushed to a certain client. For each client, each client can generally only establish a long connection with one of the long connection service nodes. For the long connection service node, each long connection service node can establish a long connection with multiple clients. The following is an example of each client can only establish a long connection with one of the long connection service nodes.
[0045] In order to accurately push messages to the corresponding clients, a feasible approach is: after the message is produced, each persistent connection service node, as a message consumer, consumes and parses the message to determine whether the client corresponding to the message has established a persistent connection with itself. If a persistent connection is established, the persistent connection service node pushes the message to the client through the persistent connection; otherwise, the persistent connection service node discards the message.
[0046] like Figure 1 As shown, it is a schematic diagram of the architecture of the message push system. The message push system may include multiple units such as a business system 11, a message middleware 12, a long connection service cluster 13, and a client 14. Units with communication needs can be configured to communicate through the network (directly, or through forwarding devices such as gateways. The network may include various connection types, such as wired communication links, wireless communication links, etc., which are not limited in the embodiments of the present application.
[0047] The business system 11 can be any software system with message push requirements, which is not limited in the embodiments of the present application. The business system 11 acts as a message producer to generate messages. The business system 11 can be deployed in a computing device, for example, a computer, a server, a server cluster, etc.
[0048] The message middleware 12 may be Kafka, RabbitMQ, RocketMQ, ActiveMQ, etc. The message middleware 12 may also be deployed in a computing device, for example, in a server or a server cluster.
[0049] The long connection service cluster 13 may include one or more long connection service nodes 131. The long connection service cluster 13 may also be deployed in a computing device, for example, in a server or a server cluster. Each long connection service node 131 may be an instance. The instance of the embodiment of the present application may be a virtual machine, a container, etc. Each instance may be corresponding to independent hardware resources and network resources. Hardware resources may refer to processor resources, memory resources, storage resources, etc.
[0050] In some embodiments, one or more of the business system 11 , the message middleware 12 , and the persistent connection service cluster 13 may be deployed in the same computing device, or respectively deployed in different computing devices.
[0051] The client 14 may refer to a device located at the user side or client software installed on a device at the user side. The number of the client 14 may be multiple. For example, the client 14 may be a smart phone, a desktop computer, a laptop computer, etc.
[0052] Figure 1 Taking the WebSocket persistent connection as an example, WebSocket persistent connection is a protocol for full-duplex communication on a single TCP connection. WebSocket persistent connection allows an instance deployed on a server (for example, the persistent connection service node 131 described above) to actively push messages to the client. A WebSocket persistent connection between each client 14 and the persistent connection service node 131 can be established in advance, and each persistent connection service node 131 can be configured to subscribe to messages of the message middleware 12.
[0053] For example, the long connection service cluster 13 includes a load balancer, through which the number of long connections of each long connection service node 131 is kept balanced. The load balancer can be selected according to actual needs, and the embodiment of the present application does not limit this. For example, the load balancer can be Nginx. The client 14 can establish a WebSocket long connection with a long connection service node 131 in the following manner: the client 14 sends a long connection establishment request to the long connection service cluster 13, and the load balancer in the long connection service cluster 13 can select a target long connection service node according to the number of long connections of each long connection service node 131, and forward the long connection establishment request to the target long connection service node. The target long connection service node then establishes a WebSocket long connection with the client 14 based on the long connection establishment request.
[0054] Among them, one client 14 can only establish a WebSocket persistent connection with one persistent connection service node 131, and one persistent connection service node 131 can establish a WebSocket persistent connection with multiple clients 14. Each persistent connection service node 131 can be pre-configured to subscribe to messages of the message middleware 12.
[0055] Each persistent connection service node 131 can subscribe to the messages of the message middleware 12 in the publish-subscribe mode. In this mode, the message producer (business system 11) produces messages and pushes the messages to the message middleware 12. When the message producer pushes the message to the message middleware 12, it can specify the topic to which the message belongs. The message middleware 12 divides and stores messages by topic. The messages are stored in the topic to which they belong. All message consumers (persistent connection service nodes 131) that subscribe to the topic can obtain the message for consumption.
[0056] In some embodiments, the business system 11 generally generates a message based on the trigger of the client 14 (for example, the user performs an operation on the client 14, triggering the business system 11 to generate a message to be pushed to the client 14), and the message is then pushed to the client 14. The message generated by the business system 11 can be added with the identification information of the client 14 (for example, a unique identity identifier), so that after the long connection service node 131 parses the message, it can determine to which client the message is pushed.
[0057] The process of implementing message push in the message push system may include:
[0058] a1 business system 11 generates a message, and pushes the message to the message middleware 12. For example, the business system 11 can actively push the message to the message middleware 12;
[0059] b1. Each persistent connection service node 131 obtains a message from the message middleware 12. For example, when each persistent connection service node 131 subscribes to the topic to which the message belongs, each persistent connection service node 131 may obtain the message from the message middleware 12 in an active manner;
[0060] c1. Each long connection service node 131 parses the acquired message to obtain the identification information of the client corresponding to the message;
[0061] d1. Each persistent connection service node 131 determines whether the client corresponding to the identification information has established a WebSocket persistent connection with itself based on the identification information of the client obtained by parsing. If it is determined that no WebSocket persistent connection is established with itself, the message is discarded. If it is determined that a WebSocket persistent connection is established with itself, the WebSocket persistent connection established with the client is searched based on the identification information of the client, and the message is pushed to the client based on the found WebSocket persistent connection.
[0062] Although the above message push system can realize the preparation and push of the message generated by the business system 11 to the corresponding client 14, due to the large number of persistent connection service nodes 131, each client 14 can only establish a WebSocket persistent connection with one persistent connection service node 131, and the message push system may have the following defects:
[0063] (1) During the message push process, it is impossible to determine with which persistent connection service node the client corresponding to the message establishes a WebSocket persistent connection. Therefore, each persistent connection service node needs to consume and parse the message, which greatly wastes the resources of the persistent connection service node.
[0064] (2) When an exception occurs in message push, it is difficult to troubleshoot the exception because it is impossible to determine which persistent connection service node the client corresponding to the message established a WebSocket persistent connection with. This makes it impossible to quickly determine the cause of the exception. For example, it is impossible to quickly determine whether it is caused by a node exception or other exceptions.
[0065] (3) It is difficult to monitor the number of WebSocket persistent connections in the persistent connection service cluster. It is necessary to obtain the number of WebSocket persistent connections of each persistent connection service node in real time and then add them up.
[0066] (4) If a persistent connection service node consumes messages slowly, it may affect the message push on the persistent connection service node, resulting in the failure to push messages to the client in time. For example, a message producer generates a first message and a second message, the first message corresponds to a first client, the second message corresponds to a second client, the first client has established a persistent connection with the first persistent connection service node, and the second client has established a persistent connection with the second persistent connection service node. If the second persistent connection service node consumes the first message first and then the second message, when the time for the second persistent connection service node to consume the first message is too long, the second persistent connection service node will consume the second message only after a long time, thereby resulting in the failure to push the second message to the second client in time.
[0067] In order to solve at least one technical problem existing in the above-mentioned message push system, the embodiment of the present application also provides a message push system and method, which can accurately push the message to be pushed to the long connection service node that has established a WebSocket long connection with the client corresponding to the message, thereby quickly pushing the message to the client.
[0068] like Figure 2 , which is a schematic diagram of the architecture of a message push system provided in one embodiment of the present application.
[0069] and Figure 1 In comparison, the message push system includes not only the business system 11, the message middleware 12, the long connection service cluster 13, and the client 14, but also a message push device 15. Among them, the message push device 15 can be deployed between the message middleware 12 and the long connection service cluster 13, and is used to consume messages from the message middleware 12, and push the consumed messages to the long connection service node with which the client corresponding to the message has established a WebSocket long connection, so that each long connection service node does not need to consume every message generated by the business system 11, but only receives and forwards the messages of the client with which the long connection is established, so as to realize the point-to-point accurate push of the messages generated by the business system 11 to the corresponding long connection service node.
[0070] For example, the message push apparatus 15 may be deployed in a computing device, and the computing device deployed with the message push apparatus 15 may communicate with a computing device deployed with the message middleware 12 and a computing device deployed with the long connection service cluster 13 .
[0071] In some embodiments, one or more of the business system 11 , the message middleware 12 , the persistent connection service cluster 13 , and the message push device 15 may be deployed in the same computing device, or respectively deployed in different computing devices.
[0072] In some embodiments, a WebSocket persistent connection between each client 14 and the persistent connection service node 131 can be pre-established, and the message push device 15 can be configured to subscribe to the message of the message middleware 12 (each persistent connection service node 131 does not need to subscribe to the message of the message middleware 12). The message push device 15 can subscribe to the message of the message middleware 12 in a point-to-point mode or a publish-subscribe mode.
[0073] In some embodiments, each persistent connection service node 131 may also report persistent connection information to the message push device 15 after establishing a WebSocket persistent connection with a certain client 14. The persistent connection information may include identification information of the persistent connection service node and identification information of the client, and the identification information may be a unique identity of the client / persistent connection service node, for example, the identification information may be an Internet Protocol (IP) address, a Media Access Control (MAC) address, etc. The message push device 15 may maintain the received persistent connection information, for example, construct a persistent connection information list to summarize the received persistent connection information.
[0074] In some embodiments, each persistent connection service node 131 may also report persistent connection disconnection information to the message push device 15 after disconnecting the WebSocket persistent connection with a certain client 14. The persistent connection disconnection information is used to indicate that the persistent connection service node 131 has disconnected the WebSocket persistent connection with a client, so that the message push device 15 updates the persistent connection information list based on the persistent connection disconnection information. For example, the message push device 15 deletes the corresponding persistent connection information in the persistent connection information list based on the persistent connection disconnection information, or adds a mark to the persistent connection information in the persistent connection information list. The persistent connection disconnection information may include a unique identity of the persistent connection service node and / or the client.
[0075] In some embodiments, the process of implementing message push in the message push system may include:
[0076] a2 business system 11 generates a message and pushes the message to the message middleware 12;
[0077] b2 message push device 15 gets the message from the message middleware 12, for example, in the case where the message push device 15 subscribes to the subject to which the message belongs, the message push device 15 can actively obtain the message from the message middleware 12;
[0078] c2 message push device 15 parses the acquired message to obtain the identification information of the client corresponding to the message;
[0079] d 2. The message push device 15 searches the persistent connection information list based on the identification information of the client obtained by parsing, and obtains the persistent connection service node information corresponding to the message, where the persistent connection service node information indicates the persistent connection service node with which the client corresponding to the identification information has established a WebSocket persistent connection, for example, the persistent connection service node information is the identification information of the persistent connection service node;
[0080] In some embodiments, if the message push device 15 searches for the long connection information list based on the identification information of the client obtained by parsing, and fails to find the corresponding long connection service node information, it indicates that the client corresponding to the identification information has not established a WebSocket long connection with any long connection service node, and the message push may not be completed. The message push device 15 can directly discard the message, or search the long connection information list again after a preset time period (or repeat the search for the long connection information list every preset time period for a preset number of times). If the corresponding long connection service node information is not found, the message is discarded.
[0081] e2 message push means 15 based on the long connection service node information, the message is pushed to the corresponding long connection service node 131, for example, the message push means 15 can be based on the long connection service node 131 provides a message push port and IP address, push the message;
[0082] f2. The persistent connection service node 131 parses the received message, obtains the identification information of the client corresponding to the message, searches for the WebSocket persistent connection established with the client based on the identification information of the client, and pushes the message to the client based on the found WebSocket persistent connection.
[0083] The message push system that adopts the above-mentioned push method can make each long connection service node not need to consume every message generated by the message producer. Each long connection service node only needs to process the messages pushed by the message push device, that is, it only needs to consume the messages of the client with which a long connection has been established, thereby realizing point-to-point precise message push, reducing the consumption of resources (CPU resources, memory resources, etc.), and based on the long connection information, it can quickly locate on which node the client's long connection is established, which is convenient for troubleshooting when an abnormality occurs in the message push.
[0084] In some embodiments, the message middleware 12 may also be omitted, and the message push device 15 is responsible for receiving messages generated by the business system 11, storing the messages, parsing the stored messages, and pushing them to the corresponding long connection service nodes.
[0085] In some embodiments, the message push device 15 may also be integrated into the message middleware 12, or integrated into the persistent connection service cluster 13. For example, a certain node in the persistent connection service cluster 13 is used as the message push device 15 to implement the function of the message push device 15. In some embodiments, in order to monitor the running status of each persistent connection service node 131 and facilitate the use of different push strategies for message push based on the node status, each persistent connection service node 131 may also be configured to report its own identification information to the message push device 15 after startup. The message push device 15 may maintain the identification information of the received persistent connection service nodes, for example, construct a node information list to summarize the identification information of the received persistent connection service nodes.
[0086] The message push device 15 can also perform heartbeat detection with the long connection service node 131 at every preset time to determine whether the long connection service node 131 is abnormal. The message push device 15 can also delete the identification information of the abnormal long connection service node from the node information list, or add a mark to the identification information in the node information list. For example, the message push device 15 can send a heartbeat packet to the long connection service node 131 at every preset time. If the response of the other party is not received within a specific duration, the message push device 15 can determine that the long connection service node 131 is abnormal (for example, offline, downtime, etc.). The preset time and the specific duration can be set according to actual needs, and the embodiment of the present application is not limited to this. For example, the preset time is 5s and the specific duration is 15s.
[0087] In some embodiments, the persistent connection service node 131 after startup may also be configured to perform heartbeat detection with the message push device 15 at preset intervals. For example, the persistent connection service node 131 after startup may be configured to send a heartbeat packet to the message push device 15 at preset intervals. If the message push device 15 does not receive a heartbeat packet sent by a persistent connection service node 131 within a specific duration, the message push device 15 may determine that the persistent connection service node 131 is operating abnormally (e.g., offline, downtime, etc.). In this case, the specific duration is greater than the preset time, for example, the preset time is 5s, and the specific duration is 15s.
[0088] In some embodiments, the process of implementing message push in the message push system may also include:
[0089] a3 business system 11 generates a message and pushes the message to the message middleware 12;
[0090] b3 message push device 15 gets the message from the message middleware 12;
[0091] c3 message push device 15 parses the acquired message to obtain the identification information of the client corresponding to the message;
[0092] d 3. The message push device 15 searches the persistent connection information list based on the identification information of the client obtained through analysis, and obtains the persistent connection service node information corresponding to the message;
[0093] In some embodiments, if the message push device 15 searches for the long connection information list based on the identification information of the client obtained by parsing, and fails to find the corresponding long connection service node information, it indicates that the client corresponding to the identification information has not established a WebSocket long connection with any long connection service node, and the message push may not be completed. The message push device 15 can directly discard the message, or search the long connection information list again after the first preset time (or repeat the search for the long connection information list every first preset time for a preset number of times), and if the corresponding long connection service node information is still not found, the message is discarded. The first preset time can be set according to actual needs, and the embodiments of the present application are not limited to this.
[0094] e3 message push device 15 based on the long connection service node information to find the node information list, determine the long connection service node information corresponding to the long connection service node 131 is running abnormally;
[0095] In some embodiments, if the long connection service node information exists in the node information list, it indicates that the long connection service node 131 corresponding to the long connection service node information is operating normally and the message push can be completed normally. If the long connection service node information does not exist in the node information list, it indicates that the long connection service node 131 corresponding to the long connection service node information is operating abnormally and may not be able to complete the message push.
[0096] f3 If the message push device 15 determines that the long connection service node information corresponding to the long connection service node 131 is abnormal, the message is discarded;
[0097] In some embodiments, if it is determined that the long connection service node 131 corresponding to the long connection service node information is operating abnormally, indicating that the message push may not be completed, the message push device 15 can directly discard the message, or search the node information list again after a second preset time (or repeat the preset number of times to search the node information list every second preset time), and if the long connection service node information is still not found in the node information list, the message is discarded. The second preset time can be set according to actual needs, and the embodiment of the present application is not limited to this.
[0098] g3. If the message push device 15 determines that the long connection service node information corresponding to the long connection service node 131 is operating normally, the message is pushed to the corresponding long connection service node 131 based on the long connection service node information;
[0099] h3. The persistent connection service node 131 parses the received message, obtains the identification information of the client corresponding to the message, searches for the WebSocket persistent connection established with the client based on the identification information of the client, and pushes the message to the client based on the found WebSocket persistent connection.
[0100] The message push system that adopts the above-mentioned push method can make each long connection service node not need to consume every message generated by the message producer. Each long connection service node only needs to process the messages pushed by the message push device, that is, it only needs to consume the messages of the client with which a long connection has been established, thereby realizing point-to-point precise message push, reducing resource consumption, and enabling visual monitoring of message push. For example, the operating status of the nodes in the system can be known in real time, and the number of valid long connections can be determined based on the nodes that are operating normally. In addition, based on the long connection information, it can quickly locate on which node the client's long connection is established, which is convenient for troubleshooting when an abnormality occurs in the message push.
[0101] Figure 3 A message push method is provided in an embodiment of the present application. The message push method can be applied to Figure 2 The message push device 15 shown is used to communicate with the long connection service cluster 13. The long connection service cluster 13 may include multiple long connection service nodes 131. Each long connection service node 131 is used to establish a long connection with one or more message receivers. The long connection referred to in the embodiment of the present application may be a WebSocket long connection, or a long connection of other protocols. The message receiver is the final recipient of the message generated by the business system 11. The message receiver may also be referred to as a client. The following description will take the message receiver as a client as an example. Figure 3 As shown, the message push method may include:
[0102] S31 , the message pushing device 15 obtains the running status of each persistent connection service node 131 , and receives persistent connection information reported by each persistent connection service node 131 .
[0103] The message push device 15 can obtain the operation status of each long connection service node 131 through heartbeat detection or other detection methods. For example, the message push device 15 can send a heartbeat packet to the long connection service node 131 at a preset time. If no response is received from the other party within a specific time, the message push device 15 can determine that the long connection service node 131 is operating abnormally. For another example, after the configuration is started, the long connection service node 131 sends a heartbeat packet to the message push device 15 at a preset time. If the message push device 15 does not receive a heartbeat packet sent by a long connection service node 131 within a specific time, the message push device 15 can determine that the long connection service node 131 is operating abnormally.
[0104] In some embodiments, the persistent connection service node 131 after startup may also be configured to report its own identification information to the message push device 15. The message push device 15 may aggregate and store the reported identification information of the persistent connection service node 131 to accurately know the number and identity of the currently started persistent connection service node 131.
[0105] In some embodiments, the message push device 15 can also maintain the identification information of the stored persistent connection service node 131 based on the running status of each persistent connection service node, so as to accurately know the number and identity of the persistent connection service node 131 in the current running state. For example, when the heartbeat detection result of a persistent connection service node is abnormal, the message push device 15 can delete the stored identification information of the persistent connection service node, or add a preset mark to the stored identification information of the persistent connection service node, and then determine the currently running normally persistent connection service node based on the stored identification information of the persistent connection service node.
[0106] In some embodiments, each persistent connection service node 131 may be pre-configured to report persistent connection information to the message push device 15 after establishing a WebSocket persistent connection with a certain client, and the message push device 15 may receive the persistent connection information reported by each persistent connection service node. The persistent connection information may include identification information of the persistent connection service node and identification information of the client that establishes a persistent connection with the persistent connection service node. For example, the format of the persistent connection information is (identification information of the persistent connection service node, identification information of the client).
[0107] Any persistent connection service node 131 , after establishing a persistent connection with a client, can report persistent connection information including its own identification information and the identification information of the client to the message push device 15 .
[0108] In some embodiments, after receiving the long connection information reported by the long connection service node 131, the message push device 15 may also store the received long connection information and maintain the stored long connection information, so as to accurately know the number of currently valid long connections and quickly locate the long connection service node on which the long connection of the client 14 is established. For example, each long connection service node 131 may be configured to report the long connection disconnection information to the message push device 15 when the long connection with a certain client is disconnected. The long connection disconnection information is used to indicate that the long connection service node has disconnected the long connection with a client. The message push device 15 may update the stored long connection information based on the long connection disconnection information. For example, the stored long connection information between the long connection service node and the client may be deleted based on the long connection disconnection information, or a preset mark may be added to the stored long connection information between the long connection service node and the client.
[0109] For another example, the message push device 15 may also update the stored persistent connection information based on the identification information of the abnormal persistent connection service node. For example, based on the identification information of the abnormal persistent connection service node, all stored persistent connection information including the identification information of the persistent connection service node is deleted.
[0110] S32, the message pushing device 15 parses the message to be pushed, and obtains the identification information of the client 14 corresponding to the message to be pushed.
[0111] In some embodiments, the message to be pushed may be obtained by the message pushing device 15 from the message middleware 12. If the message middleware 12 is omitted, the message to be pushed may also be a message directly received by the message pushing device 15 from the business system 11.
[0112] In some embodiments, the business system 11 generally generates a message based on the trigger of the client 14 (for example, the user performs a certain operation on the client 14, triggering the business system 11 to generate a message to be pushed to the client 14), and the message is then pushed to the client 14. The message generated by the business system 11 can be added with the identification information of the client 14 (for example, a unique identity). After obtaining the message to be pushed, the message pushing device 15 can parse the message to be pushed, and then obtain the identification information of the client corresponding to the message to be pushed, that is, based on the identification information of the client obtained by parsing, it can determine to which client the message to be pushed is pushed.
[0113] S33, the message pushing device 15 searches for the identification information of the first target persistent connection service node for establishing a persistent connection with the client 14 corresponding to the message to be pushed from multiple persistent connection service nodes 131 according to the received persistent connection information and the identification information of the client 14 corresponding to the message to be pushed.
[0114] In some embodiments, the first target persistent connection service node may refer to a persistent connection service node 131 with which a persistent connection is established with a client corresponding to the message to be pushed among the plurality of persistent connection service nodes 131 .
[0115] After parsing and obtaining the identification information of the client corresponding to the message to be pushed, the message push device 15 can compare the identification information of the client corresponding to the message to be pushed with the long connection information previously received, and then find the identification information of the first target long connection service node that establishes a long connection with the client corresponding to the message to be pushed. For example, the message push device 15 maintains the received long connection information by constructing a long connection information list. After parsing and obtaining the identification information of the client corresponding to the message to be pushed, the message push device 15 can search the long connection information list based on the identification information of the client corresponding to the message to be pushed, and determine whether there is a long connection information corresponding to the identification information of the client corresponding to the message to be pushed in the long connection information list. If there is a long connection information corresponding to the identification information of the client corresponding to the message to be pushed in the long connection information list, the identification information of the long connection service node recorded in the long connection information is the identification information of the first target long connection service node.
[0116] In some embodiments, if the message push device 15 searches the long connection information list and determines that there is no long connection information corresponding to the identification information of the client corresponding to the message to be pushed, the message push device 15 can directly discard the message, or search the long connection information list again after a preset time period (or repeat the search for the long connection information list every preset time period for a preset number of times), and then determine whether to discard the message.
[0117] S34, when the operating status of the first target long connection service node is normal, the message pushing device 15 pushes the message to be pushed to the first target long connection service node based on the identification information of the first target long connection service node, so as to push the message to be pushed to the client 14 corresponding to the message to be pushed through the first target long connection service node.
[0118] In some embodiments, when the operating status of the first target persistent connection service node is normal, indicating that the message to be pushed can be pushed to the corresponding client in a timely manner through the first target persistent connection service node, the message pushing device 15 can push the message to be pushed to the first target persistent connection service node based on the identification information of the first target persistent connection service node, so as to push the message to be pushed to the client 14 corresponding to the message through the first target persistent connection service node.
[0119] S35: When the operation status of the first target persistent connection service node is abnormal, the message pushing device 15 discards the message to be pushed.
[0120] In some embodiments, based on the immediacy of message push, when the operating status of the first target persistent connection service node is abnormal, indicating that the message cannot be pushed to the corresponding client 14 in time, the message push device 15 can directly discard the message to be pushed.
[0121] In some embodiments, the message push device 15 can also use a backup mechanism to try to push messages to the corresponding client when the operating status of the first target long connection service node is abnormal, so as to maximize the success of pushing messages generated by the message producer to the corresponding client.
[0122] For example, when the operation state of the first target persistent connection service node is abnormal operation, the message push device 15 can select a standby persistent connection service node from the remaining persistent connection service nodes except the first target persistent connection service node based on a preset rule, and the message push device 15 sends the identification information of the standby persistent connection service node to the persistent connection service cluster 13 to trigger the standby persistent connection service node to establish a persistent connection with the client 14 corresponding to the message. When the message push device 15 receives the persistent connection information of the client 14 corresponding to the message reported by the standby persistent connection service node, the message push device 15 pushes the message to the standby persistent connection service node, so as to push the message to the client 14 corresponding to the message through the standby persistent connection service node.
[0123] Since the client 14 can only establish a persistent connection with one of the persistent connection service nodes 131, the client 14 can be configured to perform a heartbeat detection with the persistent connection service node 131 after establishing a persistent connection with the persistent connection service node 131, that is, the client 14 can maintain or disconnect the persistent connection with the first target persistent connection service node based on the heartbeat detection result with the first target persistent connection service node. In the case where the first target persistent connection service node is operating abnormally, the client 14 can disconnect the persistent connection with the first target persistent connection service node because it cannot receive the heartbeat response of the other party. The client 14 can send a persistent connection establishment request to the persistent connection service cluster 13 again, and the persistent connection service cluster 13 can assign the persistent connection establishment request to the standby persistent connection service node based on the identification information of the standby persistent connection service node sent by the message push device 15, so that the standby persistent connection service node establishes a persistent connection with the client 14 corresponding to the message. The standby persistent connection service node can report the long connection information of the persistent connection established with the client 14 corresponding to the message to be pushed to the message push device 15, and then the message push device 15 can push the message to the standby persistent connection service node.
[0124] In some embodiments, the preset rules include: selecting a backup persistent connection service node based on the number of persistent connections of the persistent connection service node, and / or based on the available resources of the persistent connection service node, and the available resources may include one or more of CPU resources, memory resources, and network bandwidth resources.
[0125] In some embodiments, the preset rule may also be to select a standby long connection service node based on the number of long connections and available resources of the long connection service node 131. For example, when the number of long connections is the same, a long connection service node with more available resources is selected as the standby long connection service node, or corresponding scoring rules are set based on the number of long connections and available resources, and the number of long connections and available resources may also correspond to a scoring ratio coefficient (the sum of the coefficients is equal to 1), and the candidate long connection service node 131 is scored to select the standby long connection service node.
[0126] For example, the message management system 151 selects the persistent connection service node 131 with the least persistent connections from all persistent connection service nodes 131 as a standby persistent connection service node, or selects the persistent connection service node 131 with the largest currently available resources as a standby persistent connection service node.
[0127] In some embodiments, when the operation state of the first target persistent connection service node is abnormal operation, the message push device 15 may also store the first duration of the message to be pushed. Within the first duration, if the message push device 15 receives persistent connection information associated with the client 14 corresponding to the message to be pushed, the identification information of the second target persistent connection service node that establishes a persistent connection with the client 14 of the message to be pushed is determined based on the associated persistent connection information, and the message is pushed to the second target persistent connection service node, so as to push the message to the client 14 corresponding to the message to be pushed through the second target persistent connection service node. The first duration can be set according to actual needs, and the embodiment of the present application does not limit this.
[0128] For example, when the first target persistent connection service node is operating abnormally, the client 14 can disconnect the persistent connection with the first target persistent connection service node because it cannot receive the heartbeat response from the other party. The client 14 can send a persistent connection establishment request to the persistent connection service cluster 13 again. The persistent connection service cluster 13 (for example, the load balancer in the persistent connection service cluster 13 is responsible for the allocation of persistent connection establishment requests) can allocate the persistent connection establishment request to a persistent connection service node (which can be called the second target persistent connection service node), and then the client 14 corresponding to the message to be pushed can establish a persistent connection with the second target persistent connection service node again after disconnecting the persistent connection with the first target persistent connection service node. The second target persistent connection service node can report the persistent connection information of the persistent connection established with the client 14 corresponding to the message to be pushed to the message push device 15, and then the message push device 15 can push the message to the second target persistent connection service node.
[0129] The above-mentioned message push method can make each long connection service node not need to consume every message generated by the message producer. Each long connection service node only needs to process the messages pushed by the message push device, that is, it only needs to consume the messages of the client with which a long connection is established, thereby realizing point-to-point precise message push, reducing the consumption of node resources, and being able to perform visual monitoring of message push. For example, the operating status of the nodes in the system can be known in real time, and the number of valid long connections can be determined based on the nodes that are operating normally, and the specific node on which the client's long connection is established can be quickly located based on the reported long connection information, so as to facilitate the troubleshooting of abnormal problems when message push occurs abnormally. In addition, in the event of an abnormal operation of the long connection service node, a backup mechanism can be used to try to push messages to the corresponding client, so as to maximize the possibility of the message generated by the message producer being successfully pushed to the corresponding client.
[0130] In some embodiments, Figure 4 As shown, the message push device 15 may include a message management system 151 and a node management system 152. The message management system 151 and the node management system 152 may be decoupled from each other, which facilitates maintenance and expansion of the message management system 151 and the node management system 152 respectively, thereby reducing system complexity.
[0131] For example, each long connection service node 131 can report the long connection information to the message management system 151 after establishing a WebSocket long connection with a certain client 14. The message management system 151 can record the long connection information between each long connection service node and the client by constructing a long connection information list. After each long connection service node 131 is started, it can also report its own identification information to the node management system 152. The node management system 152 is used to obtain the operating status of each long connection service node 131. For example, the node management system 152 can perform heartbeat detection with the long connection service node 131 at preset intervals to obtain the operating status of each long connection service node 131. For another example, the node management system 152 can also record the identification information of the long connection service node that is operating normally by constructing a node information list.
[0132] In some embodiments, the deployment locations of the message management system 151 and the node management system 152 can be set according to actual needs, and the embodiments of the present application do not limit this. For example, the message management system 151 and the node management system 152 can both be deployed in the long connection service cluster 13, or the message management system 151 is deployed in the message middleware 12, and the node management system 152 is deployed in the long connection service cluster 13.
[0133] exist Figure 4 In the message push system shown, the process of implementing message push may include:
[0134] a4 business system 11 generates a message and pushes the message to the message middleware 12;
[0135] b4 message management system 151 obtains messages from the message middleware 12;
[0136] c4 message management system 151 parses the acquired message to obtain the identification information of the client corresponding to the message;
[0137] d 4. The message management system 151 searches the persistent connection information list based on the identification information of the client obtained through the analysis, and obtains the persistent connection service node information corresponding to the message;
[0138] In some embodiments, if the message management system 151 searches for the long connection information list based on the parsed identification information of the client and fails to find the corresponding long connection service node information, it indicates that the client corresponding to the identification information has not established a WebSocket long connection with any long connection service node and the message push may not be completed. The message management system 151 can directly discard the message.
[0139] e4. The message management system 151 sends a search request to the node management system 152 to determine whether the long connection service node corresponding to the long connection service node information is running normally;
[0140] f4 node management system 152 responds to the search request, finds the node information list, determines whether the long connection service node information corresponding to the long connection service node 131 is operating abnormally, and sends the search results to the message management system 151;
[0141] g4. If the search result is that the long connection service node information corresponding to the long connection service node 131 is operating abnormally, the message management system 151 discards the message;
[0142] h4. If the search result shows that the long connection service node 131 corresponding to the long connection service node information is running normally, the message management system 151 pushes the message to the corresponding long connection service node 131 based on the long connection service node information;
[0143] i4. The persistent connection service node 131 parses the received message, obtains the identification information of the client corresponding to the message, searches for the WebSocket persistent connection established with the client based on the identification information of the client, and pushes the message to the client based on the found WebSocket persistent connection.
[0144] In some embodiments, Figure 4 The message middleware 12 shown may also be omitted, for example, Figure 5 As shown, the message management system 151 can be configured to receive messages generated by the business system 11, store messages, parse the stored messages, and push them to the corresponding persistent connection service nodes. In this case, the message management system 151 can be deployed outside the persistent connection service cluster 13, or deployed in the persistent connection service cluster 13. The node management system 152 can also be deployed in the persistent connection service cluster 13, or deployed outside the persistent connection service cluster 13.
[0145] exist Figure 5 In the message push system shown, the process of implementing message push may include:
[0146] a5 business system 11 generates a message and pushes the message to the message management system 151;
[0147] b5 message management system 151 stores the message, and parses the message to obtain the identification information of the client corresponding to the message;
[0148] c 5. The message management system 151 searches the persistent connection information list based on the identification information of the client obtained through the analysis, and obtains the persistent connection service node information corresponding to the message;
[0149] d5. The message management system 151 sends a search request to the node management system 152 to determine whether the long connection service node 131 corresponding to the long connection service node information is operating normally;
[0150] e5. The node management system 152 responds to the search request, searches the node information list, determines whether the long connection service node information corresponding to the long connection service node 131 is operating abnormally, and sends the search results to the message management system 151;
[0151] f5. If the search result is that the long connection service node information corresponding to the long connection service node 131 is operating abnormally, the message management system 151 discards the message;
[0152] g5. If the search result is that the long connection service node information corresponding to the long connection service node 131 is running normally, the message management system 151 pushes the message to the corresponding long connection service node 131 based on the long connection service node information;
[0153] h5. The persistent connection service node 131 parses the received message, obtains the identification information of the client corresponding to the message, searches for the WebSocket persistent connection established with the client based on the identification information of the client, and pushes the message to the client based on the found WebSocket persistent connection.
[0154] like Figure 6 As shown, a message push method provided by another embodiment of the present application is shown. The message push method can be applied to Figure 4 or Figure 5 The message push device 15 shown. The message push method may include:
[0155] S61 : The node management system 152 obtains the operating status of each persistent connection service node 131 .
[0156] In some embodiments, the node management system 152 can obtain the operating status of each persistent connection service node 131 through heartbeat detection or other detection methods. For example, the node management system 152 can send a heartbeat packet to the persistent connection service node 131 at preset intervals. If no response is received from the other party within a specific time period, the node management system 152 can determine that the persistent connection service node 131 is operating abnormally. For another example, after the persistent connection service node 131 is configured to start, it sends a heartbeat packet to the node management system 152 at preset intervals. If the node management system 152 does not receive a heartbeat packet sent by a persistent connection service node 131 within a specific time period, the node management system 152 can determine that the persistent connection service node 131 is operating abnormally.
[0157] In some embodiments, the persistent connection service node 131 after startup can also be configured to automatically report its own identification information to the node management system 152. The node management system 152 can summarize and store the reported identification information of the persistent connection service node 131 to accurately know the number and identity of the currently started persistent connection service node 131.
[0158] In some embodiments, the node management system 152 may also maintain the identification information of the stored persistent connection service node 131 based on the running status of each persistent connection service node, so as to accurately know the number and identity of the persistent connection service node 131 in the current running status. For example, when the heartbeat detection result of a persistent connection service node is abnormal, the node management system 152 may delete the stored identification information of the persistent connection service node, or add a preset mark to the stored identification information of the persistent connection service node, and then determine the currently running normally persistent connection service node based on the stored identification information of the persistent connection service node.
[0159] S62 : The message management system 151 receives the persistent connection information reported by each persistent connection service node 131 .
[0160] In some embodiments, each persistent connection service node 131 may be pre-configured to report persistent connection information to the message management system 151 after establishing a WebSocket persistent connection with a client, and the message management system 151 may receive the persistent connection information reported by each persistent connection service node.
[0161] In some embodiments, after receiving the long connection information reported by the long connection service node 131, the message management system 151 may also store the received long connection information and maintain the stored long connection information, so as to accurately know the number of currently valid long connections and quickly locate the long connection service node on which the long connection of the client 14 is specifically established. For example, each long connection service node 131 may be configured to report long connection disconnection information to the message management system 151 when the long connection with a certain client is disconnected. The long connection disconnection information is used to indicate that the long connection service node has disconnected the long connection with a client, and the message management system 151 may update the stored long connection information based on the long connection disconnection information. For example, based on the long connection disconnection information, the stored long connection information between the long connection service node and the client may be deleted, or a preset mark may be added to the stored long connection information between the long connection service node and the client.
[0162] For another example, the node management system 152 may also send the identification information of the abnormally operating persistent connection service node to the message management system 151, and the message management system 151 may also update the stored persistent connection information based on the identification information of the abnormally operating persistent connection service node. For example, based on the identification information of the abnormally operating persistent connection service node, all stored persistent connection information containing the identification information of the persistent connection service node may be deleted.
[0163] In some embodiments, step S61 and step S62 may be performed in parallel, or step S61 may be performed before or after step S62.
[0164] S63, the message management system 151 parses the message to be pushed, and obtains the identification information of the client 14 corresponding to the message to be pushed.
[0165] In some embodiments, for Figure 4 In the message push system shown in FIG. 1 , the message to be pushed can be obtained from the message middleware 12 by the message management system 151. Figure 5 In the message push system shown, the message to be pushed may be a message directly received by the message push device 15 from the business system 11. After acquiring the message to be pushed, the message management system 151 may parse the message to be pushed, and then obtain the identification information of the client corresponding to the message to be pushed.
[0166] S64, the message management system 151 searches for the identification information of the first target persistent connection service node for establishing a persistent connection with the client 14 corresponding to the message to be pushed from multiple persistent connection service nodes 131 according to the received persistent connection information and the identification information of the client 14 corresponding to the message to be pushed.
[0167] In some embodiments, the first target persistent connection service node may refer to a persistent connection service node 131 with which a persistent connection is established with the client corresponding to the message to be pushed among the plurality of persistent connection service nodes 131. After parsing and obtaining the identification information of the client corresponding to the message, the message management system 151 may compare the identification information of the client corresponding to the message to be pushed with the previously received persistent connection information, and then find the identification information of the first target persistent connection service node with which a persistent connection is established with the client corresponding to the message to be pushed. For example, the message management system 151 maintains the received persistent connection information by constructing a persistent connection information list. After parsing and obtaining the identification information of the client corresponding to the message, the message management system 151 may search the persistent connection information list based on the identification information of the client corresponding to the message to be pushed, and determine whether there is a persistent connection information corresponding to the identification information of the client corresponding to the message to be pushed in the persistent connection information list. If there is a persistent connection information corresponding to the identification information of the client corresponding to the message to be pushed in the persistent connection information list, the identification information of the persistent connection service node recorded in the persistent connection information is the identification information of the first target persistent connection service node.
[0168] In some embodiments, if the message management system 151 searches the long connection information list and determines that there is no long connection information corresponding to the identification information of the client corresponding to the message to be pushed, the message management system 151 can directly discard the message, or search the long connection information list again after a preset time period (or repeat the search for the long connection information list every preset time period for a preset number of times), and then determine whether to discard the message.
[0169] S65, when the operating status of the first target persistent connection service node is normal, the message management system 151 pushes the message to be pushed to the first target persistent connection service node based on the identification information of the first target persistent connection service node, so as to push the message to be pushed to the client 14 corresponding to the message to be pushed through the first target persistent connection service node.
[0170] In some embodiments, before pushing the message to the first target persistent connection service node, the message management system 151 may communicate with the node management system 152 to obtain the operating status of the first target persistent connection service node. When the message management system 151 determines that the operating status of the first target persistent connection service node is normal, the message management system 151 pushes the message to the first target persistent connection service node based on the identification information of the first target persistent connection service node.
[0171] S66: When the operation status of the first target persistent connection service node is abnormal, the message management system 151 discards the message to be pushed.
[0172] In some embodiments, based on the immediacy of message push, when the message management system 151 determines that the operation status of the first target persistent connection service node is abnormal, the message management system 151 may directly discard the message to be pushed.
[0173] In some embodiments, the message management system 151 can also use a backup mechanism to attempt to push messages to the corresponding client when the operating status of the first target long connection service node is abnormal, so as to maximize the success of pushing messages generated by the message producer to the corresponding client. The specific implementation method can refer to the description of the aforementioned embodiment and will not be repeated here.
[0174] The above-mentioned message push method can make each long connection service node not need to consume every message generated by the message producer. Each long connection service node only needs to process the messages pushed by the message push device, that is, it only needs to consume the messages of the client with which a long connection is established, thereby realizing point-to-point precise message push, reducing the consumption of node resources, and visually monitoring the message push. For example, the operating status of the nodes in the system can be known in real time, and the number of valid long connections can be determined based on the nodes that are running normally, and the specific node on which the client's long connection is established can be quickly located based on the reported long connection information, so as to facilitate the troubleshooting of abnormal problems when abnormalities occur in message push, and the message push device is divided into two parts: a message management system and a node management system. The message management system and the node management system can be decoupled from each other, so as to facilitate the deployment, maintenance and expansion of the message management system and the node management system respectively, thereby reducing the deployment complexity of the message push device.
[0175] In some embodiments, during the operation of the business system 11, as the time nodes change, there may be business peaks and business troughs. Since the number of long connections that can be established by each long connection service node 131 is limited, that is, a long connection service node 131 can establish long connections with a preset number of clients at most. During the peak business period, in order to avoid congestion in message push, more long connection service nodes 131 are needed to meet the message push demand, that is, the long connection service cluster 13 needs to be expanded to meet the message push demand during the peak business period. During the business trough, a smaller number of long connection service nodes 131 can meet the message push demand. In order to avoid the waste of node resources, the long connection service cluster 13 needs to be reduced in capacity to maximize the use of node resources while meeting the message push demand during the business trough.
[0176] like Figure 7As shown, the embodiment of the present application also provides a message push method, which can dynamically expand and shrink the long connection service cluster 13 while realizing point-to-point accurate message push, so as to cope with the business peak and business trough of the business system. The message push method can be applied to Figure 4 or Figure 5 The message push device 15 shown. The message push method may include:
[0177] S71 : The node management system 152 obtains the operating status of each persistent connection service node 131 .
[0178] Step S71 of the embodiment of the present application is similar to step S61 of the aforementioned embodiment, and will not be described again here to avoid repetition.
[0179] S72 , the message management system 151 receives the persistent connection information reported by each persistent connection service node 131 .
[0180] Step S72 of the embodiment of the present application is similar to step S62 of the aforementioned embodiment, and will not be described again here to avoid repetition.
[0181] S73 , the message management system 151 determines the service concurrency coefficient of the persistent connection service cluster 13 based on the persistent connection information reported by each persistent connection service node 131 .
[0182] In some embodiments, the business concurrency coefficient may be used to indicate the overall size of the number of long connections of the long connection service node 131 in the long connection service cluster 13. A larger business concurrency coefficient indicates that the number of long connections of the long connection service node 131 in the long connection service cluster 13 is larger, and a smaller business concurrency coefficient indicates that the number of long connections of the long connection service node 131 in the long connection service cluster 13 is smaller.
[0183] For example, each persistent connection service node 131 can establish a preset number of persistent connections at most. For each persistent connection service node 131, the message management system 151 can determine the number of persistent connections currently established by each persistent connection service node 131 based on the persistent connection information reported by each persistent connection service node 131, and compare them with the preset number respectively to determine the concurrency coefficient of each persistent connection service node 131. For example, the ratio of the number of persistent connections currently established by each persistent connection service node 131 to the preset number is used as the concurrency coefficient of each persistent connection service node 131.
[0184] The message management system 151 then obtains the service concurrency coefficient of the persistent connection service cluster 13 based on the concurrency coefficient of each persistent connection service node 131. For example, the service concurrency coefficient of the persistent connection service cluster 13 may be the mean, median, etc. of the concurrency coefficients of all persistent connection service nodes 131.
[0185] In some embodiments, the message management system 151 may also obtain the service concurrency coefficient of the persistent connection service cluster 13 based only on the concurrency coefficients of all normally operating persistent connection service nodes 131 .
[0186] S74: If the service concurrency coefficient of the persistent connection service cluster 13 is greater than or equal to the first threshold, the message management system 151 sends a capacity expansion notification to the persistent connection service cluster 13, so that the persistent connection service cluster 13 expands the capacity based on the capacity expansion notification.
[0187] In some embodiments, if the business concurrency coefficient of the long connection service cluster 13 is greater than or equal to the first threshold, it indicates that each long connection service node 131 in the long connection service cluster 13 has established a large number of long connections, and the number of long connections is approaching the threshold (preset number). In order to avoid subsequent message forwarding congestion, the message management system 151 can send a capacity expansion notification to the long connection service cluster 13, and the long connection service cluster 13 can expand capacity based on the capacity expansion notification sent by the message management system 151. The expansion of the long connection service cluster 13 may refer to adding a first number of long connection service nodes 131, and the first number can be set according to actual needs, which is not limited in the embodiments of the present application.
[0188] For example, the persistent connection service cluster 13 includes a node management component for automatic expansion and contraction. The node management component can expand capacity based on the expansion notification sent by the message management system 151. The newly added persistent connection service nodes can be added to the cluster for management.
[0189] In some embodiments, the message management system 151 may also send a capacity expansion notification to the persistent connection service cluster 13 when the business concurrency coefficient of the persistent connection service cluster 13 is greater than or equal to the first threshold value and is maintained for the first preset time to improve the accuracy of the capacity expansion. The first preset time can be set according to actual needs, and the embodiments of the present application are not limited to this.
[0190] S75 , if the service concurrency coefficient of the persistent connection service cluster 13 is less than or equal to the second threshold, the message management system 151 sends a capacity reduction notification to the persistent connection service cluster 13 , so that the persistent connection service cluster 13 is reduced in capacity based on the capacity reduction notification.
[0191] In some embodiments, if the business concurrency coefficient of the long connection service cluster 13 is less than or equal to the second threshold, it indicates that each long connection service node 131 in the long connection service cluster 13 has established a small number of long connections. In order to avoid wasting node resources, the message management system 151 may send a capacity reduction notification to the long connection service cluster 13, and the long connection service cluster 13 may be scaled down based on the capacity reduction notification sent by the message management system 151. The long connection service cluster 13 may be scaled down by removing the second number of long connection service nodes 131, and the second number may be set according to actual needs, which is not limited in the embodiments of the present application.
[0192] In some embodiments, the message management system 151 may also send a capacity reduction notification to the persistent connection service cluster 13 when the business concurrency coefficient of the persistent connection service cluster 13 is less than or equal to the second threshold value and the second preset time is maintained to improve the accuracy of the capacity reduction. The second preset time can be set according to actual needs, and the embodiment of the present application is not limited to this.
[0193] In some embodiments, the first threshold is greater than the second threshold, and the first threshold and the second threshold can be set according to actual needs, which is not limited in the embodiments of the present application. For example, the business concurrency coefficient of the long connection service cluster 13 is between 0 and 1, the first threshold can be set to 0.8, 0.9, etc., and the second threshold can be set to 0.2, 0.3, etc.
[0194] In some embodiments, if the business concurrency coefficient of the long connection service cluster 13 is greater than the second threshold and less than the first threshold, it indicates that the number of long connections of each long connection service node 131 in the long connection service cluster 13 is appropriate. In this case, there is no need to expand or reduce the capacity of the long connection service cluster 13, and the message management system 151 does not send an expansion notification or a reduction notification to the long connection service cluster 13. The long connection service cluster 13 can maintain the number of long connection service nodes 131 unchanged.
[0195] S76, the message management system 151 parses the message to be pushed, and obtains the identification information of the client 14 corresponding to the message to be pushed.
[0196] Step S76 of the embodiment of the present application is similar to step S63 of the aforementioned embodiment and will not be described again here to avoid repetition.
[0197] In some embodiments, step S76 may be performed in parallel with step S73 , or step S76 may be performed before or after step S73 .
[0198] S77, the message management system 151 searches for the identification information of the first target persistent connection service node for establishing a persistent connection with the client 14 corresponding to the message to be pushed from multiple persistent connection service nodes 131 according to the received persistent connection information and the identification information of the client 14 corresponding to the message to be pushed.
[0199] Step S77 of the embodiment of the present application is similar to step S64 of the aforementioned embodiment and will not be described again here to avoid repetition.
[0200] S78, when the operating status of the first target persistent connection service node is normal, the message management system 151 pushes the message to be pushed to the first target persistent connection service node based on the identification information of the first target persistent connection service node, so as to push the message to be pushed to the client corresponding to the message to be pushed through the first target persistent connection service node.
[0201] Step S78 of the embodiment of the present application is similar to step S65 of the aforementioned embodiment and will not be described again here to avoid repetition.
[0202] S79: When the operation status of the first target persistent connection service node is abnormal, the message management system 151 discards the message to be pushed.
[0203] Step S79 of the embodiment of the present application is similar to step S66 of the aforementioned embodiment and will not be described again here to avoid repetition.
[0204] The above-mentioned message push method can make each persistent connection service node not need to consume every message generated by the message producer. Each persistent connection service node only needs to process the message pushed by the message push device, that is, it only needs to consume the message of the client with which the persistent connection is established, so as to realize point-to-point precise push of the message, reduce the consumption of node resources, and can visually monitor the message push. For example, the operation status of the nodes in the system can be known in real time, and the number of valid persistent connections can be determined based on the nodes that are running normally, and the specific node on which the persistent connection of the client is established can be quickly located based on the reported persistent connection information, so as to facilitate the abnormal problem troubleshooting when the message push is abnormal, and the persistent connection service cluster can be controlled to dynamically expand / contract during the peak or trough period of the business. Since the persistent connection service nodes in the persistent connection service cluster passively receive the messages pushed by the message management system, there is no need to actively subscribe to the messages produced by the message producer, so that the persistent connection service cluster can be expanded / contracted more easily and quickly, and there is no need to perform additional configuration or code changes after expansion / contraction in order to realize the message subscription of the persistent connection service node, as in the existing message push system.
[0205] See also Figure 8, is a schematic diagram of an application scenario of a message push method according to an embodiment of the present invention. The message push method can be applied to Figure 8 The message push device 15 shown may include a message management system (e.g., Figure 8 ws-manage system 113) and a node management system (eg, Figure 8 114). Taking the business system as an intelligent outbound call system (hereinafter referred to as aa-smart-outbond system 111) as an example, each outbound call agent can use the browser 112 installed on the workstation computer to log in to the aa-smart-outbond system 111. For example, the outbound call agent can enter his own account and password in the intelligent outbound call login interface opened on the browser 112 to log in to the intelligent outbound call system 111. In this application scenario, the browser 112 can be used as a client that finally receives the message generated by the aa-smart-outbond system 111.
[0206] Specifically, the aa-smart-outbond system 111 can accurately and quickly push the generated message to the browser 112 corresponding to the message in the following manner.
[0207] 1). Deploy the ws-manage system 113 and the ws-project-manage system 114, wherein the ws-manage system 113 can be configured to subscribe to messages of Kafka 115.
[0208] 2). Deploy a persistent connection service cluster (for example, Figure 8 aa-bot-msg system 116 shown), wherein the aa-bot-msg system 116 may include multiple long connection service nodes, Figure 8 For example, the aa-bot-msg system 116 includes three long connection service nodes: aa-bot-msg-dp0, aa-bot-msg-dp1, and aa-bot-msg-dp2. It is understandable that the aa-bot-msg system 116 may include more or less than three long connection service nodes.
[0209] In some embodiments, each long connection service node aa-bot-msg-dp0, aa-bot-msg-dp1, aa-bot-msg-dp2 can be configured to report identification information (for example, IP address) to the ws-project-manage system 114 after successful startup. The ws-project-manage system 114 can store the identification information reported by each long connection service node aa-bot-msg-dp0, aa-bot-msg-dp1, aa-bot-msg-dp2 in a preset database, for example, the preset database is a MySQL database.
[0210] In some embodiments, each long connection service node aa-bot-msg-dp0, aa-bot-msg-dp1, and aa-bot-msg-dp2 can send a heartbeat packet to the ws-project-manage system 114 at preset intervals (for example, 5 seconds) to perform heartbeat keep-alive. If the ws-project-manage system 114 does not receive a heartbeat packet from a long connection service node for more than a specific period of time (for example, 15 seconds), it can be considered that the long connection service node is abnormal. The ws-project-manage system 114 can remove the identification information of the long connection service node from the MySQL database, or add a mark to the identification information of the long connection service node in the MySQL database.
[0211] 3). The outbound call agent opens the intelligent outbound call login interface on the browser 112, enters the account number and password, and clicks the login control. The browser 112 initiates a request for a long connection with the domain name of the aa-bot-msg system 116.
[0212] 4). The load balancer Nginx configured by the aa-bot-msg system 116 selects the target long connection service node based on the number of long connections of each long connection service node. Assuming that the selected target long connection service node is the long connection service node aa-bot-msg-dp2, Nginx forwards the request of the browser 112 to the long connection service node aa-bot-msg-dp2, and the long connection service node aa-bot-msg-dp2 establishes a WebSocket long connection with the browser 112 based on the request.
[0213] 5). The long connection service node aa-bot-msg-dp2 reports the long connection information of the long connection established with the browser 112 to the ws-manage system 113. For example, the unique identity of the browser 112 may be the account of the currently logged-in outbound call agent, and the long connection information may include the IP address of the long connection service node aa-bot-msg-dp2 and the account of the outbound call agent. The ws-manage system 113 saves the long connection information reported by the long connection service node aa-bot-msg-dp2, for example, saves the long connection information to a preset database. The following is an example in which the long connection information includes the IP address of the long connection service node aa-bot-msg-dp2 and the account of the outbound call agent.
[0214] 6). The aa-smart-outbond system 111 responds to the outbound call operation of the outbound call agent, makes an outbound call, generates an outbound call message, and pushes the outbound call message to Kafka 115.
[0215] In some embodiments, since the outbound agent performs an outbound call operation based on a logged-in account, the outbound call operation may carry the account information of the outbound agent, and the aa-smart-outbond system 111 may add the account of the outbound agent to the outbound message.
[0216] 7). The ws-manage system 113 obtains the outbound call message from Kafka 115, parses the outbound call message, and obtains the account of the outbound call agent. The ws-manage system 113 can search for the long connection information previously stored in the preset database, determine the IP address of the long connection service node corresponding to the account of the call agent, and then find the IP address of the long connection service node aa-bot-msg-dp2. The ws-manage system 113 can also call the ws-project-manage system 114 to query whether the long connection service node aa-bot-msg-dp2 is running normally.
[0217] 8). If the ws-manage system 113 determines that the persistent connection service node aa-bot-msg-dp2 is operating normally, the ws-manage system 113 calls the IP address of the persistent connection service node aa-bot-msg-dp2 and the provided message push port to push the outbound message to the persistent connection service node aa-bot-msg-dp2.
[0218] In some embodiments, if the ws-manage system 113 determines that the persistent connection service node aa-bot-msg-dp2 operates abnormally, the ws-manage system 113 may discard the outbound message, or push the outbound message to the browser 112 used by the outbound agent through a backup mechanism.
[0219] 9). After receiving the outbound call information, the persistent connection service node aa-bot-msg-dp2 searches for the WebSocket persistent connection established with the browser 112 used by the outbound call agent, and pushes the outbound call message to the browser 112 used by the outbound call agent through the WebSocket persistent connection.
[0220] 10). After receiving the outbound call message, the browser 112 used by the outbound call agent performs page rendering to display the outbound call message.
[0221] Based on the same idea as the message push method in the above embodiment, the embodiment of the present application also provides a message push device, which can be used to execute the above message push method. For ease of explanation, the structural diagram of the message push device embodiment only shows the parts related to the embodiment of the present application. It can be understood by those skilled in the art that the illustrated structure does not constitute a limitation on the device, and may include more or fewer components than shown in the diagram, or combine certain components, or arrange the components differently.
[0222] like Fig. 9 As shown, the message push device 10 includes an acquisition module 101, a parsing module 102, a search module 103 and a push module 104. In some embodiments, the above modules can be programmable software instructions stored in a memory and can be called and executed by a processor. It is understood that in other embodiments, the above modules can also be program instructions or firmware fixed in the processor.
[0223] The acquisition module 101 is used to obtain the operating status of each persistent connection service node 131 and receive persistent connection information reported by each persistent connection service node 131, wherein the persistent connection information includes identification information of the persistent connection service node 131 and identification information of the client 14 that establishes a persistent connection with the persistent connection service node 131.
[0224] The parsing module 102 is used to parse the message to be pushed and obtain the identification information of the client 14 corresponding to the message to be pushed.
[0225] The search module 103 is used to search for the identification information of the first target persistent connection service node for establishing a persistent connection with the client 14 corresponding to the message to be pushed from multiple persistent connection service nodes 131 according to the received persistent connection information and the identification information of the client 14 corresponding to the message to be pushed.
[0226] The push module 104 is used to push the message to be pushed to the first target persistent connection service node based on the identification information of the first target persistent connection service node when the operating status of the first target persistent connection service node is normal, so as to push the message to be pushed to the client 14 corresponding to the message to be pushed through the first target persistent connection service node.
[0227] Fig.10 Schematic diagram of the hardware structure of the computer device 100 provided in the embodiment of the present application. Fig.10 As shown, the computer device 100 may include a processor 1001 and a memory 1002. The memory 1002 is used to store one or more computer programs 1003. The one or more computer programs 1003 are configured to be executed by the processor 1001. The one or more computer programs 1003 include instructions, and the above instructions can be used to implement the above message push method in the computer device 100.
[0228] It is understandable that the structure shown in this embodiment does not constitute a specific limitation on the computer device 100. In other embodiments, the computer device 100 may include more or fewer components than shown, or combine or separate some components, or arrange the components differently.
[0229] The processor 1001 may include one or more processing units, for example, the processor 1001 may include an application processor (AP), a modem, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0230] The processor 1001 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 1001 is a cache memory. The memory may store instructions or data that the processor 1001 has just used or circulated. If the processor 1001 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 1001, and thus improves the efficiency of the system.
[0231] In some embodiments, the processor 1001 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a SIM interface, and / or a USB interface, etc.
[0232] In some embodiments, memory 1002 may include high-speed random access memory and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0233] The message push methods in the above embodiments can all be implemented in a computer device 100 having the above hardware structure.
[0234] An embodiment of the present application also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on the computer device 100, the computer device 100 executes the above-mentioned related method steps to implement the message push method in the above-mentioned embodiment.
[0235] The embodiment of the present application also provides a computer program product. When the computer program product is executed on a computer device, the computer device executes the above-mentioned related steps to implement the message push method in the above-mentioned embodiment.
[0236] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer execution instructions, and when the device is running, the processor can execute the computer execution instructions stored in the memory so that the chip executes the message push method in the above embodiment.
[0237] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0238] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0239] The unit described as a separate component may or may not be physically separated, and the component shown as a unit may be one physical unit or multiple physical units, that is, it may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment.
[0240] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0241] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.
[0242] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A message push method, characterized in that: Applied to a message push device, the message push device is used to communicate with a persistent connection service cluster, the persistent connection service cluster includes multiple persistent connection service nodes, each persistent connection service node is used to establish a persistent connection with one or more message recipients, the method includes: Acquire the running status of each of the persistent connection service nodes, and receive persistent connection information reported by each of the persistent connection service nodes, wherein the persistent connection information includes identification information of the persistent connection service node and identification information of a message receiver that establishes a persistent connection with the persistent connection service node; Parsing the message to be pushed, and obtaining identification information of the message recipient corresponding to the message to be pushed; According to the received persistent connection information and the identification information of the message recipient corresponding to the message to be pushed, searching from the plurality of persistent connection service nodes for the identification information of the first target persistent connection service node for establishing a persistent connection with the message recipient corresponding to the message to be pushed; When the operating status of the first target persistent connection service node is normal, based on the identification information of the first target persistent connection service node, the message to be pushed is pushed to the first target persistent connection service node, so that the message to be pushed is pushed to the message recipient corresponding to the message to be pushed through the first target persistent connection service node.
2. The method according to claim 1, characterized in that The method further comprises: Determining a service concurrency coefficient of the persistent connection service cluster based on the persistent connection information reported by each of the persistent connection service nodes; If the service concurrency coefficient of the persistent connection service cluster is greater than or equal to the first threshold, sending a capacity expansion notification to the persistent connection service cluster, so that the persistent connection service cluster expands capacity based on the capacity expansion notification; If the service concurrency coefficient of the persistent connection service cluster is less than or equal to a second threshold, a reduction notification is sent to the persistent connection service cluster so that the persistent connection service cluster is reduced in capacity based on the reduction notification, and the first threshold is greater than the second threshold.
3. The method according to claim 1, characterized in that The method further comprises: Receiving and storing identification information reported by each of the persistent connection service nodes after startup; Perform heartbeat detection with each of the long connection service nodes; If the heartbeat detection result of the first persistent connection service node among the multiple persistent connection service nodes is abnormal, the stored identification information of the first persistent connection service node is deleted, or a preset mark is added to the stored identification information of the first persistent connection service node.
4. The method according to claim 1, characterized in that After receiving the persistent connection information reported by each persistent connection service node, the method further includes: Store the received long connection information; Based on the persistent connection disconnection information reported by each persistent connection service node or the identification information of the abnormally operating persistent connection service node, the stored persistent connection information is updated, where the persistent connection disconnection information is used to indicate that a persistent connection service node disconnects a persistent connection with a message receiver.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: When the operation state of the first target persistent connection service node is abnormal, discard the message to be pushed; or In the case that the identification information of the first target persistent connection service node for establishing a persistent connection with the message recipient corresponding to the message to be pushed is not found, the message to be pushed is discarded.
6. The method according to claim 1, characterized in that The method further comprises: In the case where the operation state of the first target persistent connection service node is abnormal, a backup persistent connection service node is selected from the remaining persistent connection service nodes except the first target persistent connection service node based on a preset rule, wherein the message recipient corresponding to the message to be pushed can maintain or disconnect the persistent connection with the first target persistent connection service node based on the heartbeat detection result with the first target persistent connection service node; Sending identification information of the standby persistent connection service node to the persistent connection service cluster to trigger the standby persistent connection service node to establish a persistent connection with a message recipient corresponding to the message to be pushed; When the persistent connection information associated with the message recipient corresponding to the message to be pushed is received from the standby persistent connection service node, the message to be pushed is pushed to the standby persistent connection service node, so that the message to be pushed is pushed to the message recipient corresponding to the message to be pushed through the standby persistent connection service node.
7. The method according to claim 6, characterized in that The preset rule includes: selecting the standby persistent connection service node based on the number of persistent connections of the persistent connection service node and / or based on available resources of the persistent connection service node, wherein the available resources include one or more of CPU resources, memory resources, and network bandwidth resources.
8. The method according to claim 1, characterized in that The method further comprises: When the operation state of the first target persistent connection service node is abnormal operation, storing the first duration of the message to be pushed, wherein the message recipient corresponding to the message to be pushed can maintain or disconnect the persistent connection with the first target persistent connection service node based on the heartbeat detection result with the first target persistent connection service node; In a case where persistent connection information associated with a message recipient corresponding to the message to be pushed is received within the first time period, determining, based on the associated persistent connection information, identification information of a second target persistent connection service node among the plurality of persistent connection service nodes for establishing a persistent connection with the message recipient corresponding to the message to be pushed, and pushing the message to be pushed to the second target persistent connection service node, so as to push the message to be pushed to the message recipient corresponding to the message to be pushed through the second target persistent connection service node; In the case that the long connection information associated with the message recipient corresponding to the message to be pushed is not received within the first time period, the message to be pushed is discarded.
9. A message push device, characterized in that: The message push device is used to communicate with a persistent connection service cluster, the persistent connection service cluster includes multiple persistent connection service nodes, each persistent connection service node is used to establish a persistent connection with one or more message recipients, and the device includes: an acquisition module, configured to acquire the running status of each of the persistent connection service nodes, and receive persistent connection information reported by each of the persistent connection service nodes, wherein the persistent connection information includes identification information of the persistent connection service node and identification information of a message receiver that establishes a persistent connection with the persistent connection service node; A parsing module, used to parse the message to be pushed, and obtain identification information of the message recipient corresponding to the message to be pushed; a search module, configured to search, from a plurality of the persistent connection service nodes, for identification information of a first target persistent connection service node for establishing a persistent connection with the message recipient corresponding to the message to be pushed, according to the received persistent connection information and the identification information of the message recipient corresponding to the message to be pushed; A push module is used to push the message to be pushed to the first target persistent connection service node based on the identification information of the first target persistent connection service node when the operating status of the first target persistent connection service node is normal, so as to push the message to be pushed to the message recipient corresponding to the message to be pushed through the first target persistent connection service node.
10. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory is used to store computer-readable instructions; the processor is used to read the computer-readable instructions and implement the message pushing method as described in any one of claims 1 to 8.
11. A computer storage medium, characterized in that: Computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the message pushing method according to any one of claims 1 to 8 is implemented.
