CN111385324A - Data communication method, device, equipment and storage medium - Google Patents
Data communication method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN111385324A CN111385324A CN201811627369.XA CN201811627369A CN111385324A CN 111385324 A CN111385324 A CN 111385324A CN 201811627369 A CN201811627369 A CN 201811627369A CN 111385324 A CN111385324 A CN 111385324A
- Authority
- CN
- China
- Prior art keywords
- server
- communication
- client
- target server
- identification
- 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
Links
- 230000006854 communication Effects 0.000 title claims abstract description 324
- 238000004891 communication Methods 0.000 title claims abstract description 298
- 238000000034 method Methods 0.000 title claims abstract description 58
- 238000012795 verification Methods 0.000 claims description 14
- 238000004590 computer program Methods 0.000 claims description 6
- 238000010586 diagram Methods 0.000 description 15
- 230000003993 interaction Effects 0.000 description 12
- 230000006870 function Effects 0.000 description 9
- 238000012423 maintenance Methods 0.000 description 8
- 230000008569 process Effects 0.000 description 7
- 230000004044 response Effects 0.000 description 4
- 239000002699 waste material Substances 0.000 description 4
- 230000009286 beneficial effect Effects 0.000 description 3
- 238000001514 detection method Methods 0.000 description 3
- 235000014510 cooky Nutrition 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002085 persistent effect Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/146—Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention discloses a data communication method, a data communication device, data communication equipment and a storage medium. Wherein, the method comprises the following steps: sending a communication request to a central node; acquiring an identifier of a target server fed back by a central node, wherein the identifier of the target server is selected from identifiers of background servers prestored locally by the central node; and establishing communication connection with the target server according to the identification of the target server. According to the technical scheme provided by the embodiment of the invention, the central node selects the identification of the target server from the identifications of the background servers prestored locally, so that the communication connection is directly established between the client and the target server, a plurality of load balancers are not required to be respectively connected with the background servers, the forwarding of communication data through the central node is not required, additional information is not required to be carried in the communication process, the communication process is simplified, and the communication efficiency between the client and the background servers is improved.
Description
Technical Field
The embodiment of the invention relates to the technical field of internet, in particular to a data communication method, a data communication device, data communication equipment and a storage medium.
Background
With the rapid development of the internet technology, more and more project business requirements correspondingly exist in the Web Service, which is an application program generated by the Web Service technology and capable of being used for developing distributed interoperation. In the traditional web service, a cookie or session is generally adopted to store the identity authentication state of a user; the cookie is stored in the client and has certain potential safety hazard due to the attack of third-party service; the session is saved in the server, and at this time, the request Protocol generally uses a hypertext transfer Protocol (HTTP), extra storage information is introduced, and the storage space of the server is occupied; there is therefore a high demand for real-time and high availability of Web services.
Currently, as shown in fig. 1A, a load balancer is generally adopted to realize high availability of web services between a client and a background server; after the client generates a corresponding web service request according to user operation, the web service request is forwarded to a target server with an uncongested link in the server cluster through a load balancer, the target server responds to the web service request at this time, and a response result is returned to the client through the load balancer; the horizontal expansion of the web services corresponding to the background servers is realized through the server cluster, and when a certain background server fails, the failed background server can be deleted from the server cluster, so that the high-availability and extensible web services are realized; meanwhile, web service requests of the terminal are forwarded through the main load balancer and the standby load balancer, and when the main load balancer breaks down, the standby load balancer can be automatically switched to respond to corresponding web services.
The existing web service system is formed by respectively establishing connection between a plurality of load balancers and a server cluster, is relatively complex and has high operation and maintenance cost, and meanwhile, a client communicates with a background server through the load balancers, so that a web service request is required to carry some extra information irrelevant to the request, bandwidth and server resources are wasted, and response data are difficult to manage and maintain.
Disclosure of Invention
Embodiments of the present invention provide a data communication method, apparatus, device, and storage medium, to solve the problems of complex system architecture and high operation and maintenance cost in the prior art, simplify the communication process, and improve the communication efficiency between a client and a background server.
In a first aspect, an embodiment of the present invention provides a data communication method, where the method includes:
sending a communication request to a central node;
acquiring an identifier of a target server fed back by a central node, wherein the identifier of the target server is selected from identifiers of background servers prestored locally by the central node;
and establishing communication connection with the target server according to the identification of the target server.
In a second aspect, an embodiment of the present invention provides a data communication method, where the method includes:
receiving a communication request sent by a client;
selecting the identification of a target server from the identifications of background servers prestored locally according to the communication request;
and feeding back the identification of the target server to the client so that the client establishes communication connection with the target server according to the identification of the target server.
In a third aspect, an embodiment of the present invention provides a data communication apparatus, including:
the communication request sending module is used for sending a communication request to the central node;
the target identification acquisition module is used for acquiring the identification of the target server fed back by the central node, and the identification of the target server is selected from the identifications of the background servers prestored locally by the central node;
and the communication connection establishing module is used for establishing communication connection with the target server according to the identification of the target server.
In a fourth aspect, an embodiment of the present invention provides a data communication apparatus, including:
the communication request receiving module is used for receiving a communication request sent by a client;
the target identification selection module is used for selecting the identification of the target server from the identifications of the background servers prestored locally according to the communication request;
and the target identification feedback module is used for feeding back the identification of the target server to the client so that the client establishes communication connection with the target server according to the identification of the target server.
In a fifth aspect, an embodiment of the present invention provides a data communication system, where the system includes: the system comprises a client, a central node and a server cluster; the client is configured with the data communication device according to the third aspect, the central node is configured with the data communication device according to the fourth aspect, the server cluster includes at least one background server, and the background server is configured to send a registration request to the central node.
In a sixth aspect, an embodiment of the present invention provides an apparatus, where the apparatus includes:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a data communication method as described in the first aspect or the second aspect.
In a seventh aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the data communication method according to the first aspect or the second aspect.
The embodiment of the invention provides a data communication method, a device, equipment and a storage medium, by sending a communication request to a central node, the central node selects the identification of a target server from the identifications of background servers prestored locally, therefore, the communication connection between the client and the target server is established according to the identification of the target server, the identifications of the background servers are prestored by one central node, and a plurality of load balancers are not required to be respectively connected with the background servers, so that the problems of complex system architecture and high operation and maintenance cost in the prior art are solved, the communication connection is directly established between the client and the target server, the forwarding of communication data through the central node is not required, and extra information is not required to be carried in the communication process, the communication process is simplified, the waste of communication bandwidth and resources is reduced, and the communication efficiency between the client and the background servers is improved.
Drawings
Other features, objects and advantages of the invention will become more apparent upon reading of the detailed description of non-limiting embodiments made with reference to the following drawings:
fig. 1A is a scene architecture diagram of a data communication system provided in the prior art;
fig. 1B is a schematic diagram of an architecture of a data communication system according to an embodiment of the present invention;
fig. 2A is a flowchart of a data communication method according to an embodiment of the present invention;
fig. 2B is a schematic diagram of a data communication process according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a data communication process according to a second embodiment of the present invention;
fig. 4A is a flowchart of a data communication method according to a third embodiment of the present invention;
fig. 4B is a schematic diagram of a data communication process according to a third embodiment of the present invention;
fig. 5 is a schematic diagram of a data communication process according to a fourth embodiment of the present invention;
fig. 6 is a flowchart of a data communication method according to a fifth embodiment of the present invention;
fig. 7 is a schematic structural diagram of a data communication device according to a sixth embodiment of the present invention;
fig. 8 is a schematic structural diagram of a data communication device according to a seventh embodiment of the present invention;
fig. 9 is a schematic structural diagram of an apparatus according to an eighth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures. In addition, the embodiments and features of the embodiments in the present invention may be combined with each other without conflict.
In order to meet the high-speed business requirements in data communication, the data communication service is required to meet the following principles: 1) flexible horizontal extension; 2) high availability of fail-over; 3) timeliness of data communication. Therefore, the embodiment of the invention provides a real-time high-availability data communication method, wherein the central node stores the identifier of the background server in advance, and when data communication is executed, the client firstly acquires the identifier of the target server selected by the central node, so that the communication connection with the target server is directly established according to the identifier of the target server, the subsequent data communication process is realized, the communication process is simplified, and the communication efficiency between the client and the background server is improved.
Fig. 1B is a schematic diagram of an architecture of a data communication system according to an embodiment of the present invention. Specifically, as shown in fig. 1B, the data communication system includes: client 10, central node 20, and server cluster 30.
The Client 10 may be a Client that deploys a corresponding software application in a software architecture system adopting a Client/Server (C/S) structure, and is mainly used for submitting service data of the user to a corresponding Server, so as to obtain corresponding response data; the central node 20 is a service node capable of selecting a target server performing the communication with the client 10 from a large number of available background servers, and is pre-stored with an identifier of the currently available background server; the server cluster 30 includes at least one background server, the background server initiates a registration request to the central node 20, so as to record the identifier of each background server into the central node 20, and the central node 20 detects the availability of each background server in real time, after a certain background server fails, the central node 20 can cancel the pre-stored identifier of the failed background server, so as to ensure high availability of the data communication service, and meanwhile, the available background servers are added in the server cluster 30, so as to implement horizontal extension of the service.
It should be noted that, in this embodiment, the number of the clients 10 may be specifically determined according to the number of devices capable of establishing wireless connection with the server 30 to perform data communication, which is not limited to this, and meanwhile, the clients 10 and the central node 20 in this embodiment may respectively execute the data communication methods corresponding to the following embodiments, and a specific execution process is further described in the following data communication methods, which is not described in detail herein.
Example one
Fig. 2A is a flowchart of a data communication method according to an embodiment of the present invention. The embodiment can be applied to any client terminal with data communication service with the background server. The technical scheme in the embodiment of the invention can be suitable for the situation of realizing high availability of data communication between the client and the background server. The data communication method provided by this embodiment may be performed by a data communication device applied to a client according to an embodiment of the present invention, where the data communication device may be implemented by software and/or hardware, and is integrated in a client executing the method, where the client may be any software application configured to enable data communication with a backend server.
Specifically, referring to fig. 2A, the method may include the steps of:
s210, a communication request is sent to the central node.
The central node is a service node which can realize the automatic detection of the availability of the background server by the back end during data communication, and is responsible for storing and managing state data in the data communication service and judging the availability of the background server according to the change of the state data; the communication request is instruction information automatically generated by the client when detecting that the client has an interaction requirement for data communication with the background server, and is used for indicating that the client needs to perform data interaction with the background server at present; for example, the client may detect whether the client currently has an interaction requirement for data communication with the background server by acquiring operation information with a corresponding interaction requirement, where the operation information is acted by the user at the client. The data communication in this embodiment may be communication services in various application scenarios, such as a login service, an information search service, or an information push service of a user in a certain application program, and the specific communication service is not limited in this embodiment.
Optionally, when detecting that the client needs to perform data communication with the background server, a communication request corresponding to the data communication is obtained, where the communication request is used to indicate that the client currently needs to perform data communication with the background server; at this time, in order to determine which specific background server in the server cluster the client needs to perform the data communication service, the communication request may be sent to the central node, and the central node determines specific information of the background server executing the data communication service, so as to implement a subsequent data communication process. In this embodiment, horizontal extension of the service can be realized by adding a corresponding available background server in the server cluster.
In addition, the central node in this embodiment may be a distributed system, and is configured by a master server and a slave server, when the master server fails, a certain slave server may be directly converted into the master server to continue to execute the corresponding function of the central node, so as to ensure high availability of the central node, and at this time, the distributed system may autonomously implement the failover of the central node, and it is not necessary to connect all the load balancers to the background servers in the server cluster, and only a single central node is directly connected to the background servers in the server cluster, thereby simplifying the system architecture and reducing the operation and maintenance cost. For example, the central node in this embodiment may be a Zookeeper service system, which is a distributed-based coordination service system of a distributed application program with an open source code, and is mainly used for configuration synchronization and coordination under distributed application, and providing functions such as unified configuration service, unified naming service, distributed synchronization, cluster management, and the like; specifically, from the perspective of a design mode, the Zookeeper service system is a distributed service management framework designed based on an observer mode, and is responsible for storing and managing important state detection data, and then receiving registration information of a background server, and once the state of the registration data changes, the Zookeeper service system is responsible for notifying the background server which has been registered on the Zookeeper to make a corresponding reaction, so that high availability and expandability of the background server are realized.
S220, acquiring the identification of the target server fed back by the central node, wherein the identification of the target server is selected from the identifications of the background servers prestored locally by the central node.
The target server is a background server in the server cluster for realizing the data communication of the client, the central node stores the identification of each available background server in the server cluster in advance, and when the central node detects that a certain background server in the server cluster fails, the central node can cancel the identification of the failed background server and remove the failed background server from the server cluster. Specifically, the identifier of the background server refers to data that can uniquely and clearly represent the identity information of each background server in all the background servers; for example, in this embodiment, the identifier of the backend server may be address information of the backend server.
Optionally, after sending the communication request to the central node, as shown in fig. 2B, when the central node receives the communication request, it may be determined that the client currently needs to perform data communication with the background server, at this time, the central node may select, from the identifiers of the background servers pre-stored locally, an identifier of a target server currently performing the data communication with the client, at this time, since the central node may detect the availability of the background server in real time, and when the background server fails, it may log out information of the failed background server, so that the identifiers of the background servers pre-stored locally by the central node are all identifiers of the available background servers; at this time, the central node feeds back the selected identification of the target server to the corresponding client according to the received communication request, the client receives the identification of the target server fed back by the central node, and then establishes corresponding communication connection according to the identification of the target server, so as to realize the subsequent data communication process.
In addition, when the central node selects the identifier of the target server from the identifiers of the background servers, the data execution efficiency of each background server may be determined first, and the background server with high execution efficiency and less occupied communication channel is used as the target server, so that the communication efficiency between the target server and the client is ensured.
And S230, establishing communication connection with the target server according to the identification of the target server.
Specifically, after the client acquires the identifier of the target server fed back by the central node, the client can know the specific information of the background server performing the data communication with the client, at this time, communication connection is directly established between the client and the target server in the server cluster according to the identifier of the target server, and the data communication process between the client and the target server is realized according to the communication connection established this time.
Optionally, the communication connection established this time between the client and the target server is a long connection, where the long connection refers to that when both communication parties perform data interaction, multiple data packets may be continuously sent on the connection, and during the connection holding period, if no data packet is sent, both communication parties need to send corresponding link detection packets, unlike a short connection that is disconnected after the data packet is sent, the long connection may continuously complete multiple data interactions, so as to implement instant communication between the client and the background server, avoid the problems that additional information occupies bandwidth and server resources when data interaction is performed in a polling manner in the prior art, and avoid the problems that a returned data sequence is not guaranteed and management and maintenance are difficult due to a long polling manner, thereby improving the real-time performance and accuracy of data communication.
According to the technical scheme provided by the embodiment, the communication request is sent to the central node, the identification of the target server is selected from the identifications of the background servers prestored locally by the central node, so that the communication connection between the client and the target server is established according to the identification of the target server, the identifications of a plurality of background servers are prestored by one central node, a plurality of load balancers are not required to be respectively connected with the background servers, the problems of complex system architecture and high operation and maintenance cost in the prior art are solved, the communication connection is directly established between the client and the target server, the forwarding of communication data is not required to be carried out through the central node, extra information is not required to be carried in the communication process, the communication process is simplified, the waste of communication bandwidth and resources is reduced, and the communication efficiency between the client and the background servers is improved.
Example two
Fig. 3 is a schematic diagram of a data communication process according to a second embodiment of the present invention. The embodiment is optimized on the basis of the embodiment. Specifically, the present embodiment mainly explains the communication connection established between the client and the target server in detail.
Optionally, this embodiment may specifically include the following steps:
s310, a communication request is sent to the central node.
And S320, acquiring the identification of the target server fed back by the central node, wherein the identification of the target server is selected from the identifications of the background servers prestored locally by the central node.
And S330, establishing communication connection with the target server by adopting a websocket communication protocol according to the identification of the target server.
The websocket communication protocol is a two-way communication protocol capable of realizing data communication between a client and a background server, after communication connection is established, the client and the background server can both actively send or receive data to each other, the websocket communication protocol needs to be established by means of a hypertext transfer protocol (HTTP), and after the communication connection is established, the two-way communication of persistent connection does not need to be established by means of the HTTP.
Optionally, in this embodiment, after obtaining the identifier of the target server fed back by the central node, a communication connection between the client and the target server may be established by using a pre-designed websocket communication protocol according to the identifier of the target server, so as to execute a corresponding data communication process.
S340, sending or receiving corresponding service data through the communication connection.
Specifically, after the client establishes a communication connection with the target server, a corresponding communication connection channel between the client and the target server is generated, and when a specific communication service is executed, corresponding service data may be sent or received through the communication connection. The service data is related data corresponding to a specific service business, and may include login data related to a login service of a user in a certain application program, a search request and a search result related to an information search service, or a pushed video or a pushed news related to an information push service. Optionally, in this embodiment, corresponding service data may be generated according to various service operations executed by the user on the client, and the client sends the service data to the target server through the established communication connection, or when the target server generates new service data, the new service data may be directly fed back to the corresponding client through the established communication connection, so as to implement data communication between the client and the target server.
In addition, the service data in this embodiment mainly aims at web services in data communication, and at this time, a weblinkd service process is correspondingly configured in the background server, and the weblinkd service process is mainly used for processing serial service such as login and registration.
According to the technical scheme provided by the embodiment, the communication connection between the client and the target server is established by adopting a websocket communication protocol, so that both the client and the target server can actively send communication data to each other, the real-time performance of data communication is improved, the communication process is simplified, and the communication efficiency between the client and the background server is improved.
EXAMPLE III
Fig. 4A is a flowchart of a data communication method according to a third embodiment of the present invention. The present embodiment is applicable to any kind of central node that determines a target server for data communication with a client. The technical scheme in the embodiment of the invention can be suitable for the situation of realizing high availability of data communication between the client and the background server. The data communication method provided by this embodiment may be executed by the data communication apparatus applied to the central node provided by this embodiment of the present invention, and the apparatus may be implemented by software and/or hardware and integrated in the central node executing this method.
Specifically, referring to fig. 4A, the method may include the steps of:
s410, receiving a communication request sent by the client.
The client is a client which has a data communication requirement with the background server and is deployed with a corresponding software application program, and is mainly used for submitting service data of a user to the corresponding server so as to acquire corresponding response data; the communication request refers to instruction information automatically generated by the client when detecting that the client has an interaction requirement for data communication with the background server, and is used for indicating that the client needs to perform data interaction with the background server currently.
Optionally, when an interaction requirement that data communication needs to be performed with the background server exists in the client, a corresponding communication request may be generated, at this time, in order to determine which background server in the server cluster the background server implementing the data communication is specifically, the client may send the communication request to the center node, the center node may receive the communication request sent by the client, and subsequently, according to the communication request, the target server of the data communication is determined in the server cluster.
Optionally, in this embodiment, when receiving the communication request of the client, because the external interface developed on the central node may not support the communication service of the client, receiving the communication request sent by the client may specifically include: and receiving a communication request sent by the client through a preset service component.
Specifically, the service component is a component capable of discovering a specific service, and if the data communication service in this embodiment is a web service, the service component is a webLbs component and is mainly used to obtain the backend corresponding weblinkd service process information. At this time, a corresponding service component may be configured on the central node, and when the client sends a communication request, as shown in fig. 4B, the central node may receive the communication request through the service component set thereon, so as to subsequently obtain the identifier of the target server.
And S420, selecting the identification of the target server from the identifications of the background servers prestored locally according to the communication request.
The target server is a background server in the server cluster for realizing the data communication of the client, the central node stores the identification of each available background server in the server cluster in advance, and when the central node detects that a certain background server in the server cluster fails, the central node can cancel the identification of the failed background server and remove the failed background server from the server cluster. Specifically, the identifier of the background server refers to data that can uniquely and clearly represent the identity information of each background server in all the background servers; for example, in this embodiment, the identifier of the backend server may be address information of the backend server.
Optionally, when receiving a communication request sent by a client, a central node may determine that the client currently needs to perform data communication with a background server, and at this time, the central node may select an identifier of a target server currently performing the data communication with the client from identifiers of the background servers pre-stored locally, and at this time, since the central node may detect availability of the background server in real time, when the background server fails, information of the failed background server may be cancelled, so that the identifiers of the background servers pre-stored locally by the central node are all identifiers of the available background servers; the identifier of the target server can be fed back to the corresponding client side subsequently, so that the client side and the target server establish corresponding communication connection, and a data communication process is realized.
In addition, when the central node selects the identifier of the target server from the identifiers of the background servers, the data execution efficiency of each background server may be determined first, and the background server with high execution efficiency and less occupied communication channel is used as the target server, so that the communication efficiency between the target server and the client is ensured.
Optionally, because the external interface developed on the central node may not support the communication service of the client, at this time, the identifier of the target server is selected from the identifiers of the background servers prestored locally according to the communication request, which may specifically include: and selecting the identification of the target server from the identifications of the background servers prestored locally through the service component.
Specifically, in this embodiment, if the communication request sent by the client is received through the preset service component, at this time, the identifier of the target server may be directly selected from the identifiers of the background servers prestored in the local through the service component, and the identifier of the target server is subsequently fed back to the corresponding client, so as to implement the communication service between the central node and the client.
S430, feeding back the identification of the target server to the client, so that the client establishes communication connection with the target server according to the identification of the target server.
Specifically, after the central node selects the identifier of the target server from the identifiers of the background servers prestored locally, in order to implement data communication between the client and the target server, the central node may further feed back the selected identifier of the target server to the corresponding client, so that the client establishes communication connection with the target server according to the identifier of the target server. Wherein the communication connection may be a long connection in order to improve the real-time performance of subsequent data communication.
Optionally, in this embodiment, in order to improve the efficiency of data communication, the feeding back the identifier of the target server to the client may specifically include: selecting a communication channel between the client and the client through a load balancing algorithm; and feeding back the identification of the target server to the client through the selected communication channel.
Specifically, when the identifier of the target server is fed back to the client, a non-congested communication channel can be selected from communication channels between the central node and the client according to a load balancing algorithm, and the identifier of the target server is fed back to the client through the selected communication channel, so that the communication efficiency is improved.
According to the technical scheme provided by the embodiment, the central node selects the identification of the target server from the identifications of the background servers prestored locally, so that the communication connection between the client and the target server is established according to the identification of the target server, the identifications of the plurality of background servers are prestored by the central node, and a plurality of load balancers are not required to be respectively connected with the background servers.
Example four
Fig. 5 is a schematic diagram of a data communication process according to a fourth embodiment of the present invention. The embodiment is optimized on the basis of the embodiment. Specifically, this embodiment mainly explains in detail a specific process of the central node detecting the availability of the background server in the server cluster.
Optionally, this embodiment may specifically include the following steps:
s510, receiving a registration request sent by the background server.
Wherein the registration request includes an identification of the backend server. Specifically, the registration request is used to indicate that a background server is newly added in the server cluster, and the background server can also implement data communication with the corresponding client. Specifically, when each background server in the server cluster can be used for data communication with the client, the corresponding registration request is actively sent to the central node, the central node receives the registration request of the background server, and it is determined that the background server for realizing the data communication is newly added in the server cluster, so as to store the identifier of the background server later.
Optionally, as the user amount of the communication service increases, the number of the background servers needs to be correspondingly extended, in this embodiment, a new background server may be added in the server cluster, and the new background server actively sends a corresponding registration request to the central node, so that horizontal extension of the background server is achieved, and the scheme has strong horizontal extensibility.
And S520, locally storing the identifier of the background server according to the registration request.
Specifically, when receiving a registration request of a background server, the central node locally records the identifier of the background server, so as to select a corresponding target server for the client according to a communication request of the client in the following, that is, locally stores the identifier of each background server according to the registration request of each background server in the server cluster.
S530, sending a verification request to the corresponding background server according to the identifier of the background server.
Optionally, in order to improve the effectiveness of data communication, in this embodiment, it is further required to detect the availability of each background server in the server cluster, at this time, the central node may send a corresponding check request to each background server according to an identifier of the locally pre-stored background server, where the check request includes request information that requires the background server to perform feedback, and is used to check the availability of each background server in the server cluster.
S540, judging whether check data fed back by the background server is received or not; if yes, go to S550; if not, go to S560.
Optionally, after sending the verification request to each background server in the server cluster, the central node needs to determine the availability of the corresponding background server according to whether the feedback verification data can be received.
And S550, the corresponding background server passes the verification.
Specifically, if the central node receives the check data fed back by the background server, it indicates that the background server is currently valid, and the corresponding data communication function can be realized, so that it is determined that the background server passes the check, that is, the background server is currently available.
And S560, deleting the locally stored identification of the corresponding background server.
Specifically, if the central node does not receive the check data fed back by the background server, it indicates that the background server has a certain fault, which results in current unavailability and a corresponding data communication function cannot be realized, so that the central node needs to delete the identifier of the failed background server from the locally pre-stored identifiers of the background servers, thereby avoiding that the subsequent central node feeds back the identifier of the failed background server as the identifier of the target server to the corresponding client, so that the data communication between the client and the target server fails, and improving the high availability of data communication.
S570, receiving the communication request sent by the client.
It should be noted that, in this embodiment, the checking process for the background server between S530 to S560 may be performed by sending a communication request to the central node at the client, so that the data communication process between the client and the target server is performed simultaneously, and there is no sequential execution order
And S580, selecting the identification of the target server from the identifications of the background servers prestored locally according to the communication request.
And S590, feeding back the identifier of the target server to the client, so that the client establishes communication connection with the target server according to the identifier of the target server.
According to the technical scheme provided by the embodiment, the central node sends the check request to the corresponding background server according to the identification of the background server prestored locally, detects the availability of each background server in the server cluster in real time according to whether the feedback check data is received, and deletes the failed background server locally, so that the high availability of the data communication service is ensured.
EXAMPLE five
Fig. 6 is a flowchart of a data communication method according to a fifth embodiment of the present invention. The embodiment is optimized on the basis of the embodiment. Specifically, this embodiment mainly explains in detail a data interaction process between the client, the central node, and the background server in the server cluster.
Specifically, as shown in fig. 6, the present embodiment may include the following steps:
s601, the background server sends a registration request to the central node.
And S602, the central node locally stores the identifier of the background server according to the registration request.
S603, the central node sends a check request to the background server.
S604, if the central node does not receive the check data fed back by the background server, deleting the locally stored identifier of the corresponding background server.
S605, the client sends a communication request to the central node.
And S606, the central node selects the identification of the target server from the identifications of the background servers prestored locally according to the communication request.
S607, the central node feeds back the identification of the target server to the client.
S608, the client establishes communication connection with the target server according to the identification of the target server.
According to the technical scheme provided by the embodiment, the communication request is sent to the central node, the identification of the target server is selected from the identifications of the background servers prestored locally by the central node, so that the communication connection between the client and the target server is established according to the identification of the target server, the identifications of a plurality of background servers are prestored by one central node, a plurality of load balancers are not required to be respectively connected with the background servers, the problems of complex system architecture and high operation and maintenance cost in the prior art are solved, the communication connection is directly established between the client and the target server, the forwarding of communication data is not required to be carried out through the central node, extra information is not required to be carried in the communication process, the communication process is simplified, the waste of communication bandwidth and resources is reduced, and the communication efficiency between the client and the background servers is improved.
EXAMPLE six
Fig. 7 is a schematic structural diagram of a data communication device according to a sixth embodiment of the present invention, specifically, as shown in fig. 7, the data communication device may include:
a communication request sending module 710, configured to send a communication request to a central node;
a target identifier obtaining module 720, configured to obtain an identifier of the target server fed back by the central node, where the identifier of the target server is selected from identifiers of background servers pre-stored locally by the central node;
a communication connection establishing module 730, configured to establish a communication connection with the target server according to the identifier of the target server.
According to the technical scheme provided by the embodiment, the communication request is sent to the central node, the identification of the target server is selected from the identifications of the background servers prestored locally by the central node, so that the communication connection between the client and the target server is established according to the identification of the target server, the identifications of a plurality of background servers are prestored by one central node, a plurality of load balancers are not required to be respectively connected with the background servers, the problems of complex system architecture and high operation and maintenance cost in the prior art are solved, the communication connection is directly established between the client and the target server, the forwarding of communication data is not required to be carried out through the central node, extra information is not required to be carried in the communication process, the communication process is simplified, the waste of communication bandwidth and resources is reduced, and the communication efficiency between the client and the background servers is improved.
Further, the communication connection establishing module 730 may be specifically configured to:
and establishing communication connection with the target server by adopting a websocket communication protocol according to the identification of the target server.
Further, the communication connection is a long connection.
Further, the data communication apparatus may further include:
and the service data interaction module is used for sending or receiving corresponding service data through the communication connection after the communication connection with the target server is established according to the identification of the target server.
Further, the central node is a distributed system.
The data communication device provided by the embodiment can be applied to the data communication method applied to the client terminal provided by any embodiment, and has corresponding functions and beneficial effects.
EXAMPLE seven
Fig. 8 is a schematic structural diagram of a data communication device according to a seventh embodiment of the present invention, specifically, as shown in fig. 8, the data communication device may include:
a communication request receiving module 810, configured to receive a communication request sent by a client;
a target identifier selecting module 820, configured to select an identifier of a target server from identifiers of background servers prestored locally according to the communication request;
and a target identifier feedback module 830, configured to feed back the identifier of the target server to the client, so that the client establishes a communication connection with the target server according to the identifier of the target server.
According to the technical scheme provided by the embodiment, the central node selects the identification of the target server from the identifications of the background servers prestored locally, so that the communication connection between the client and the target server is established according to the identification of the target server, the identifications of the plurality of background servers are prestored by the central node, and a plurality of load balancers are not required to be respectively connected with the background servers.
Further, the data communication apparatus may further include:
the system comprises a registration request receiving module, a registration request receiving module and a registration request sending module, wherein the registration request receiving module is used for receiving a registration request sent by a background server, and the registration request comprises an identifier of the background server;
and the identification storage module is used for locally storing the identification of the background server according to the registration request.
Further, the data communication apparatus may further include:
the verification request sending module is used for sending a verification request to the corresponding background server according to the identifier of the background server;
and the verification passing module is used for passing the verification of the corresponding background server if the verification data fed back by the background server is received.
Further, the data communication apparatus may further include:
and the identification deleting module is used for deleting the locally stored identification of the corresponding background server if the verification data fed back by the background server is not received.
Further, the communication request receiving module 810 may specifically be configured to:
receiving a communication request sent by a client through a preset service component;
correspondingly, the target identifier selecting module 820 may be specifically configured to:
and selecting the identification of the target server from the identifications of the background servers prestored locally through the service component.
Further, the target identifier feedback module 830 may be specifically configured to:
selecting a communication channel between the client and the client through a load balancing algorithm;
and feeding back the identification of the target server to the client through the selected communication channel.
The data communication device provided by the embodiment can be applied to the data communication method applied to the central node provided by any embodiment, and has corresponding functions and beneficial effects.
Example eight
Fig. 9 is a schematic structural diagram of an apparatus according to an eighth embodiment of the present invention, as shown in fig. 9, the apparatus includes a processor 90, a storage device 91, and a communication device 92; the number of processors 90 in the device may be one or more, and one processor 90 is taken as an example in fig. 9; the processor 90, the storage means 91 and the communication means 92 in the device may be connected by a bus or other means, as exemplified by the bus connection in fig. 9.
The storage device 91 is a computer-readable storage medium, and can be used for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the data communication method according to any embodiment of the present invention. The processor 90 executes various functional applications of the apparatus and data processing by executing software programs, instructions, and modules stored in the storage device 91, that is, implements the above-described data communication method.
The storage device 91 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the storage 91 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the storage 91 may further include memory located remotely from the processor 90, which may be connected to the device over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The communication device 92 may be used to implement a network connection or a mobile data connection between the client, the central node, and the backend server.
The device provided by the embodiment can be used for executing the data communication method provided by any embodiment, and has corresponding functions and beneficial effects.
Example nine
Ninth, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program can implement the data communication method in any of the above embodiments. The method specifically comprises the following steps: sending a communication request to a central node; acquiring an identifier of a target server fed back by a central node, wherein the identifier of the target server is selected from identifiers of background servers prestored locally by the central node; and establishing communication connection with the target server according to the identification of the target server. Or,
receiving a communication request sent by a client; selecting an identification of a target server from identifications of background servers prestored locally according to the communication request; and feeding back the identification of the target server to the client so that the client establishes communication connection with the target server according to the identification of the target server.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the operations of the method described above, and may also perform related operations in the data communication method provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the data communication apparatus, the included units and modules are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (16)
1. A method of data communication, comprising:
sending a communication request to a central node;
acquiring an identifier of a target server fed back by a central node, wherein the identifier of the target server is selected from identifiers of background servers prestored locally by the central node;
and establishing communication connection with the target server according to the identification of the target server.
2. The method of claim 1, wherein the establishing a communication connection with the target server according to the identification of the target server comprises:
and establishing communication connection with the target server by adopting a websocket communication protocol according to the identification of the target server.
3. The method of claim 1, wherein the communication connection is a long connection.
4. The method of claim 2, further comprising, after establishing a communication connection with the target server based on the identification of the target server:
and sending or receiving corresponding service data through the communication connection.
5. The method of claim 1, wherein the central node is a distributed system.
6. A method of data communication, comprising:
receiving a communication request sent by a client;
selecting the identification of a target server from the identifications of background servers prestored locally according to the communication request;
and feeding back the identification of the target server to the client so that the client establishes communication connection with the target server according to the identification of the target server.
7. The method of claim 6, further comprising, before obtaining the communication request sent by the client:
receiving a registration request sent by a background server, wherein the registration request comprises an identifier of the background server;
and locally storing the identifier of the background server according to the registration request.
8. The method of claim 7, further comprising, after locally storing the identity of the backend server according to the registration request:
sending a verification request to a corresponding background server according to the identifier of the background server;
and if the verification data fed back by the background server is received, the corresponding background server passes the verification.
9. The method of claim 8, further comprising:
and if the verification data fed back by the background server is not received, deleting the locally stored identification of the corresponding background server.
10. The method of claim 6, wherein receiving a communication request sent by a client comprises:
receiving a communication request sent by a client through a preset service component;
correspondingly, selecting the identifier of the target server from the locally pre-stored identifiers of the background server according to the communication request, including:
and selecting the identification of the target server from the identifications of the background servers prestored locally through the service component.
11. The method of claim 6, wherein feeding back the identification of the target server to the client comprises:
selecting a communication channel between the client and the client through a load balancing algorithm;
and feeding back the identification of the target server to the client through the selected communication channel.
12. A data communication apparatus, comprising:
the communication request sending module is used for sending a communication request to the central node;
the target identification acquisition module is used for acquiring the identification of the target server fed back by the central node, and the identification of the target server is selected from the identifications of the background servers prestored locally by the central node;
and the communication connection establishing module is used for establishing communication connection with the target server according to the identification of the target server.
13. A data communication apparatus, comprising:
the communication request receiving module is used for receiving a communication request sent by a client;
the target identification selection module is used for selecting the identification of the target server from the identifications of the background servers prestored locally according to the communication request;
and the target identification feedback module is used for feeding back the identification of the target server to the client so that the client establishes communication connection with the target server according to the identification of the target server.
14. A data communication system, comprising: the system comprises a client, a central node and a server cluster; the client is configured with the data communication apparatus according to claim 12, the central node is configured with the data communication apparatus according to claim 13, the server cluster includes at least one background server, and the background server is configured to send a registration request to the central node.
15. An apparatus, characterized in that the apparatus comprises:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a data communication method as claimed in any one of claims 1-11.
16. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the data communication method according to any one of claims 1 to 11.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811627369.XA CN111385324A (en) | 2018-12-28 | 2018-12-28 | Data communication method, device, equipment and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811627369.XA CN111385324A (en) | 2018-12-28 | 2018-12-28 | Data communication method, device, equipment and storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN111385324A true CN111385324A (en) | 2020-07-07 |
Family
ID=71218176
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201811627369.XA Pending CN111385324A (en) | 2018-12-28 | 2018-12-28 | Data communication method, device, equipment and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111385324A (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114327295A (en) * | 2021-12-31 | 2022-04-12 | 华云数据控股集团有限公司 | Distributed data access method and system |
| CN114598704A (en) * | 2022-03-16 | 2022-06-07 | 浪潮云信息技术股份公司 | TCP connection fault tolerance method based on four-layer load balancing cluster |
| CN116915541A (en) * | 2023-07-24 | 2023-10-20 | 亿咖通(湖北)技术有限公司 | A communication method, device, equipment and medium based on distributed soft bus |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8095687B1 (en) * | 2001-03-26 | 2012-01-10 | Microsoft Corporation | Systems and methods for managing state in a cluster of servers |
| CN103731365A (en) * | 2012-10-16 | 2014-04-16 | 无锡云捷科技有限公司 | Bottleneck-free load balancing network server system and establishment method thereof |
| CN104079630A (en) * | 2014-06-09 | 2014-10-01 | 中国建设银行股份有限公司 | Business server side load balancing method, client side, server side and system |
| CN106657354A (en) * | 2016-12-29 | 2017-05-10 | 努比亚技术有限公司 | Load balancing device and method |
| CN106657287A (en) * | 2016-11-30 | 2017-05-10 | 广州市千钧网络科技有限公司 | Data access method and system |
| CN106713378A (en) * | 2015-07-30 | 2017-05-24 | 北京京东尚科信息技术有限公司 | Method and system for realizing service provision by multiple application servers |
-
2018
- 2018-12-28 CN CN201811627369.XA patent/CN111385324A/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8095687B1 (en) * | 2001-03-26 | 2012-01-10 | Microsoft Corporation | Systems and methods for managing state in a cluster of servers |
| CN103731365A (en) * | 2012-10-16 | 2014-04-16 | 无锡云捷科技有限公司 | Bottleneck-free load balancing network server system and establishment method thereof |
| CN104079630A (en) * | 2014-06-09 | 2014-10-01 | 中国建设银行股份有限公司 | Business server side load balancing method, client side, server side and system |
| CN106713378A (en) * | 2015-07-30 | 2017-05-24 | 北京京东尚科信息技术有限公司 | Method and system for realizing service provision by multiple application servers |
| CN106657287A (en) * | 2016-11-30 | 2017-05-10 | 广州市千钧网络科技有限公司 | Data access method and system |
| CN106657354A (en) * | 2016-12-29 | 2017-05-10 | 努比亚技术有限公司 | Load balancing device and method |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114327295A (en) * | 2021-12-31 | 2022-04-12 | 华云数据控股集团有限公司 | Distributed data access method and system |
| CN114327295B (en) * | 2021-12-31 | 2024-11-05 | 华云数据控股集团有限公司 | Distributed data access method and system |
| CN114598704A (en) * | 2022-03-16 | 2022-06-07 | 浪潮云信息技术股份公司 | TCP connection fault tolerance method based on four-layer load balancing cluster |
| CN114598704B (en) * | 2022-03-16 | 2024-05-17 | 浪潮云信息技术股份公司 | TCP connection fault tolerance method based on four-layer load balancing cluster |
| CN116915541A (en) * | 2023-07-24 | 2023-10-20 | 亿咖通(湖北)技术有限公司 | A communication method, device, equipment and medium based on distributed soft bus |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN107465767B (en) | Data synchronization method and system | |
| US10419531B2 (en) | Method for setting gateway device identity, and management gateway device | |
| CN102447624B (en) | Load balancing method in server cluster, as well as node server and cluster | |
| CN104639913B (en) | A kind of network video recorder and its method for automatically accessing IPC | |
| CN109474936B (en) | Internet of things communication method and system applied among multiple lora gateways | |
| JP6549320B2 (en) | Communication device connection method, terminal device, and server system | |
| US20210218590A1 (en) | Virtual Meetings In Ad-Hoc Networks | |
| WO2015101260A1 (en) | Method and system for processing instant communication service | |
| US8942213B2 (en) | Method and system for accessing storage devices | |
| JP2019525604A (en) | Network function NF management method and NF management apparatus | |
| CN101242306A (en) | Method, system, device and server for realizing automatic discovery of network devices | |
| JP5255035B2 (en) | Failover system, storage processing apparatus, and failover control method | |
| CN110971702A (en) | Service calling method and device, computer equipment and storage medium | |
| CN108282846A (en) | A kind of service request processing method and device | |
| CN106572132B (en) | Distributed chain building method, device and system | |
| CN111385324A (en) | Data communication method, device, equipment and storage medium | |
| CN103414641B (en) | Neighbor table item release, device and the network equipment | |
| CN109561004B (en) | Message forwarding method and device and switch | |
| WO2015139633A1 (en) | Data transmission method and apparatus | |
| CN107306289B (en) | A method and device for load balancing based on cloud computing | |
| EP3503484A1 (en) | Message transmission method, device and network system | |
| CN110809033B (en) | Message forwarding method and device and switching server | |
| CN115051970B (en) | Method and device for controlling user to be online, forwarding plane network element and medium | |
| CN108632355B (en) | A home appliance network routing method, control terminal, readable storage medium and device | |
| CN108242982A (en) | A kind of server dual-locomotive heat switching processing system |
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: 20200707 |
|
| RJ01 | Rejection of invention patent application after publication |