CN113037834A - Web page state updating method and device based on distributed instant push - Google Patents

Web page state updating method and device based on distributed instant push Download PDF

Info

Publication number
CN113037834A
CN113037834A CN202110243204.8A CN202110243204A CN113037834A CN 113037834 A CN113037834 A CN 113037834A CN 202110243204 A CN202110243204 A CN 202110243204A CN 113037834 A CN113037834 A CN 113037834A
Authority
CN
China
Prior art keywords
mapping
client
web page
server
long connection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110243204.8A
Other languages
Chinese (zh)
Inventor
张颖
郭建廷
尹学壮
余满江
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202110243204.8A priority Critical patent/CN113037834A/en
Publication of CN113037834A publication Critical patent/CN113037834A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/55Push-based network services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention belongs to the technical field of big data, and provides a Web page state updating method and a Web page state updating device based on distributed instant push, wherein the method comprises the following steps: receiving a long connection request sent by a client Web page; responding to the long connection request, and randomly sending the long connection request to a plurality of service terminals to establish a plurality of long connections; respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection; and when the server side carries out synchronous or asynchronous data updating, pushing the updated data of the server side to the Web page of the client side according to the first mapping and the second mapping. The invention overcomes the defects and shortcomings of the Web page state updating method in the prior art, and provides a real-time, reliable and highly available complex Web page state updating method.

Description

