Message pushing method and device, electronic equipment, storage medium and program product
By employing persistent connections and service instance clusters for message push between banks and partners, the resource consumption and message delay issues caused by short HTTP connections were resolved, achieving efficient and stable message delivery and system availability.
Patent Information
- Application Number
- CN202411906240.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-12-23
AI Technical Summary
The current message push between banks and partners is based on HTTP short connections, which leads to frequent connection establishment, consuming a lot of system resources. Furthermore, network fluctuations or node failures can cause messages to fail to reach the client in a timely or accurate manner.
Persistent connections and service instance clusters are used. A persistent connection is established between the client and the target service instance cluster through the gateway. The current service instance is selected and the persistent connection is synchronized to receive and push messages.
It reduces network resource and time consumption, improves message push efficiency and real-time performance, enhances system stability and security, ensures timely message delivery, and maintains high system availability in the event of service instance failure.
Smart Images

Figure CN119743523B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of Internet of Things, and in particular to a message pushing method and device, electronic equipment, storage medium and program product. BACKGROUND
[0002] Hypertext Transfer Protocol (HTTP) short connection, also known as "non-persistent connection". In this connection mode, each HTTP request will establish a new Transmission Control Protocol (TCP) connection, and after the request is completed, the TCP connection will be closed.
[0003] Between banks and partners, messages often need to be pushed. The existing message pushing between banks and partners is implemented based on the HTTP short connection mode. That is, when the business needs, the bank calls the Application Programming Interface (API) of the partner to implement the pushing of the message, and after the pushing is completed, the connection is interrupted.
[0004] Based on the HTTP short connection to implement the message pushing, there is a problem of large overhead caused by frequent connection establishment, and when continuous and large messages are pushed, a large amount of system resources will be consumed, and any network fluctuation, node failure, etc. will cause the messages to be unable to reach the customer in time or accurately. SUMMARY
[0005] Embodiments of the present application provide a message pushing method and device, electronic equipment, storage medium and program product, which utilize persistent connection and service instance cluster to implement message pushing, and have significant improvement in resource utilization, pushing real-time performance, system stability and security, etc.
[0006] In a first aspect, the message pushing method provided by the embodiments of the present application is applied to a gateway, the gateway includes at least two service instance clusters, each service instance cluster includes at least two service instances, and the message pushing method includes:
[0007] Establishing a persistent connection between a client and a target service instance cluster;
[0008] Selecting a current service instance for the client from the target service instance cluster, and synchronizing the persistent connection to the current service instance;
[0009] Receiving a message sent by an application end and needed to be pushed to the client;
[0010] Pushing the message to the client by the current service instance through the persistent connection.
[0011] In a second aspect, the message pushing device is applied to a gateway, the gateway comprises at least two service instance clusters, each service instance cluster comprises at least two service instances, and the message pushing device comprises:
[0012] a connection establishing module, configured to establish a persistent connection between the client and the target service instance cluster;
[0013] an instance selecting module, configured to select a current service instance for the client from the target service instance cluster and synchronize the persistent connection to the current service instance;
[0014] a message receiving module, configured to receive a message sent by the application end and needed to be pushed to the client;
[0015] a message pushing module, configured to push the message to the client by the current service instance through the persistent connection.
[0016] In a third aspect, the electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the message pushing method according to any one of the embodiments of the present application when executing the program.
[0017] In a fourth aspect, the computer readable storage medium stores a computer program, and the program is executable on the processor to implement the message pushing method according to any one of the embodiments of the present application.
[0018] In a fifth aspect, the computer program product comprises a computer program, and the computer program is executable on the processor to implement the message pushing method according to any one of the embodiments of the present application.
[0019] In the embodiments of the present application, the persistent connection is established between the client and the target service instance cluster, because the connection remains in a continuous state, the process of repeatedly establishing the connection by handshaking is avoided, the network resources and time are saved, and the message pushing efficiency is improved; the persistent connection ensures that the client is online at any time, and once there is a message to be pushed, the message can be immediately sent through the existing connection, so that the delay time is reduced; the persistent connection has stronger bearing capacity for network fluctuations, and once the connection is established, short-term network fluctuations will not affect the stability of the connection, thereby improving the message arrival rate; the message pushing mode based on the persistent connection is only executed once in the whole process of connection establishment and disconnection, the long-time maintained connection can better utilize the underlying resources, and the waste of system resources is greatly reduced; the gateway manages the service instance cluster, ensures the high availability of the system, and even if a service instance fails, the system can be quickly switched to other healthy instances without interrupting the client connection; through the load balancing within and between the clusters, the load between each instance is evenly distributed, and service degradation caused by single point overload is prevented; through the centralized management of the service instances by the gateway, the security monitoring and management capability is improved. Attached Figure Description
[0020] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating a message push method provided in an embodiment of the present invention;
[0022] Figure 2a This is an example diagram of the message push framework provided in an embodiment of the present invention;
[0023] Figure 2b This is another flowchart illustrating the message push method provided in this embodiment of the invention;
[0024] Figure 3 This is an interactive example diagram of the message push method provided in an embodiment of the present invention;
[0025] Figure 4 This is a schematic diagram of a message push device provided in an embodiment of the present invention;
[0026] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0027] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0028] It should be noted that the terms "first", "second", and the like in the description and in the claims of the present application and above-described accompanying drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0029] Figure 1 is a flowchart of a message pushing method provided by an embodiment of the present application. The message pushing method provided by the embodiment of the present application can be applied to a scenario in which a large number of messages need to be pushed to a client by an application end. The message pushing method can be executed by a message pushing device provided by the embodiment of the present application. The device can be realized in a software and / or hardware manner. In a specific embodiment, the device can be integrated in an electronic device, which can be a gateway or the like. The following embodiments take the gateway as an example for description. Referring to Figure 1 The message pushing method of the embodiment can include the following steps:
[0030] In step 110, a persistent connection between the client and the target service instance cluster is established.
[0031] The method of the embodiment is applied to a gateway. The gateway includes at least two service instance clusters, and each service instance cluster includes at least two service instances. A service instance cluster is a collection of a group of service instances that collectively provide the same service. The cluster can share traffic through load balancing and provide failover capability when an instance fails. A service instance cluster exposes an address to the outside, that is, all service instances in a service instance cluster can share the same address. A service instance is a running instance of a service that provides actual business processing capability to the outside. A service instance cluster can be deployed on the same physical or virtual device. Deploying multiple instances of a service to form different service instance clusters allows the system not only to efficiently handle high-concurrency requests, but also to ensure continuous service availability when some service instances fail, thereby improving the stability and reliability of the overall system.
[0032] The client can be any terminal accessing the service, such as a browser, a mobile application or other terminal. The target service instance cluster is a specific service instance cluster selected to process the client request. The gateway can select a certain cluster as the "target" for this request according to factors such as load, health status, etc. Persistent connection refers to a TCP connection that is always open, which does not close after each request, but remains open for reuse. It can maintain the connection state between multiple requests, thereby reducing the overhead of connection establishment and closure. Specifically, the persistent connection can be a page socket (WebSocket) long connection. WebSocket is a full-duplex communication protocol based on TCP connection, which can establish a persistent connection between the client and the server, thereby realizing real-time bidirectional communication.
[0033] The client (such as a browser or mobile application) can initiate a connection request to the gateway, which selects a target service instance cluster according to the current load, service instance health status, etc. The gateway establishes a long-time valid TCP connection between the gateway and the client, and associates the connection directly to the target service instance cluster. After that, all messages that need to be pushed can be transmitted through this persistent connection, and the communication between the client and the target service instance cluster does not need to re-establish the connection each time.
[0034] Step 120, selecting a current service instance for the client from the target service instance cluster, and synchronizing the persistent connection to the current service instance.
[0035] The current service instance is a single service instance selected from the target service instance cluster to process a specific client request. This instance will handle the client's request in the current persistent connection. "Synchronization" means updating the state or information of the persistent connection to the selected current service instance, so that the instance knows and can handle the request through the persistent connection.
[0036] Specifically, in the target service instance cluster, the gateway can select a service instance that is most suitable for processing the current request according to load balancing strategies, instance health status, etc. The selected service instance is called the current service instance, and the gateway synchronizes the persistent connection information between the client to this current service instance, which means that this service instance will take over the persistent connection and handle the client's subsequent requests through it.
[0037] Through the above design, the system not only can efficiently handle high-concurrency requests, but also can keep the service continuously available when the service instance fails, thereby improving the performance and reliability of the overall system.
[0038] Step 130, receiving the message sent by the application end and needing to be pushed to the client.
[0039] The application end refers to an application program or a system that initiates a message push request. In a specific scenario, the application end can be a background system of a bank. The application end (such as a bank system) can send messages that need to be pushed to a certain client to the gateway, and these messages can contain various types of information, such as transaction notifications, account change reminders, or other important client notifications.
[0040] In step 140, the current service instance pushes a message to the client through a persistent connection.
[0041] After the gateway receives the message, it sends the message to the client through the persistent connection by using the current service instance. The client receives the message from the server through the persistent connection and processes it accordingly, such as popping up a notification, updating the interface, etc.
[0042] In this embodiment, a persistent connection is established between the client and the target service instance cluster. Because the connection remains in a persistent state, the process of repeatedly establishing a connection through handshaking is avoided, network resources and time are saved, and message push efficiency is improved. The persistent connection ensures that the client is always online, and once there is a message to be pushed, the message can be sent immediately through the existing connection, reducing the delay time. The persistent connection has stronger resistance to network fluctuations, and once the connection is established, short-term network fluctuations will not affect the stability of the connection, thereby improving the message arrival rate. The message push method based on the persistent connection only performs the connection establishment to disconnection process once, and the long-maintained connection can better utilize underlying resources, greatly reducing the waste of system resources. The gateway manages the service instance cluster, ensuring system high availability, so even if a service instance fails, it can quickly switch to other healthy instances without interrupting client connections. Through load balancing within and between clusters, the load is evenly distributed among each instance, preventing service degradation caused by single-point overload. Through centralized management of service instances by the gateway, security monitoring and management capabilities are improved.
[0043] The framework to which the message push method of the embodiment of the application is applied will be introduced below. A specific message push framework example can be as shown in Figure 2a The cooperation partner client, the connection management center (i.e., the connection management device), the push gateway, and the in-house application (i.e., the application end). There can be multiple cooperation partner clients, and the push gateway has multiple service instances. A WebSocket long connection is established between each client and the corresponding service instance.
[0044] The connection management center is responsible for managing the long connection state, session information and routing information of each WebSocket client, and includes a connection management module and a load balancing module. The connection management module can use a remote dictionary server (Redis) to store and manage connection information. Redis is selected because it has the following advantages: first, Redis has the characteristics of efficient key-value storage and in-memory database, and supports the publish / subscribe mode, which can realize the broadcast or grouping of message pushing; second, Redis supports cluster mode, which can cope with a large number of connections and high-concurrency request scenarios; third, the persistence mechanism of Redis guarantees the high availability and rapid recovery capability of the connection management center. The load balancing module is responsible for long connection distribution, and through formulating load balancing strategies (such as round robin, minimum connection, address hash, etc.), the connection is reasonably distributed to different WebSocket service instance clusters.
[0045] The message pushing framework as shown in Figure 2a The message pushing method provided by the embodiment of the application will be further described below in combination with the message pushing framework as shown in Figure 2b The method of the embodiment can include:
[0046] In step 201, the address information and load of each service instance cluster are reported to the connection management device, so that the connection management device selects a target service instance cluster for the client according to the load of each service instance cluster and provides the address information of the target service instance cluster to the client.
[0047] The address information can include an Internet Protocol (IP) address and a port number. The load refers to the current workload of the service instance cluster, including the number of connections, the Central Processing Unit (CPU) usage, the memory usage, etc., which reflects the current resource usage of the service instance cluster.
[0048] Specifically, after the deployment of the message pushing framework is completed, the gateway can report the address information and load of each service instance cluster to the connection management device in real time or periodically. The connection management device selects a suitable target service instance cluster according to the load of these clusters, and provides the address information of the selected target service instance cluster to the client, so that the client can connect to the cluster. Through this mechanism, the system can not only ensure load balancing and efficient resource utilization, but also improve the stability and response speed of the service.
[0049] At step 202, a connection establishment request initiated by a client is received, and the connection establishment request includes address information of a target service instance cluster. A persistent connection between the client and the target service instance cluster is established based on the address information of the target service instance cluster.
[0050] The connection establishment request is a request initiated by the client to the server, and the purpose is to request to establish a communication connection with the target service instance cluster. The request includes address information of the target service instance cluster. The persistent connection is a long-term open connection, which will not be closed after each request processing, but can be reused to process multiple requests to reduce the overhead of establishing and closing the connection.
[0051] The client can generate a connection establishment request, which includes address information (such as IP and port) of the target service instance cluster. The gateway receives the connection establishment request sent by the client, parses the address information of the cluster in the request, identifies the specific network address of the service instance cluster to be connected, and establishes a persistent connection with the target service instance cluster based on the parsed address information.
[0052] For example, the gateway has three service instance clusters: cluster A, cluster B, and cluster C. Assuming that the current load of cluster A is the lowest, the gateway can provide the address information of cluster A to the client to establish a persistent connection between the client and cluster A.
[0053] At step 203, the load conditions of each service instance in the target service instance cluster are obtained.
[0054] The load condition of the service instance refers to the current resource usage and stress condition of each service instance, including but not limited to CPU usage, memory usage, network traffic, and the number of requests currently being processed. These information can help determine the workload of the service instance.
[0055] At step 204, a current service instance is selected from the target service instance cluster for the client according to the load conditions of each service instance, and the persistent connection is synchronized to the current service instance.
[0056] The gateway can select a service instance with the most appropriate load (e.g., the lowest load) as the current service instance to process the client's request according to the load of each service instance in the target service instance cluster. Then, the gateway synchronizes the client's persistent connection with the selected current service instance, enabling smooth communication. For example, the target service instance cluster is cluster A, which includes service instances A1, A2, and A3, and service instance A1 has the lowest load at the current time. Then, service instance A1 can be determined as the current service instance, and the client's persistent connection is synchronized to service instance A1. Through this mechanism, the system can achieve efficient load balancing, ensure full utilization of resources, improve system response speed and stability, and ultimately improve user experience and service quality.
[0057] At the same time, in order to achieve high availability, the connection management device can also broadcast the client's persistent connection to the candidate service instances in the target service instance cluster, so that when the current service instance is unavailable, the candidate service instances can take over the current service instance to provide services to the client. The candidate service instances are other service instances in the target service instance cluster except the current service instance. For example, the target service instance cluster is cluster A, which includes service instances A1, A2, and A3, and the current service instance is A1. The connection management device can also broadcast the client's persistent connection to A2 and A3.
[0058] Step 205, receiving the message sent by the application end that needs to be pushed to the client.
[0059] The application end refers to the application program or system that initiates the message push request. In a specific scenario, the application end can be a bank's back-end system. The application end (such as a bank system) can send messages that need to be pushed to a certain client to the gateway, and these messages can contain various types of information, such as transaction notifications, account change reminders, or other important client notifications.
[0060] Step 206, determining whether the current service instance is available. If it is available, step 209 is executed, and if it is not available, step 207 is executed.
[0061] Availability refers to whether a service instance can work normally and process requests. Measuring the availability of a service instance usually involves monitoring its health status, response time, load, and connection status, etc.
[0062] Step 207, selecting a backup service instance for the client from the candidate service instances of the target service instance cluster based on the load balancing strategy, and the backup service instance synchronizes the persistent connection through the broadcast of the connection management device.
[0063] The load balancing strategy is an algorithm or rule for distributing requests to different service instances to ensure that system resources are used most efficiently and guarantee service performance and stability. The standby service instance is a service instance used when the current service instance is unavailable or has too high a load to ensure service continuity.
[0064] That is, when the current service instance is unavailable, the gateway selects a standby service instance for the client from the candidate service instances of the target service instance cluster according to the load balancing strategy. Since the standby service instance has synchronized the persistent connection through the broadcast of the connection management device, the standby instance can immediately take over processing the client's request.
[0065] Step 208, using the standby service instance to push messages to the client through the persistent connection.
[0066] Step 209, using the current service instance to push messages to the client through the persistent connection.
[0067] Step 210, when the persistent connection between the client and the target service instance cluster is interrupted, reporting the connection interruption notification information to the connection management device to enable the connection management device to generate connection failure notification information based on the connection interruption notification information, and the connection failure notification information is broadcast to the candidate service instances in the target service instance cluster by the connection management device.
[0068] The client and the gateway can detect the state of the persistent connection through the heartbeat packets sent periodically, and once the persistent connection is detected to be interrupted, the gateway can report the connection interruption notification information to the connection management device. After the connection management device receives the connection interruption notification information, it determines that the current persistent connection has failed, and broadcasts the connection failure notification information to the candidate service instances in the target service instance cluster to enable the candidate service instances to also stop providing services to the client, and thus the disconnection between the client and the target service instance cluster is successful.
[0069] The following describes the interaction process involved in the message pushing method of the embodiment of the application, and a specific interaction example is shown in FIG. 1. Figure 3
[0070] When deploying the message pushing framework, the client can be configured with application identity (APP ID), key, and other information, and the client accesses the software development kit (SDK) for message pushing. After the client is started, the SDK is initialized, the address information of the service instance cluster with the smallest current load is obtained from the connection management device using the SDK, and a request for establishing a WebSocket connection is initiated to the pushing gateway based on the address information of the service instance cluster with the smallest current load.
[0071] The gateway establishes a persistent connection between the client and the current service instance cluster with the smallest load (i.e., the current service instance cluster), selects a service instance with the smallest load (i.e., the current service instance) from the current service instance cluster, and synchronizes the persistent connection to the current service instance. At the same time, the connection management device can also broadcast the synchronization of the persistent connection to other service instances in the current service instance cluster.
[0072] When the gateway receives a message sent by the application end and to be pushed to the client, it can determine whether the current service instance is available. If the current service instance is available, the current service instance pushes the message to the client through the persistent connection. If the current service instance is not available, another available service instance, i.e., a standby service instance, is determined from the current service instance cluster through load balancing, and the standby service instance pushes the message to the client through the persistent connection.
[0073] The gateway and the client can detect the state of the persistent connection through a heartbeat packet. Once the persistent connection is detected to be interrupted, the gateway can report a connection interruption notification to the connection management device. After receiving the connection interruption notification, the connection management device determines that the current persistent connection has failed, broadcasts a connection failure notification to the candidate service instances in the current service instance cluster, so that the candidate service instances also stop providing services to the client. Thus, the disconnection between the client and the current service instance cluster is successful.
[0074] In this embodiment, a persistent connection is established between the client and the target service instance cluster. Because the connection remains in a persistent state, the process of multiple handshakes to rebuild the connection is avoided, network resources and time are saved, and the message pushing efficiency is improved. The persistent connection ensures that the client is online at any time. Once there is a message to be pushed, the message can be sent immediately through the existing connection, reducing the delay time. The persistent connection has stronger tolerance to network fluctuations. Once the connection is established, short-term network fluctuations will not affect the stability of the connection, thereby improving the message arrival rate. The message pushing method based on the persistent connection is performed only once from the connection establishment to the disconnection. The long-time maintained connection can better utilize the underlying resources, greatly reducing the waste of system resources. The gateway manages the service instance cluster, ensuring the high availability of the system. Even if a service instance fails, it can be quickly switched to other healthy instances without interrupting the client connection. Through the load balancing within and between clusters, the load is evenly distributed between each instance, preventing service degradation caused by single-point overload. Through the centralized management of the gateway on the service instances, the security monitoring and management capabilities are improved.
[0075] Figure 4 is a structural schematic diagram of a message pushing device provided by an embodiment of the present application. The device is suitable for executing the message pushing method provided by the embodiment of the present application, such as Figure 4As shown, the apparatus is applied to a gateway, the gateway includes at least two service instance clusters, each service instance cluster includes at least two service instances, and the apparatus specifically can include:
[0076] The connection establishing module 401 is configured to establish a persistent connection between the client and the target service instance cluster.
[0077] The instance selecting module 402 is configured to select a current service instance for the client from the target service instance cluster, and synchronize the persistent connection to the current service instance.
[0078] The message receiving module 403 is configured to receive a message sent by an application end and needed to be pushed to the client.
[0079] The message pushing module 404 is configured to push the message to the client by the current service instance through the persistent connection.
[0080] In an embodiment, the apparatus further includes:
[0081] The reporting module is configured to report address information and load conditions of each service instance cluster to a connection management device, so that the connection management device selects a target service instance cluster for the client according to the load conditions of each service instance cluster and provides address information of the target service instance cluster to the client.
[0082] The connection establishing module 401 establishes the persistent connection between the client and the target service instance cluster, including:
[0083] Receiving a connection establishing request initiated by the client, the connection establishing request including address information of the target service instance cluster, and establishing the persistent connection between the client and the target service instance cluster based on the address information of the target service instance cluster.
[0084] In an embodiment, the instance selecting module 402 selects the current service instance for the client from the target service instance cluster, including:
[0085] Obtaining load conditions of each service instance in the target service instance cluster.
[0086] Selecting the current service instance for the client from the target service instance cluster according to the load conditions of each service instance.
[0087] In an embodiment, the apparatus further includes:
[0088] The judging module is configured to judge whether the current service instance is available.
[0089] If the current service instance is available, the message pushing module 404 pushes the message to the client by the current service instance through the persistent connection.
[0090] In an embodiment, after the judging module judges whether the current service instance is available, the message pushing module 404 is further configured to:
[0091] If the current service instance is not available, a backup service instance is selected for the client from the candidate service instances of the target service instance cluster based on a load balancing strategy, and the backup service instance is through a broadcast synchronization persistent connection of the connection management device;
[0092] The backup service instance pushes a message to the client through the persistent connection.
[0093] In an embodiment, the reporting module is further configured to:
[0094] When the persistent connection between the client and the target service instance cluster is interrupted, the reporting module reports connection interruption notification information to the connection management device, so that the connection management device generates connection invalidation notification information based on the connection interruption notification information, and the connection invalidation notification information is broadcasted by the connection management device to the candidate service instances in the target service instance cluster.
[0095] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional modules is taken as an example, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the above described functional modules can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0096] The device of the embodiment of the application establishes a persistent connection between the client and the target service instance cluster, because the connection remains in a continuous state, the process of repeatedly handshaking to rebuild the connection is avoided, network resources and time are saved, and the message pushing efficiency is improved; the persistent connection ensures that the client is online at any time, and once there is a message to be pushed, the message can be immediately sent through the existing connection, reducing the delay time; the persistent connection has stronger resistance to network fluctuations, and once the connection is established, short-term network fluctuations will not affect the stability of the connection, thereby improving the message arrival rate; the message pushing method based on the persistent connection is performed only once in the entire connection establishment to disconnection process, and the long-time maintained connection can better utilize the underlying resources, greatly reducing the waste of system resources; the gateway manages the service instance cluster, ensuring system high availability, so that even if a service instance fails, it can quickly switch to other healthy instances without interrupting the client connection; through the load balancing within and between the clusters, the load is evenly distributed between each instance, preventing service degradation caused by single point overload; through the centralized management of the gateway service instance, the security monitoring and management capability is improved.
[0097] The following refers to Figure 5It shows a schematic diagram of the structure of a computer system 500 suitable for implementing an electronic device according to embodiments of the present invention. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0098] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 502 or programs loaded from storage section 508 into random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of the computer system 500. The CPU 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0099] The following components are connected to I / O interface 505: an input section 506 including a keyboard, mouse, etc.; an output section 507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to I / O interface 505 as needed. A removable medium 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 510 as needed so that computer programs read from it can be installed into storage section 508 as needed.
[0100] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by central processing unit (CPU) 501, it performs the functions defined above in the system of this invention.
[0101] It should be noted that the computer-readable medium shown in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or component. In the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or component. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0102] The flow diagrams and block diagrams in the drawings are schematic illustrations of possible architectures, functions and operations of systems, methods and computer program products in accordance with various embodiments of the present application. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may be executed in the reverse order, depending on the functionality involved. It will also be noted that each block of the block diagrams or flow diagrams, and combinations of blocks in the block diagrams or flow diagrams, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.
[0103] The modules and / or units described in the embodiments of the present application can be implemented by software or hardware. The described modules and / or units can also be arranged in a processor, for example, a processor can be described as including a connection establishing module, an instance selecting module, a message receiving module and a message pushing module. In some cases, the names of the modules do not constitute a limitation on the modules themselves.
[0104] As another aspect, the present application also provides a computer readable medium, which can be included in the device described in the above embodiments, or can exist independently without being assembled into the device. The computer readable medium carries one or more programs, which, when executed by the device, cause the device to include:
[0105] establish a persistent connection between the client and the target service instance cluster, select a current service instance for the client from the target service instance cluster, and synchronize the persistent connection to the current service instance, receive a message sent by an application end and needed to be pushed to the client, and push the message to the client by the current service instance through the persistent connection.
[0106] The technical solution of the embodiments of the present application establishes a persistent connection between the client and the target service instance cluster. Because the connection remains in a continuous state, the process of repeatedly establishing a connection through handshaking is avoided, network resources and time are saved, and the message pushing efficiency is improved. The persistent connection ensures that the client is online at any time, and once a message needs to be pushed, the message can be immediately sent through the existing connection, reducing the delay time. The persistent connection has stronger resistance to network fluctuations. Once the connection is established, short-term network fluctuations will not affect the stability of the connection, thereby improving the message arrival rate. The message pushing method based on the persistent connection is performed only once from the entire connection establishment to disconnection. The long-term maintained connection can better utilize the underlying resources, greatly reducing the waste of system resources. The gateway manages the service instance cluster, ensuring system high availability. Even if a service instance fails, it can quickly switch to other healthy instances without interrupting the client connection. Through load balancing within and between clusters, the load between each instance is evenly distributed, preventing service degradation caused by single point overload. Through centralized management of service instances by the gateway, the security monitoring and management capabilities are improved.
[0107] The embodiments of the present application also provide a computer program product, which includes a computer program, and the computer program, when executed by a processor, implements the message pushing method provided by any of the embodiments of the present application.
[0108] Computer program products can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0109] It should be understood that the various forms of flow shown above can be re-ordered, added to, or have steps deleted, for example. The steps recited in the present disclosure can be performed in parallel, in series, or in a different order, as long as the desired results of the claimed technical solutions are achieved, and are not limited herein.
[0110] It should be noted that in the technical solutions of the present application, the collection, use, storage, sharing and transfer of user personal information and other processing comply with relevant laws and regulations, and the user needs to be informed and the user's consent or authorization needs to be obtained, and when applicable, the user personal information is subjected to de-identification and / or anonymization and / or encryption technical processing. In addition, the user is also provided with a corresponding operation portal for the user to choose to agree or refuse the automatic decision result; if the user chooses to refuse, the expert decision flow is entered.
[0111] The above detailed description does not constitute a limitation on the scope of protection of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A message pushing method, characterized by, The application is applied to a gateway, the gateway comprises at least two service instance clusters, each service instance cluster comprises at least two service instances, and the message pushing method comprises: establishing a persistent connection between the client and a target service instance cluster; the target service instance cluster exposes an address to the outside, and all service instances in the target service instance cluster share the same address exposed to the outside; selecting a current service instance for the client from the target service instance cluster and synchronizing the persistent connection to the current service instance; candidate service instances in the target service instance cluster synchronize the persistent connection through broadcast of a connection management device, and the candidate service instances are other service instances in the target service instance cluster except the current service instance; receiving a message sent by an application end and needed to be pushed to the client; judging whether the current service instance is available, and if the current service instance is available, pushing the message to the client through the persistent connection by using the current service instance; if the current service instance is not available, selecting a backup service instance for the client from the candidate service instances of the target service instance cluster based on a load balancing strategy, and pushing the message to the client through the persistent connection by using the backup service instance; when the persistent connection between the client and the target service instance cluster is interrupted, reporting connection interruption notification information to the connection management device, so that the connection management device generates connection invalidation notification information based on the connection interruption notification information, the connection invalidation notification information is broadcasted to the candidate service instances in the target service instance cluster by the connection management device, and the connection invalidation notification information is used to notify the candidate service instances to also stop providing services for the client.
2. The message pushing method of claim 1, wherein, Before the persistent connection between the client and the target service instance cluster is established, the method further comprises: reporting address information and load conditions of each service instance cluster to the connection management device, so that the connection management device selects the target service instance cluster for the client according to the load conditions of each service instance cluster and provides the address information of the target service instance cluster to the client; establishing the persistent connection between the client and the target service instance cluster, comprising: receiving a connection establishment request initiated by the client, the connection establishment request comprising the address information of the target service instance cluster, and establishing the persistent connection between the client and the target service instance cluster based on the address information of the target service instance cluster.
3. The message pushing method of claim 1, wherein, selecting the current service instance for the client from the target service instance cluster, comprising: obtaining load conditions of each service instance in the target service instance cluster; selecting the current service instance for the client from the target service instance cluster according to the load conditions of each service instance.
4. A message pushing apparatus characterized by comprising: The application is applied to a gateway, the gateway comprises at least two service instance clusters, each service instance cluster comprises at least two service instances, and the message pushing device comprises: a connection establishment module, configured to establish a persistent connection between the client and a target service instance cluster; the target service instance cluster exposes an address to the outside, and all service instances in the target service instance cluster share the same address exposed to the outside; An instance selection module is configured to select a current service instance for the client from a target service instance cluster and synchronize the persistent connection to the current service instance; a candidate service instance in the target service instance cluster synchronizes the persistent connection through broadcasting of the connection management device, and the candidate service instance is a service instance other than the current service instance in the target service instance cluster; A message receiving module is configured to receive a message sent by the application end and needed to be pushed to the client; A message pushing module is configured to determine whether the current service instance is available, and if the current service instance is available, push the message to the client through the persistent connection by using the current service instance; if the current service instance is not available, select a backup service instance for the client from the candidate service instances of the target service instance cluster based on a load balancing strategy, and push the message to the client through the persistent connection by using the backup service instance; A reporting module is configured to report a connection interruption notification information to the connection management device when the persistent connection between the client and the target service instance cluster is interrupted, so that the connection management device generates a connection invalidation notification information based on the connection interruption notification information, the connection invalidation notification information is broadcasted to the candidate service instances in the target service instance cluster by the connection management device, and the connection invalidation notification information is used to notify the candidate service instances to stop providing services for the client.
5. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to implement the message pushing method according to any one of claims 1 to 3.
6. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the message pushing method according to any one of claims 1 to 3.
7. A computer program product, characterised in that, The computer program product comprises a computer program, and the computer program is executed by the processor to implement the message pushing method according to any one of claims 1 to 3.
Citation Information
Patent Citations
FTP service implementation method, system and device and storage medium
CN114124935A
Request processing method and device, equipment, storage medium and program product
CN117395255A