Web page state updating method and device based on distributed instant push
Technical Field
The invention relates to the technical field of big data, in particular to a Web page state updating method and device based on distributed instant push.
Background
In the prior art, a state updating scheme for processing a complex web page generally adopts a client active polling mode, namely, the client actively and continuously queries a server to retrieve new content, and http short polling or http long polling is used for interval data request acquisition. However, the polling message interaction has low real-time performance, is not suitable for the situation of high concurrency, and needs frequent http requests, thereby causing resource waste of the server.
Disclosure of Invention
The invention belongs to the technical field of big data, and provides a Web page state updating method and a Web page state updating device based on distributed instant push, which solve the problem that the refreshing of Web page data needs to be realized by initiating a data request through a front end, can support the frequent refreshing of the page data, and can realize more real-time and faster page refreshing. And broadcast message pushing is supported, and state updating is carried out on more online user pages.
In order to achieve the above object, a method for updating a Web page state based on distributed instant push is provided, which includes:
receiving a long connection request sent by a client Web page;
responding to the long connection request, and randomly sending the long connection request to a plurality of service terminals to establish a plurality of long connections;
respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection;
and when the server side carries out synchronous or asynchronous data updating, pushing the updated data of the server side to the Web page of the client side according to the first mapping and the second mapping.
Preferably, the establishing, according to the long connection, a first mapping between a server address and a client number and a second mapping between the client number and the long connection number respectively includes:
storing the first mapping in a Redis cache;
storing the second mapping in the server.
Preferably, when the server performs synchronous or asynchronous data update, pushing the updated data of the server to the client Web page according to the first mapping and the second mapping includes:
if the server side carries out synchronous or asynchronous data updating, reading a server side address from the Redis cache according to the first mapping; and
reading a client address from the server according to the second mapping;
and pushing the updated data of the server to the Web page of the client according to the address of the server and the address of the client.
Preferably, the Web page status updating method based on distributed instant push further includes:
establishing a client Socket corresponding to the long connection;
and monitoring the reading and writing of the data in the client Socket by using the Netty framework.
Preferably, the Web page status updating method based on distributed instant push further includes:
registering a push interface through Dubbo to determine a push service interface;
performing message encapsulation on the data updated by the server;
and pushing the packaged message to the pushing service interface.
In a second aspect, the present invention further provides a device for updating a Web page status based on distributed instant push, where the device includes:
the request receiving unit is used for receiving a long connection request sent by a client Web page;
a long connection establishing unit, configured to respond to the long connection request, and randomly send the long connection request to multiple servers to establish multiple long connections;
the mapping relation establishing unit is used for respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection;
and the message pushing unit is used for pushing the updated data of the server to the Web page of the client according to the first mapping and the second mapping.
Preferably, the mapping relationship establishing unit includes:
the first mapping cache module is used for storing the first mapping in a Redis cache;
and the second mapping cache module is used for storing the second mapping in the server.
Preferably, the message pushing unit includes:
a server address reading module, configured to read a server address from the Redis cache according to the first mapping; and
a client address reading module, configured to read a client address from the server according to the second mapping;
and the message pushing module is used for pushing the updated data of the server to the client Web page according to the server address and the client address.
Preferably, the Web page status updating apparatus based on distributed instant push further includes:
the client Socket establishing unit is used for establishing a client Socket corresponding to the long connection;
and the data monitoring unit is used for monitoring reading and writing of data in the client Socket by using the Netty framework.
Preferably, the Web page status updating apparatus based on distributed instant push further includes:
the service interface determining unit is used for registering the push interface through the Dubbo to determine the push service interface;
the message encapsulation unit is used for carrying out message encapsulation on the data updated by the server;
and the encapsulated message pushing unit is used for pushing the encapsulated message to the pushing service interface.
In a third aspect, the present invention provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements a method for updating a Web page status based on distributed instant push when executing the computer program.
In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of a method for Web page status update based on distributed push-on-demand.
As can be seen from the above description, in the method and apparatus for updating a Web page state based on distributed instant push provided by the embodiments of the present invention, a long connection request sent by a client Web page is received first; then, responding to the long connection request, and randomly sending the long connection request to a plurality of service terminals to establish a plurality of long connections; respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection; and finally, when the server side carries out synchronous or asynchronous data updating, pushing the updated data of the server side to the Web page of the client side according to the first mapping and the second mapping. The invention overcomes the defects and shortcomings of the Web page state updating method in the prior art (a client needs to actively and continuously inquire a server to retrieve new contents, and interval data request acquisition is carried out by http short polling or long polling), and provides a real-time, reliable and highly available complex Web page state updating method.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a schematic diagram of an architecture between a server A1 and a client device B1 and a server S1 according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the architecture among the server A1, the client device B1, the server S1 and the database server S2 according to the embodiment of the present invention;
fig. 3 is a first schematic flowchart of a method for updating a Web page state based on distributed instant push according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating steps 300 of a Web page status updating method based on distributed instant push according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating steps 400 of a method for updating a Web page status based on distributed instant push according to an embodiment of the present invention;
fig. 6 is a schematic flowchart of a second method for updating a Web page status based on distributed instant push according to an embodiment of the present invention;
fig. 7 is a schematic flowchart of a third method for updating a Web page state based on distributed instant push according to an embodiment of the present invention;
FIG. 8 is a block diagram of a Web page status updating apparatus based on distributed instant push in an embodiment of the present invention;
fig. 9 is a first schematic structural diagram of a Web page state updating apparatus based on distributed instant push in an embodiment of the present invention;
fig. 10 is a schematic structural diagram of the mapping relationship establishing unit 30 according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of the message pushing unit 40 according to the embodiment of the present invention;
fig. 12 is a schematic structural diagram of a Web page state updating apparatus based on distributed instant push in the embodiment of the present invention;
fig. 13 is a schematic structural diagram three of a Web page state updating apparatus based on distributed instant push in the embodiment of the present invention;
fig. 14 is a schematic structural diagram of an electronic device in an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
It should be noted that the terms "comprises" and "comprising," and any variations thereof, in the description and claims of this application and the above-described drawings, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In view of the above, the present application provides a Web page status updating system based on distributed instant push, which may be a server a1, see fig. 1, where the server a1 may be communicatively connected to at least one client device B1, and the server S1 may send a long connection request sent by a client Web page, and in response to the long connection request, randomly send the long connection request to a plurality of servers S1 to establish a plurality of long connections; the server A1 establishes a first mapping between the address of the server S1 and the user number and a second mapping between the user number and the long connection number according to the long connection respectively; when the server S1 performs synchronous or asynchronous data update, the server A1 pushes the updated data of the server S1 to the Web page of the client B1 according to the first mapping and the second mapping.
In addition, referring to fig. 2, the server a1 may further be communicatively connected to at least one database server S2, the database server S2 is configured to store a first mapping between the server S1 address and the user number, a second mapping between the user number and the long connection number, and the long connection request.
Based on the above, the client device B1 may have a display interface so that the user can view the risk pre-warning control information sent by the server S1 according to the interface.
It is understood that the client device B1 may include a smart phone, a tablet electronic device, a network set-top box, a portable computer, a desktop computer, a Personal Digital Assistant (PDA), a vehicle-mounted device, a smart wearable device, etc. Wherein, intelligence wearing equipment can include intelligent glasses, intelligent wrist-watch, intelligent bracelet etc..
The server and the client device may communicate using any suitable network protocol, including network protocols not yet developed at the filing date of this application. The network protocol may include, for example, a TCP/IP protocol, a UDP/IP protocol, an HTTP protocol, an HTTPS protocol, or the like. Of course, the network Protocol may also include, for example, an RPC Protocol (Remote Procedure Call Protocol), a REST Protocol (Representational State Transfer Protocol), and the like used above the above Protocol.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
The embodiment of the present invention provides a specific implementation of a Web page status updating method based on distributed instant push, and referring to fig. 3, the method specifically includes the following steps:
step 100: and receiving a long connection request sent by a client Web page.
It should be noted that a long connection means that a plurality of packets can be continuously transmitted over one connection, and if no packet is transmitted during the connection holding period, a link check packet needs to be transmitted in both directions. In contrast, short connection means that when two communication parties have data interaction, a connection is established, and after data transmission is completed, the connection is disconnected, that is, only one service is transmitted in each connection. Long connections are often used for frequent, point-to-point communications, and the number of connections cannot be too great. Each TCP connection needs three-step handshake, which requires time, and if each operation is a short connection, the processing speed is reduced greatly if the operation is repeated, so that each operation is not disconnected after the operation is completed, and the data packet is OK when the next processing is performed, and the TCP connection does not need to be established. For example: the connection of the database uses long connection, if the communication is frequent with short connection, Socket error can be caused, and the frequent Socket creation is also waste of resources.
Preferably, step 100 is implemented, when a long connection request is sent by the client Web page, a Web program in the client Web page obtains a long connection security check encryption string from the server. The security check encryption string is spliced by a user code and a time stamp and encrypted through a certificate.
Step 200: and responding to the long connection request, and randomly sending the long connection request to a plurality of service terminals to establish a plurality of long connections.
Specifically, when a long connection request is sent to a push service cluster, multiple long connections are randomly distributed to different service containers by a load balancing system to be established.
Step 300: and respectively establishing a first mapping between the address of the server and the number of the client and a second mapping between the number of the client and the number of the long connection according to the long connection.
Specifically, a mapping relationship between a server address and a corresponding client number is established according to the long connection, and then, a mapping relationship between a client number and a long connection number is established according to the long connection, it can be understood that the mapping relationship between the server address and the corresponding client number can determine the server address when message pushing is performed, and the mapping relationship between the client number and the long connection number is used for reading the client address.
Step 400: and when the server side carries out synchronous or asynchronous data updating, pushing the updated data of the server side to the Web page of the client side according to the first mapping and the second mapping.
On the basis of step 300, when the server data is changed and the changed message needs to be sent to the client Web page, the server address is read according to the first mapping, the client address is read according to the second mapping, and on this basis, the changed data (message) is sent from the server to the client Web page, and after receiving the message, the Web page parses the message content and makes different status displays and updates.
As can be seen from the above description, in the method and apparatus for updating a Web page state based on distributed instant push provided by the embodiments of the present invention, a long connection request sent by a client Web page is received first; then, responding to the long connection request, and randomly sending the long connection request to a plurality of service terminals to establish a plurality of long connections; respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection; and finally, when the server side carries out synchronous or asynchronous data updating, pushing the updated data of the server side to the Web page of the client side according to the first mapping and the second mapping. Specifically, the invention has the following beneficial effects:
1. the problem that the data refreshing of a complex Web page (such as a game page) is realized by initiating a data request through a front end is solved;
2. through the dubbo service call and the long connection message transmission, frequent refreshing of page data can be supported, and the page refreshing can be realized in real time and at a higher speed;
3. a highly available distributed instant messaging service supports broadcast messaging while providing status updates to more online user pages.
The method overcomes the defects and shortcomings of the Web page state updating method in the prior art (a client needs to actively and continuously inquire a server to retrieve new contents, and interval data request acquisition is carried out by using http short polling or long polling), and provides a real-time, reliable and highly available complex Web page state updating method.
In one embodiment, referring to fig. 4, step 300 further comprises:
step 301: storing the first mapping in a Redis cache.
Redis in step 301 is an open-source high-performance key-value database, and supports relatively more stored value types, including string, list, set, zset, and hash. These data types all support push/pop, add/remove, and intersect union and difference, and richer operations, and these operations are all atomic. On this basis, Redis supports various different ways of ordering. Like memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes updated data to a disk or writes a modification operation to an additional recording file, and a master-slave synchronization is realized on the basis of the updated data or the modification operation.
Step 302: storing the second mapping in the server.
In one embodiment, referring to fig. 5, step 400 further comprises:
step 401: if the server side carries out synchronous or asynchronous data updating, reading a server side address from the Redis cache according to the first mapping; and
specifically, a connection with the server can be established, and whether data update exists in the server is monitored in real time.
Step 402: reading a client address from the server according to the second mapping;
step 403: and pushing the updated data of the server to the Web page of the client according to the address of the server and the address of the client.
For the problem that complicated Web page data refreshing, for example, Web game page data refreshing, must be realized by a front-end initiated data request, steps 401 to 403 are performed by reading a client address in a server and reading a server address from a Redis cache, pushing a message updated by the server to a client Web page, and after receiving the pushed message, a corresponding Web page analyzes the message content and performs different state display.
In an embodiment, referring to fig. 6, the method for updating a Web page status based on distributed instant push further includes:
step 500: establishing a client Socket corresponding to the long connection;
as will be appreciated, Socket is an abstraction of an endpoint for two-way communication between application processes on different hosts in a network. A socket is the end of a process's communication over a network and provides a mechanism for application layer processes to exchange data using a network protocol. In terms of the position, the socket uplink application process and the socket downlink network protocol stack are interfaces through which the application program communicates through the network protocol, and are interfaces through which the application program interacts with the network protocol root.
Step 600: and monitoring the reading and writing of the data in the client Socket by using the Netty framework.
Netty is a high-performance, high-reliability web application open-source framework that provides an asynchronous, event-driven web application framework and tools for rapid development of high-performance, high-reliability web servers and client programs. That is, Netty is a NIO-based client, server-side programming framework that can be used to ensure that a web application, such as a client, server-side application that implements a protocol, is developed quickly and easily. Netty simplifies and streamlines the process of programmatic development of network applications, such as Socket service development for TCP and UDP.
In step 600, after the service of the Netty itself is started, a thread is started to continuously monitor whether a new network connection is accessed, and when a long connection establishment request is sent to the server, the Netty can monitor a message of the long connection request access, create a new client Socket, and monitor reading and writing of data in the Socket. When the long connection establishment is monitored, a mapping relation between the server address established by the long connection and the corresponding client number is stored in a Redis cache by realizing a connection establishment callback method provided by Netty. And storing the mapping relation between the client number and the long connection number in a server memory where the long connection is established.
In an embodiment, referring to fig. 7, the method for updating a Web page status based on distributed instant push further includes:
step 700: registering a push interface through Dubbo to determine a push service interface;
step 800: performing message encapsulation on the data updated by the server;
step 900: and pushing the packaged message to the pushing service interface.
It can be understood that Dubbo is an open source high performance service framework that enables applications to implement output and input functions of services through high performance RPC, and can be seamlessly integrated with Spring framework, which has three functions: interface-oriented remote method invocation, intelligent fault tolerance and load balancing, and automatic registration and discovery of services.
In steps 700-900, after the push service is started, the push interface is registered with the registry. The server calls a push service interface registered to a registration center through Dubbo, and transmits the encapsulated message to the server, wherein the encapsulation of the message supports multiple mode definitions as long as the format of the message is defined by the server and the client. Preferably, the method can be packaged into a Json string format, and specific message numbers and message content formats are agreed according to different scene content messages.
To further illustrate the present solution, the present application provides a specific application example of a Web page status updating apparatus based on distributed instant push, and referring to fig. 8, the apparatus specifically includes the following contents: the device is realized based on Dubbo, Netty, websocket and Redis. The method is divided into three service module clusters: push service module, business service module, storage module, specifically:
the push module uses a socket and websocket integrated jar-based package to support the establishment, communication and management of a long connecting channel between the client and the push server. The program run flow corresponding to fig. 8 is described below (the numbers correspond to the corresponding flow lines in fig. 8):
1: the client enters an application web page, and the web program acquires the long connection security check encryption string from the service module. The security check encryption string is spliced by a user code and a timestamp and encrypted through a certificate.
2: and the web program initiates a long connection establishment request, namely a websocket request, to the push service module, wherein the request carries the security check encryption string. When a request is sent to a push service cluster, the request is randomly distributed to different service containers by a load balancing system to establish long connection.
3. After the service of the Netty is started, a thread is started to continuously monitor whether a new network connection is accessed, when a long connection establishment request is sent to a server, the Netty can monitor a message of the long connection request access, create a new client Socket and monitor reading and writing of data in the Socket. When the long connection establishment is monitored, a mapping relation between the server address established by the long connection and the corresponding client number is stored in a Redis cache by realizing a connection establishment callback method provided by Netty. And storing the mapping relation between the client number and the long connection number in a server memory where the long connection is established.
4. When the service module carries out synchronous or asynchronous data updating, if a client page of a specific user needs to be informed of a message in real time, the address of the server established by the long connection is acquired from the Redis cache through the client number
5. The push module provides a push interface for other modules to use the push service program. After the push service is started, the push interface is registered in the registration center. The business service module calls a push service interface registered to the registration center through Dubbo and transmits the encapsulated message to the server, the encapsulation of the message supports multiple mode definitions, and the server and the client only need to define the format of the message. The method can be packaged into a Json string format, and specific message numbers and message content formats are appointed according to different scene content messages.
6. The Netty framework can manage the connection after packaging when a new network connection is accessed, and the push program acquires a corresponding long connection number through the client number, acquires a connection object after Netty packaging, calls a message sending interface provided by Netty and pushes a message to a client Web page. The push program does not process the message, and only transmits the message. After receiving the message, the Web page analyzes the message content and makes different state display and update
Through the program flow, the information can be pushed to the Web page of the client in real time, and the method is a perfect solution for the scene that the display effect of the front-end page needs to be updated when the data updating triggered by the server and the asynchronous data processing of the server are carried out simultaneously.
The embodiment of the present invention provides a specific implementation manner of a Web page state updating device based on distributed instant push, which can implement a Web page state updating method based on distributed instant push, and referring to fig. 9, the Web page state updating device based on distributed instant push specifically includes the following contents:
a request receiving unit 10, configured to receive a long connection request sent by a client Web page;
a long connection establishing unit 20, configured to respond to the long connection request, and randomly send the long connection request to multiple servers to establish multiple long connections;
a mapping relationship establishing unit 30, configured to respectively establish a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection;
and the message pushing unit 40 is configured to push the updated data of the server to the client Web page according to the first mapping and the second mapping.
Preferably, referring to fig. 10, the mapping relationship establishing unit 30 includes:
a first mapping cache module 301, configured to store the first mapping in a Redis cache;
a second mapping cache module 302, configured to store the second mapping in the server.
Preferably, referring to fig. 11, the message pushing unit 40 includes:
a server address reading module 401, configured to read a server address from the Redis cache according to the first mapping; and
a client address reading module 402, configured to read a client address from the server according to the second mapping;
a message pushing module 403, configured to push, according to the server address and the client address, the updated data of the server to the client Web page.
Preferably, referring to fig. 12, the Web page status updating apparatus based on distributed instant push further includes:
a client Socket establishing unit 50, configured to establish a client Socket corresponding to the long connection;
and the data monitoring unit 60 is configured to monitor reading and writing of data in the client Socket by using a Netty framework.
Preferably, referring to fig. 13, the Web page status updating apparatus based on distributed instant push further includes:
a service interface determining unit 70, configured to register a push interface through a Dubbo to determine a push service interface;
a message encapsulation unit 80, configured to perform message encapsulation on the data updated by the server;
and an encapsulated message pushing unit 90, configured to push the encapsulated message to the push service interface.
As can be seen from the above description, the Web page status updating apparatus based on distributed instant push provided in the embodiment of the present invention first receives a long connection request sent by a client Web page; then, responding to the long connection request, and randomly sending the long connection request to a plurality of service terminals to establish a plurality of long connections; respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection; and finally, when the server side carries out synchronous or asynchronous data updating, pushing the updated data of the server side to the Web page of the client side according to the first mapping and the second mapping. The invention overcomes the defects and shortcomings of the Web page state updating method in the prior art (the client needs to actively and continuously inquire the server to retrieve new contents, and interval data request acquisition is carried out by http short polling or long polling), and provides a complex Web page state updating device which is real-time, reliable and highly available.
An embodiment of the present application further provides a specific implementation manner of an electronic device, which is capable of implementing all steps in the method for updating a Web page state based on distributed instant push in the foregoing embodiment, and referring to fig. 14, the electronic device specifically includes the following contents:
a processor (processor)1201, a memory (memory)1202, a communication Interface 1203, and a bus 1204;
the processor 1201, the memory 1202 and the communication interface 1203 complete communication with each other through the bus 1204; the communication interface 1203 is configured to implement information transmission between related devices, such as a server-side device, a power measurement device, and a client device.
The processor 1201 is configured to call the computer program in the memory 1202, and the processor executes the computer program to implement all the steps in the method for updating a Web page status based on distributed instant push in the foregoing embodiments, for example, the processor executes the computer program to implement the following steps:
step 100: receiving a long connection request sent by a client Web page;
step 200: responding to the long connection request, and randomly sending the long connection request to a plurality of service terminals to establish a plurality of long connections;
step 300: respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection;
step 400: and when the server side carries out synchronous or asynchronous data updating, pushing the updated data of the server side to the Web page of the client side according to the first mapping and the second mapping.
An embodiment of the present application further provides a computer-readable storage medium capable of implementing all the steps in the method for updating a Web page status based on distributed instant push in the foregoing embodiments, where the computer-readable storage medium stores a computer program, and the computer program implements all the steps of the method for updating a Web page status based on distributed instant push in the foregoing embodiments when executed by a processor, for example, the processor implements the following steps when executing the computer program:
step 100: receiving a long connection request sent by a client Web page;
step 200: responding to the long connection request, and randomly sending the long connection request to a plurality of service terminals to establish a plurality of long connections;
step 300: respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection;
step 400: and when the server side carries out synchronous or asynchronous data updating, pushing the updated data of the server side to the Web page of the client side according to the first mapping and the second mapping.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the hardware + program class embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to the partial description of the method embodiment.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
Although the present application provides method steps as in an embodiment or a flowchart, more or fewer steps may be included based on conventional or non-inventive labor. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an actual apparatus or client product executes, it may execute sequentially or in parallel (e.g., in the context of parallel processors or multi-threaded processing) according to the embodiments or methods shown in the figures.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The principle and the implementation mode of the invention are explained by applying specific embodiments in the invention, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (12)

1. A Web page state updating method based on distributed instant push is characterized by comprising the following steps:
receiving a long connection request sent by a client Web page;
responding to the long connection request, and randomly sending the long connection request to a plurality of service terminals to establish a plurality of long connections;
respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection;
and pushing the updated data of the server to the client Web page according to the first mapping and the second mapping.
2. The method according to claim 1, wherein the establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection respectively comprises:
storing the first mapping in a Redis cache;
storing the second mapping in the server.
3. The method for updating a Web page status according to claim 2, wherein the pushing the updated data of the server to the client Web page according to the first mapping and the second mapping comprises:
if the server side carries out synchronous or asynchronous data updating, reading a server side address from the Redis cache according to the first mapping; and
reading a client address from the server according to the second mapping;
and pushing the updated data of the server to the Web page of the client according to the address of the server and the address of the client.
4. The Web page status updating method according to claim 1, further comprising:
establishing a client Socket corresponding to the long connection;
and monitoring the reading and writing of the data in the client Socket by using the Netty framework.
5. The Web page status updating method according to claim 1, further comprising:
registering a push interface through Dubbo to determine a push service interface;
performing message encapsulation on the data updated by the server;
and pushing the packaged message to the pushing service interface.
6. A Web page state updating device based on distributed instant push is characterized by comprising:
the request receiving unit is used for receiving a long connection request sent by a client Web page;
a long connection establishing unit, configured to respond to the long connection request, and randomly send the long connection request to multiple servers to establish multiple long connections;
the mapping relation establishing unit is used for respectively establishing a first mapping between a server address and a client number and a second mapping between the client number and a long connection number according to the long connection;
and the message pushing unit is used for pushing the updated data of the server to the Web page of the client according to the first mapping and the second mapping.
7. The Web page status updating apparatus according to claim 6, wherein the mapping relationship establishing unit includes:
the first mapping cache module is used for storing the first mapping in a Redis cache;
and the second mapping cache module is used for storing the second mapping in the server.
8. The Web page status updating apparatus according to claim 7, wherein the message pushing unit comprises:
a server address reading module, configured to read a server address from the Redis cache according to the first mapping; and
a client address reading module, configured to read a client address from the server according to the second mapping;
and the message pushing module is used for pushing the updated data of the server to the client Web page according to the server address and the client address.
9. The Web page status updating apparatus according to claim 6, further comprising:
the client Socket establishing unit is used for establishing a client Socket corresponding to the long connection;
and the data monitoring unit is used for monitoring reading and writing of data in the client Socket by using the Netty framework.
10. The Web page status updating apparatus according to claim 6, further comprising:
the service interface determining unit is used for registering the push interface through the Dubbo to determine the push service interface;
the message encapsulation unit is used for carrying out message encapsulation on the data updated by the server;
and the encapsulated message pushing unit is used for pushing the encapsulated message to the pushing service interface.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method for updating Web page status based on distributed push-on-demand as claimed in any one of claims 1 to 5 when executing the program.
12. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of a method for updating a Web page status based on distributed push-on-demand as claimed in any one of claims 1 to 5.
CN202110243204.8A 2021-03-05 2021-03-05 Web page state updating method and device based on distributed instant push Pending CN113037834A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110243204.8A CN113037834A (en) 2021-03-05 2021-03-05 Web page state updating method and device based on distributed instant push

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110243204.8A CN113037834A (en) 2021-03-05 2021-03-05 Web page state updating method and device based on distributed instant push

Publications (1)

Publication Number Publication Date
CN113037834A true CN113037834A (en) 2021-06-25

Family

ID=76468167

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110243204.8A Pending CN113037834A (en) 2021-03-05 2021-03-05 Web page state updating method and device based on distributed instant push

Country Status (1)

Country Link
CN (1) CN113037834A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114553949A (en) * 2022-02-15 2022-05-27 北京京东乾石科技有限公司 Page message pushing method and device
CN115333940A (en) * 2022-08-11 2022-11-11 以萨技术股份有限公司 Method and system for realizing configuration monitoring based on ETCD

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140047431A1 (en) * 2012-08-07 2014-02-13 Lawrence Cameron Vaughan Methods and systems for updating online gaming clients
WO2015056833A1 (en) * 2013-10-14 2015-04-23 Kyungpook National University Industry-Academic Cooperation Foundation Web-based real time data pushing method and system thereof
CN109660584A (en) * 2017-10-12 2019-04-19 阿里巴巴集团控股有限公司 A kind of method and communication means and communication system of client and the long connection of server foundation
CN109698785A (en) * 2017-10-24 2019-04-30 广东亿迅科技有限公司 A kind of the real-time messages method for pushing and device of distribution high concurrent
CN110300050A (en) * 2019-05-23 2019-10-01 中国平安人寿保险股份有限公司 Information push method, device, computer equipment and storage medium
CN111031058A (en) * 2019-12-23 2020-04-17 集奥聚合(北京)人工智能科技有限公司 Websocket-based distributed server cluster interaction method and device
CN111107039A (en) * 2018-10-26 2020-05-05 北京国双科技有限公司 Communication method, device and system based on TCP connection

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140047431A1 (en) * 2012-08-07 2014-02-13 Lawrence Cameron Vaughan Methods and systems for updating online gaming clients
WO2015056833A1 (en) * 2013-10-14 2015-04-23 Kyungpook National University Industry-Academic Cooperation Foundation Web-based real time data pushing method and system thereof
CN109660584A (en) * 2017-10-12 2019-04-19 阿里巴巴集团控股有限公司 A kind of method and communication means and communication system of client and the long connection of server foundation
CN109698785A (en) * 2017-10-24 2019-04-30 广东亿迅科技有限公司 A kind of the real-time messages method for pushing and device of distribution high concurrent
CN111107039A (en) * 2018-10-26 2020-05-05 北京国双科技有限公司 Communication method, device and system based on TCP connection
CN110300050A (en) * 2019-05-23 2019-10-01 中国平安人寿保险股份有限公司 Information push method, device, computer equipment and storage medium
CN111031058A (en) * 2019-12-23 2020-04-17 集奥聚合(北京)人工智能科技有限公司 Websocket-based distributed server cluster interaction method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114553949A (en) * 2022-02-15 2022-05-27 北京京东乾石科技有限公司 Page message pushing method and device
CN115333940A (en) * 2022-08-11 2022-11-11 以萨技术股份有限公司 Method and system for realizing configuration monitoring based on ETCD

Similar Documents

Publication Publication Date Title
CN106131213B (en) Service management method and system
CN107172187B (en) A kind of SiteServer LBS and method
CN110677277B (en) Data processing method, device, server and computer readable storage medium
EP2492860B1 (en) Forwarding data from server to device
TW202038581A (en) Management client, and device monitoring system and method
CN113037834A (en) Web page state updating method and device based on distributed instant push
CN107193674B (en) Method and device for processing online push message
JP2019523501A (en) Risk identification method, risk identification device, cloud risk identification device and system
CN111124589B (en) Service discovery system, method, device and equipment
CN113259415B (en) Network message processing method and device and network server
CN114070833A (en) Multi-protocol service compatible method, system, device, medium, and program product
CN107302572B (en) Architecture method of cloud monitoring center
Mangas et al. WOTPY: A framework for web of things applications
CN111064626A (en) Configuration updating method, device, server and readable storage medium
CN111240858A (en) Event scheduling method and component
WO2024067529A1 (en) Rdma-based link establishment method and apparatus, and device and storage medium
CN112702338B (en) IKE message acquisition method and device
CN112817539A (en) Industrial data storage method and system, electronic device and storage medium
US9614916B2 (en) Permanent connection oriented communication using parallel single connection circuits
CN115632815A (en) Data updating method and device, electronic equipment and storage medium
CN110262912B (en) Calling method and device for procedure call gRPC
CN113542217A (en) Service subscription system
CN113326056A (en) Data processing method, data processing device, storage medium and processor
CN115250276A (en) Distributed system and data processing method and device
CN111988283A (en) Data transmission method, system, device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20210625

RJ01 Rejection of invention patent application after publication