CN113923249A - High-performance network long connection establishing method and device - Google Patents

High-performance network long connection establishing method and device Download PDF

Info

Publication number
CN113923249A
CN113923249A CN202111186958.0A CN202111186958A CN113923249A CN 113923249 A CN113923249 A CN 113923249A CN 202111186958 A CN202111186958 A CN 202111186958A CN 113923249 A CN113923249 A CN 113923249A
Authority
CN
China
Prior art keywords
client
long connection
tracker
establishing
standard interface
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
CN202111186958.0A
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
ICBC Technology Co Ltd
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology Co Ltd
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, ICBC Technology Co Ltd filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202111186958.0A priority Critical patent/CN113923249A/en
Publication of CN113923249A publication Critical patent/CN113923249A/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/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • 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
    • 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)
  • Computer And Data Communications (AREA)

Abstract

The application provides a method and a device for establishing long connection of a high-performance network, which relate to the field of communication and can also be used in the field of finance, and the method comprises the following steps: establishing a long connection with a client according to a long connection establishment request of the client; selecting a corresponding tracker from pre-established trackers according to the type of the client, and monitoring the state of the long connection by using the selected tracker; the states include create, disconnect, and run; and sending the message corresponding to the state to the client by utilizing a pre-constructed splitter. The application can provide an open type generalized high-performance network long connection engine to quickly construct a high-availability long connection service.

Description

High-performance network long connection establishing method and device
Technical Field
The application relates to the field of communication, can be used in the field of finance, and particularly relates to a method and a device for establishing long connection of a high-performance network.
Background
The technical scheme of long connection is more favored by developers, the existing long connection technology based on Java language is realized by using a Websocket protocol, a basic long connection service endpoint life cycle management API is provided, developers can establish, use and destroy a long connection service endpoint by packaging the basic API, the long connection service endpoint is matched with the packaging of the clients to realize, and the data sharing requirement of a conventional service end and the clients can be supported. The prior art has the following problems:
1) service endpoints cannot be uniformly managed
The prior art only provides the capabilities of establishing, using, recycling and the like aiming at single connection, and can not directly realize the uniform viewing and scheduling of all online connections.
2) The problems of delay and loss of messages under the high-concurrency scene are obvious
The prior art is realized based on a synchronization mechanism, has no message buffering mechanism, and easily causes the conditions of message delay, blocking, even loss and the like under a high-concurrency scene.
3) Single application cannot support multiple scenes
The prior art can only realize one set of logic aiming at important nodes such as connection establishment, message processing and the like, and can not support the condition that a plurality of long connection services coexist.
4) Can not be compatible with various abnormal conditions
The prior art does not provide a protection mechanism for abnormal conditions such as network disconnection, power failure, client violent operation and the like. Once this occurs, the memory of the server may be idle, causing a system crash.
Disclosure of Invention
Aiming at the problems in the prior art, the application provides a high-performance network long connection establishing method and device, which can provide an open type generalized high-performance network long connection engine to quickly establish a high-availability long connection service.
In order to solve the technical problem, the application provides the following technical scheme:
in a first aspect, the present application provides a method for establishing a long connection in a high performance network, including:
establishing a long connection with a client according to a long connection establishment request of the client;
selecting a corresponding tracker from pre-established trackers according to the type of the client, and monitoring the state of the long connection by using the selected tracker; the states include create, disconnect, and run;
and sending the message corresponding to the state to the client by utilizing a pre-constructed splitter.
Further, the client includes a resource client, and the step of pre-constructing the resource client tracker includes:
establishing a long connection type of the resource client tracker by utilizing an EnumWsType enumeration type;
establishing a standard interface of the resource client tracker by using a method in an IWsProcessor interface;
and establishing the resource client tracker according to the long connection type of the resource client tracker and a standard interface of the resource client tracker.
Further, the method in the iwsProcessor interface includes a whaeddToPool method, a whanremovedFromPool method, and a whanreceivedUpmsg method, and the method in the iwsProcessor interface is used to establish the standard interface of the resource client tracker, including:
establishing a service logic standard interface after the initialization of the long connection corresponding to the resource client tracker by using the whaeddtopool method;
establishing a service logic standard interface after the long connection destruction corresponding to the resource client tracker by using the method of the whanremovedfrompool;
and establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the resource client tracker by using the whorereceivedUpMsg method.
Further, the client includes a service client, and the step of pre-constructing a service client tracker includes:
establishing a long connection type of the service client tracker by utilizing an EnumWsType enumeration type;
establishing a standard interface of the service client tracker by using a method in an IWsProcessor interface;
and establishing the service client tracker according to the long connection type of the service client tracker and a standard interface of the service client tracker.
Further, the method in the iwsProcessor interface includes a whaeddToPool method, a whanremovedFromPool method, and a whanreceivedUpmsg method, and the method in the iwsProcessor interface is used to establish the standard interface of the service client tracker, including:
establishing a service logic standard interface after long connection initialization corresponding to the service client tracker by using the whaeddtopool method;
establishing a service logic standard interface after the long connection destruction corresponding to the service client tracker by using the method of the whanremovedfrompool;
and establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the service client tracker by using the whorereceivedUpMsg method.
Further, the establishing a long connection with the client according to the long connection establishment request of the client includes:
establishing long connection with the client by using a void put method;
binding the relation between the unique identifier uuid of the long connection and the long connection object wsObj;
and binding the matched tracker according to the long connection type of the long connection.
Further, the sending the message corresponding to the state to the client by using the pre-constructed splitter includes:
determining whether a message to be sent is congested, if so, putting the message to be sent into a ring buffer of the splitter;
and sending the message to be sent in the annular buffer area to the client by utilizing a pre-supported memory mechanism and a lock-free concurrent mechanism.
Further, the method for establishing a long connection of a high-performance network further includes:
and monitoring the full life cycle state of the long connection by utilizing a heartbeat mechanism in a pre-constructed connection pool.
In a second aspect, the present application provides a high performance network long connection establishing apparatus, including:
the connection establishing unit is used for establishing long connection with the client according to a long connection establishing request of the client;
the state monitoring unit is used for selecting a corresponding tracker from pre-established trackers according to the type of the client and monitoring the state of the long connection by using the selected tracker; the states include create, disconnect, and run;
and the message sending unit is used for sending the message corresponding to the state to the client by utilizing a pre-constructed splitter.
Further, the client includes a resource client, including:
a connection type determining unit, configured to establish a long connection type of the resource client tracker by using an EnumWsType enumeration type;
the standard interface determining unit is used for establishing a standard interface of the resource client tracker by using a method in an IWsProcessor interface;
and the tracker establishing unit is used for establishing the resource client tracker according to the long connection type of the resource client tracker and the standard interface of the resource client tracker.
Further, the method in the iwsProcessor interface includes a whaeddToPool method, a whanremovedFromPool method, and a whanreceivedUpMsg method, and the standard interface determination unit includes:
a first standard interface determining module, configured to establish a service logic standard interface after long connection initialization corresponding to the resource client tracker by using the whaeddedtopool method;
a second standard interface determining module, configured to establish a service logic standard interface after the long connection destruction corresponding to the resource client tracker by using the whenRemovedFromPool method;
and the third standard interface determining module is used for establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the resource client tracker by using the whenereceivedUpMsg method.
Further, the client includes a business client, including:
a connection type determining unit, configured to establish a long connection type of the service client tracker by using an EnumWsType enumeration type;
the standard interface determining unit is used for establishing a standard interface of the service client tracker by using a method in an IWsProcessor interface;
and the tracker establishing unit is used for establishing the service client tracker according to the long connection type of the service client tracker and the standard interface of the service client tracker.
Further, the method in the iwsProcessor interface includes a whaeddToPool method, a whanremovedFromPool method, and a whanreceivedUpMsg method, and the standard interface determination unit includes:
a first standard interface determining module, configured to establish a service logic standard interface after long connection initialization corresponding to the service client tracker by using the whaeddedtopool method;
a second standard interface determining module, configured to establish a service logic standard interface after the long connection destruction corresponding to the service client tracker by using the whenRemovedFromPool method;
and the third standard interface determining module is used for establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the service client tracker by using the whenereceivedUpMsg method.
Further, the high performance network long connection establishing apparatus, the connection establishing unit, includes:
the connection establishing module is used for establishing long connection with the client by using a void put method;
the relation binding module is used for binding the relation between the unique identifier uuid of the long connection and the long connection object wsObj;
and the tracker matching module is used for binding the matched tracker according to the long link type of the long link.
Further, the message sending unit includes:
the message buffer module is used for determining whether the message to be sent is congested, if so, the message to be sent is placed into a ring buffer area of the splitter;
and the message sending module is used for sending the message to be sent in the annular buffer area to the client by utilizing a pre-supported memory mechanism and a lock-free concurrent mechanism.
Further, the high performance network long connection establishing apparatus further includes:
and the heartbeat monitoring unit is used for monitoring the full life cycle state of the long connection by utilizing a heartbeat mechanism in a pre-constructed connection pool.
In a third aspect, the present application provides 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 high performance network long connection establishment method when executing the program.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the high performance network long connection establishment method.
Aiming at the problems in the prior art, the high-performance network long connection establishing method and device provided by the application can provide an open type universal high-performance network long connection engine through constructing the connection pool, the splitter and the tracker, ensure the unified management of service endpoints and the high concurrency of message distribution, further realize the parallel processing of various long connection scenes, provide a protection mechanism aiming at various abnormal conditions such as power failure, network failure, client violent operation and the like, and have simple access and stable service.
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 described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a high performance network long connection establishment method in an embodiment of the present application;
FIG. 2 is a flowchart illustrating steps for constructing a resource client tracker according to an embodiment of the present application;
FIG. 3 is a flow chart illustrating the establishment of a standard interface for a resource client tracker according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating steps for constructing a business client tracker according to an embodiment of the present application;
FIG. 5 is a flow chart of establishing a standard interface for a service client tracker according to an embodiment of the present application;
FIG. 6 is a flow chart of establishing a long connection in an embodiment of the present application;
FIG. 7 is a flow chart of sending a message to a client in an embodiment of the application;
fig. 8 is one of the structural diagrams of the high performance network long connection establishing apparatus in the embodiment of the present application;
fig. 9 is a second block diagram of a high-performance network long connection setup apparatus according to an embodiment of the present application;
fig. 10 is one of the structural diagrams of a standard interface determining unit in the embodiment of the present application;
fig. 11 is a third structural diagram of a high performance network long connection setup apparatus in an embodiment of the present application;
FIG. 12 is a second block diagram of a standard interface determination unit according to an embodiment of the present invention;
fig. 13 is a structural diagram of a connection establishing unit in the embodiment of the present application;
fig. 14 is a structural diagram of a message sending unit in the embodiment of the present application;
fig. 15 is a schematic structural diagram of an electronic device in an embodiment of the present application;
FIG. 16 is a schematic diagram of an application scenario according to an embodiment of the present application;
fig. 17 is a second exemplary application scenario of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. 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 application.
It should be noted that the high-performance network long connection establishment method and apparatus provided by the present application may be used in the financial field, and may also be used in any field other than the financial field.
In the fields of instant messaging, data monitoring and the like, a client may need to share data of a server in real time. For this purpose, the client can be implemented using both the techniques of timed polling or long connection. Due to the defects of high data sharing delay, high client resource consumption and the like in the timing polling, the long connection technical scheme is more favored by developers. The existing long connection technology based on Java language is realized by using Websocket protocol, can provide basic long connection service endpoint life cycle management API, developers can realize the creation, use and destruction of long connection service endpoints by packaging the basic API, and the long connection service endpoints are matched with clients to realize packaging, thereby supporting the data sharing requirements of conventional servers and clients.
However, the prior art only provides a method for creating, using and recycling a single connection, and cannot realize uniform viewing and scheduling of all online connections. Because the prior art is realized based on a synchronization mechanism and a message buffer mechanism is not set up, the situations of message delay, message blocking, message loss and the like are easily caused in a high concurrency scene. And important nodes such as connection establishment, message processing and the like can only realize single connection logic, cannot support coexistence of multiple connection services, cannot be compatible with various abnormal conditions, and have no complete protection mechanism for abnormal conditions such as network disconnection, power failure, client violent operation and the like. Once this occurs, the memory of the server may be idle, causing a system crash.
Based on the problems existing in the prior art, the present application provides a method for establishing a long connection in a high performance network, see fig. 1. The method can provide an open type generalized high-performance network long connection engine to quickly construct a high-availability long connection service, and specifically comprises the following steps:
s101: establishing a long connection with a client according to a long connection establishment request of the client;
s102: selecting a corresponding tracker from pre-established trackers according to the type of the client, and monitoring the state of long connection by using the selected tracker; the states include creation, disconnection and operation;
s103: and sending the message corresponding to the state to the client by utilizing the pre-constructed splitter.
It is understood that the method provided by the present application can be applied to at least the following scenarios:
the first is that a plurality of service clients need to communicate with each other through a server. Such a scenario may exist in an e-commerce platform, where the service client may be a customer handheld device 1 (e.g., a cell phone) or a merchant desktop device 2 (e.g., a PC). The two require communication with each other via the server 3. The communication takes place in the form of a long connection, see fig. 16.
The second is that one resource client 5 provides resource services to one service client 4. Such scenarios tend to have a large amount of computation and information interaction performed. For example, the service client 4 may be a financial institution that needs to perform a large amount of data calculation, and the resource client 5 may be a data calculation center with high calculation power. In this scenario, a financial institution may initiate a computing service request to a data computing center. In this process, the server 6 needs to help establish a long connection between the two so that the data computing center can provide stable computing services to the financial institution, see fig. 17.
It should be noted that the above scenarios are only for understanding the solution described in the present application, and the application scenarios of the solution described in the present application are not limited thereto.
The execution subject of the method described herein may be a server. When the server receives a long connection establishment request sent by the client, the server establishes a long connection with the client. In particular, the method is realized by the connecting pool provided by the method, and the details are explained in the following. Each client establishes long connection with the server, which is equivalent to that the clients realize long connection and communication with each other. The types of the clients in the method at least relate to business clients and resource clients. Because different types of clients correspond to different types of trackers, a corresponding tracker needs to be selected from the trackers created in advance according to the types of the clients, and the selected tracker is used for monitoring the state of long connection; these states include at least create, disconnect, and run.
It should be noted that a tracker is a program for directionally tracking a service endpoint lifecycle (creation, communication, recovery), and can perform directional tracking based on an endpoint category, one tracker corresponds to one endpoint category, and a developer can create different tracker implementation classes by implementing a tracker interface, so as to implement a situation that a single application supports multiple long connection scenarios. The service endpoint may be a client, but the application is not limited thereto.
Finally, the method sends the message corresponding to the state to the client by utilizing the pre-constructed splitter, so that the client can know the current long connection state in real time. In an embodiment, the client may further determine whether to continue the service process according to the current long connection state, and the server may also implement disconnection of the long connection according to a subsequent disconnection request of the client, thereby completing charging.
From the above description, the high-performance network long connection establishing method and device provided by the application can provide an open type generalized high-performance network long connection engine by constructing the connection pool, the splitter and the tracker, and ensure the unified management of the service endpoints and the high concurrency of message distribution, so that the parallel processing of multiple long connection scenes is realized, a protection mechanism can be provided for various abnormal conditions such as power failure, network failure, client violent operation and the like, and the access is simple and the service is stable.
In one embodiment, referring to fig. 2, the client includes a resource client, and the step of pre-building a resource client tracker includes:
s201: establishing a long connection type of the resource client tracker by utilizing an EnumWsType enumeration type;
s202: establishing a standard interface of a resource client tracker by using a method in an IWsProcessor interface;
s203: and establishing the resource client tracker according to the long connection type of the resource client tracker and the standard interface of the resource client tracker.
It will be appreciated that the role of the resource client tracker is to track the connection status of the resource client, including but not limited to establishing a connection, disconnecting a connection, and maintaining a connection.
In one embodiment, referring to fig. 3, the method in the iwsProcessor interface includes a whaeddedToPool method, a whanremovedFromPool method, and a wharvsg method, and the method in the iwsProcessor interface is used to establish a standard interface of the resource client tracker, including: establishing a service logic standard interface after long connection initialization corresponding to the resource client tracker by using a whaneddedToPool method (S301); establishing a service logic standard interface after the long connection destruction corresponding to the resource client tracker by utilizing a whenRemovedFromPool method (S302); and establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the resource client tracker by using a whorereceivedUpMsg method (S303).
Specifically, it can be established by the following steps:
(ii) connection class enumeration
Enumerating class extension connection types using EnumWsType, such as: customer type, customer service type, etc.
② tracker standard interface
The tracker can be customized by implementing the iw processor interface, which provides three methods:
whanenaddedtopool (wsockserver wsobj): when the connection object is triggered when being added into the connection pool, the developer can realize the service logic after connection initialization in the method.
(WsockServer wsObj): when the connection object is destroyed, triggering is carried out, and the developer can realize the business logic after the connection destruction in the method.
(vii) whenreceivedUpMsg (WsockServer wsObj, JSONObject upJson): when the service receives the uplink message, the service is triggered, and the developer can realize the service logic of processing the uplink message in the method.
From the above description, the high-performance network long connection establishment method provided by the present application can pre-construct the resource client tracker.
In one embodiment, referring to fig. 4, the client includes a business client, and the step of pre-constructing a business client tracker includes:
s401: establishing a long connection type of a service client tracker by utilizing an EnumWsType enumeration type;
s402: establishing a standard interface of a service client tracker by using a method in an IWsProcessor interface;
s403: and establishing the service client tracker according to the long connection type of the service client tracker and the standard interface of the service client tracker.
It will be appreciated that the role of the resource client tracker is to track the connection status of the resource client, including but not limited to establishing a connection, disconnecting a connection, and maintaining a connection.
In an embodiment, referring to fig. 5, the method in the iwsProcessor interface includes a whaeddedToPool method, a whanremovedFromPool method, and a wharvsg method, and the method in the iwsProcessor interface is used to establish a standard interface of the service client tracker, including: establishing a service logic standard interface after long connection initialization corresponding to a service client tracker by using a whaneddedToPool method (S501); establishing a service logic standard interface after long connection destruction corresponding to a service client tracker by utilizing a whenRemovedFromPool method (S502); and establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the service client tracker by using a whorereceivedUpMsg method (S503).
The specific steps for establishing the service client tracker are the same as those for establishing the resource client tracker, and are not described herein again.
From the above description, the high-performance network long connection establishment method provided by the present application can pre-construct the service client tracker.
In one embodiment, referring to fig. 6, the establishing a long connection with a client according to a long connection establishment request of the client includes:
s601: establishing long connection with a client by using a void put method;
s602: binding the relation between the unique identifier uuid of the long connection and the long connection object wsObj;
s603: and binding the matched tracker according to the long link type of the long link.
It can be understood that, the high-performance network long connection establishment method provided by the present application establishes a connection pool (WsockServerPool), and establishes a long connection with the client through the connection pool. The connection pool is responsible for uniformly managing the life cycle of the long connection service end point, can realize elegant creation, use and recovery of the service end point under a large-scale connection scene, and ensures high utilization rate of the service end point in the pool through mechanisms such as heartbeat and self-checking.
The connection pool is realized based on a singleton mode, a double-end lock checking mechanism is used for guaranteeing thread safety, all connection types and corresponding trackers are loaded during initialization, and a ready switch is turned on after initialization is completed, so that services can be provided for the outside. The functions of the connection pool include, but are not limited to:
creating a connection
Creating a connection by using a void put (String uuid, Wsock Server wsObj) method, binding the relation between the unique identifier uuid of the connection and the connection object wsObj, and binding the tracker matched with the unique identifier uuid and the connection object wsObj according to the connection type.
② destroy the connection
The connection is destroyed by using a void remove (String uuid) method, and the connection object wsObj is found according to the unique identifier uuid of the connection and is removed from the memory.
③ broadcast messages
Sending a message to all online clients can be achieved using the int broadcastMsgToAll (WsMsg msg) method, which returns the number of clients that received the message.
Oriented message
Directed messages for a portion of the online clients can be achieved using the int broadcastMsg (WsMsg, List < String > uuidList) method, which returns the number of clients that received the message.
Fifthly, unicast message
The method of int broadcast msg (WsMsg msg, String wsType, String wsOid) can be used for realizing directional unicast message, and a client is uniquely determined through the connection type wsType and the connection identification wsOid.
Sixth, uplink message
The client uplink message is processed using void processUpMsg (WsockServer wsObj, JSONObject msgiobj), and different processing is performed for different connection objects wsObj and message contents msgiobj.
It should be noted that the connection pool also provides a heartbeat mechanism to monitor the full life cycle status of the long connection. In an embodiment, the connection pool sends heartbeat messages to all the clients every 5 seconds, and requires the clients to respond immediately, if the clients do not respond to the heartbeat messages for 30 seconds continuously, the clients are considered to be offline, and at this time, the connection pool automatically recovers the service endpoints corresponding to the clients.
From the above description, it can be known that the high-performance network long connection establishment method provided by the present application can establish a long connection with a client according to a long connection establishment request of the client.
In an embodiment, referring to fig. 7, sending a message corresponding to a state to a client by using a pre-constructed splitter includes:
s701: determining whether the message to be sent is congested, if so, putting the message to be sent into a ring buffer of a splitter;
s702: and sending the message to be sent in the ring buffer to the client by utilizing a pre-supported memory mechanism and a lock-free concurrent mechanism.
It can be understood that the splitter can be used as a message distribution center of a long connection service endpoint, and is implemented based on characteristics of a ring buffer, a pre-branch memory, lock-free concurrency and the like, so that occurrence probability of problems of message delay, message loss and the like in a high-concurrency scene can be greatly reduced.
The splitter in the present application is used to implement the message transmission to the client by using its own characteristics, including but not limited to: with ring buffers, with a pre-emptive memory mechanism, with a lock-free concurrency mechanism. By utilizing the mechanism, when network congestion is caused by too many concurrent messages, the messages can be orderly sent to the client without causing a large amount of time delay, and the method specifically comprises the following steps:
annular buffer zone
This application realizes the ring buffer based on the array, and the ring buffer is through its next available element of a digital mark, and it only needs through the digital mark to put data in toward the buffer, finds available element position can. The consumed buffer area elements cannot be destroyed immediately, if the use result of a certain element is failure, the failure element segment in the buffer area can be found through the failure element position and the current available element position, the elements are consumed again, the consumed elements are stored until being replaced by new elements, and a developer can set a reasonable buffer area size according to the service characteristics of the developer.
② memory with advance memory
Since the ring buffer is implemented based on an array, we can pre-fetch memory to allocate to the buffer, keeping the buffer elements permanently valid, which means that garbage collection is hardly triggered. And the object is not required to be created every time one piece of data is added like a linked list, and the object is also required to be destroyed when the data is deleted.
③ lock-free concurrence
Assuming the buffer length is buffer size, we set two pointers: head points to the next read location and tail points to the next write location. Since this is a circular buffer, there is a problem how to judge whether the buffer is full or empty, and the rule used here is that the last cell of the buffer does not store data. Therefore, if head is equal to tail, buffer is empty. If head +1(mod buffer size), then the buffer is full.
How to perform read-write operation of thread-safe buffer in a lock-free manner is the following basic principle: during a read operation we only modify the value of head, and during a write operation we only modify the value of tail. At the time of a write operation, we modify the value of tail after writing the content to the buffer; while in the read operation, we read the value of tail and assign it to copyTail, the assign operation is an atomic operation. Therefore, after the copyTail is read, data can be read from the head to the copyTail without writing the data. Similarly, the value of the head is modified after the read operation is completed; before the write operation, the value of the head is read to determine whether there is room for writing data. Therefore, there is always room between tail and head-1 to write data at this time, and there is no situation that data in one location is overwritten by a write operation without being read.
From the above description, the high-performance network long connection establishment method provided by the present application can send a message corresponding to a state to a client by using a pre-constructed splitter.
The artificial intelligence algorithm training platform is an artificial intelligence algorithm training platform established by the industrial and silver technology, and provides infrastructure required by algorithm training of computing resources, software environments and the like for an algorithm developer. The computing resource is charged according to the using time length, the system needs to monitor the running state of the computing resource, and when a developer selects the computing resource and starts the machine, the system carries out fee deduction operation every half hour of normal running; on the other hand, the system also monitors the online state of the account of the developer, and if the developer is offline due to network disconnection, power failure or misoperation when the computing resources are started and not closed, the system needs to help the developer to shut down in time so as to avoid generating extra cost and resource waste; in addition, if the balance of the developer is insufficient in the training process, the system needs to inform the developer of recharging in time. Finally, if training is finished, the system needs to inform the developer of the training completion condition and automatically close the computing resources.
To better illustrate the feasibility of the technical solution described in the present application, an embodiment is described, that is, how to implement the monitoring service using the "open high-performance long connection engine" corresponding to the method described in the present application.
After the developer is on line, the WEB system of the developer establishes long connection with the monitoring service; and after the computing resources are started, the computing resources establish long connection with the monitoring service.
Defining tracker
Two long connection clients are involved in this case: developer WEB systems, computing resources. Two trackers are defined correspondingly.
a. Developer WEB system tracker
And the system is responsible for monitoring online, offline and uplink messages of developers. After the developer is online, putting the long connection service endpoint into a connection pool; when a developer goes offline, it shuts down the computing resources it is using and removes its service endpoints from the connection pool. When the balance of the developer is monitored to be insufficient, sending downlink information to a WEB client to remind the developer to recharge; and after the training is finished, sending downlink information to the WEB client, and informing a developer of a training result.
b. Computing resource tracker
And the system is responsible for monitoring the online, offline and uplink messages of the computing resources. After the computing resource is started, putting the long connection service end point into a connection pool, and starting charging; when the computing resource is shut down, removing the service end point from the connection pool, and stopping charging; after training is completed, the computing resources can send uplink messages to the monitoring service, the monitoring service informs developers of the completion of training of the WEB client, and the computing resources are closed.
Management of connection pool
The connection pool is in healthy connection with a developer WEB system and computing resources through a heartbeat mechanism. And if the developer WEB system or the computing resource does not reply the heartbeat message in time within 30 seconds, the connection pool considers that the connection is disconnected, and the corresponding service endpoint is removed from the connection pool and corresponding business operation is carried out.
In addition, the connection pool can establish a logical relationship between the service end point of the WEB system of the developer and the computational resource service end point corresponding to the developer, and after the developer goes offline, the monitoring service can find the computational resource started by the developer in time, so that the computational resource can be quickly closed, and the resource waste is avoided; when charging operation is carried out on a certain example resource, if the balance of a developer is found to be insufficient, a service endpoint corresponding to the developer can be found in time and a unicast message is sent to the service endpoint, so that the service endpoint is informed to recharge. When the training of a certain computing resource is finished, the corresponding developer can be informed of the training result information in time.
High performance guaranteed splitter
In this case, the following message interaction scenarios are involved:
a. broadcasting heartbeat messages
b. Unicast training result message
c. Unicast insufficient balance message
d. Unicast shutdown instruction message
When each service endpoint is established, a 1024-length annular buffer area is established for the service endpoint, the buffer area directly occupies a memory and does not carry out resource recovery. When a large amount of messages need to be sent in a short time, the ring buffer area pre-supports the memory, so that the operation of opening up a large amount of memory is avoided, and the high speed and high efficiency of program execution are ensured. In addition, the put operation of the ring buffer is realized by adopting an asynchronous mechanism, the condition of message blocking of a service endpoint cannot occur, and the splitter realizes peak clipping and valley filling of the message based on the ring buffer.
To sum up, this application technical scheme's beneficial effect includes:
1) unified management service endpoint
The connection pool provided by the application can uniformly manage long connection service endpoints, can realize broadcast messages of all service endpoints, directional messages of part of service endpoints and unicast messages of a single service endpoint, and has strong functions.
2) Optimizing concurrent message delay and message loss
The method and the device adopt the annular buffer area to realize the splitter, and effectively reduce the occurrence probability of the situations of message delay and message loss under the high-concurrency scene through the technologies of pre-supporting memory, lock-free concurrency and the like.
3) A single application may support multiple scenarios
The tracker can be realized according to the requirements of developers, a plurality of trackers can be realized in one application, each tracker can correspond to one connection type, and the service logic of life cycle nodes such as creation, destruction, uplink message receiving and the like of each type of connection can be realized in the corresponding tracker.
4) Compatibility with various abnormal conditions
The connection pool in the application provides a uniform heartbeat mechanism, abnormal connection caused by network disconnection, power failure, client violent operation and the like can be rapidly identified through the heartbeat mechanism, and if the connection is confirmed to be abnormal, the connection is immediately destroyed to ensure the high utilization rate of memory resources.
Based on the same inventive concept, the embodiments of the present application further provide a high-performance network long connection establishing apparatus, which can be used to implement the methods described in the foregoing embodiments, as described in the following embodiments. Because the principle of the high-performance network long connection establishment device for solving the problems is similar to the high-performance network long connection establishment method, the implementation of the high-performance network long connection establishment device can refer to the implementation of the software performance reference determination method, and repeated parts are not described again. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. While the system described in the embodiments below is preferably implemented in software, implementations in hardware, or a combination of software and hardware are also possible and contemplated.
In an embodiment, referring to fig. 8, in order to provide an open generalized high-performance network long connection engine to quickly construct a high-available long connection service, the present application provides a high-performance network long connection establishment apparatus, including: a connection establishing unit 801, a state monitoring unit 802, and a message transmitting unit 803.
A connection establishing unit 801, configured to establish a long connection with a client according to a long connection establishment request of the client;
a state monitoring unit 802, configured to select a corresponding tracker from pre-created trackers according to the type of the client, and monitor the state of the long connection by using the selected tracker; the states include create, disconnect, and run;
a message sending unit 803, configured to send, to the client, a message corresponding to the state by using a pre-constructed splitter.
In one embodiment, referring to fig. 9, the client includes a resource client, including: a connection type determination unit 901, a standard interface determination unit 902, and a tracker establishment unit 903.
A connection type determining unit 901, configured to establish a long connection type of the resource client tracker by using an EnumWsType enumeration type;
a standard interface determining unit 902, configured to establish a standard interface of the resource client tracker by using a method in the iwsProcessor interface;
a tracker establishing unit 903, configured to establish the resource client tracker according to the long connection type of the resource client tracker and a standard interface of the resource client tracker.
In an embodiment, referring to fig. 10, the method in the iwsProcessor interface includes a whaeddePool method, a whanremovedFromPool method, and a wharvsgg method, and the standard interface determining unit 902 includes:
a first standard interface determining module 1001, configured to establish a service logic standard interface after initialization of a long connection corresponding to the resource client tracker by using the whaeddtopool method;
a second standard interface determining module 1002, configured to establish a service logic standard interface after the long connection destruction corresponding to the resource client tracker by using the whenRemovedFromPool method;
a third standard interface determining module 1003, configured to establish a service logic standard interface for processing an uplink message in a long connection corresponding to the resource client tracker by using the whorereceivedupmsg method.
In one embodiment, referring to fig. 11, the client includes a service client, including:
a connection type determining unit 1101, configured to establish a long connection type of the service client tracker by using an EnumWsType enumeration type;
a standard interface determining unit 1102, configured to establish a standard interface of the service client tracker by using a method in an iwsProcessor interface;
a tracker establishing unit 1103, configured to establish the service client tracker according to the long connection type of the service client tracker and a standard interface of the service client tracker.
In an embodiment, referring to fig. 12, the method in the iwsProcessor interface includes a whaeddePool method, a whanremovedFromPool method, and a wharvsgg method, and the standard interface determining unit 902 includes:
a first standard interface determining module 1201, configured to establish a service logic standard interface after initialization of a long connection corresponding to the service client tracker by using the whaeddtopool method;
a second standard interface determining module 1202, configured to establish, by using the whenremovedfrmpool method, a service logic standard interface after the long connection destruction corresponding to the service client tracker;
a third standard interface determining module 1203, configured to establish a service logic standard interface for processing an uplink message in a long connection corresponding to the service client tracker by using the whoereceivedupmsg method.
In an embodiment, referring to fig. 13, the high-performance network long connection establishment apparatus includes: a connection establishing module 1301, a relation binding module 1302 and a tracker matching module 1303.
A connection establishing module 1301, configured to establish a long connection with the client by using a void put method;
a relation binding module 1302, configured to bind a relation between the unique identifier uuid of the long connection and the long connection object wsObj;
and the tracker matching module 1303 is used for binding matched trackers according to the long link type of the long link.
In an embodiment, referring to fig. 14, the message sending unit 803 includes:
a message buffer module 1401, configured to determine whether a message to be sent is congested, and if so, place the message to be sent in a ring buffer of the splitter;
a message sending module 1402, configured to send, to the client, a message to be sent in the ring buffer by using a pre-supported memory mechanism and a lock-free concurrent mechanism.
In an embodiment, the apparatus for establishing a long connection in a high performance network further includes:
and the heartbeat monitoring unit is used for monitoring the full life cycle state of the long connection by utilizing a heartbeat mechanism in a pre-constructed connection pool.
In order to provide an open generalized high-performance network long connection engine to quickly construct a high-available long connection service from a hardware level, the present application provides an embodiment of an electronic device for implementing all or part of the contents of the high-performance network long connection establishment method, where the electronic device specifically includes the following contents:
a Processor (Processor), a Memory (Memory), a communication Interface (Communications Interface) and a bus; the processor, the memory and the communication interface complete mutual communication through the bus; the communication interface is used for realizing information transmission between the high-performance network long connection establishing device and relevant equipment such as a core service system, a user terminal, a relevant database and the like; the logic controller may be a desktop computer, a tablet computer, a mobile terminal, and the like, but the embodiment is not limited thereto. In this embodiment, the logic controller may refer to the embodiment of the high performance network long connection establishment method and the embodiment of the high performance network long connection establishment apparatus in the embodiment for implementation, and the contents thereof are incorporated herein, and repeated details are not repeated.
It is understood that the user terminal 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), an in-vehicle device, a smart wearable device, and the like. Wherein, intelligence wearing equipment can include intelligent glasses, intelligent wrist-watch, intelligent bracelet etc..
In practical applications, part of the high-performance network long connection establishment method may be executed on the electronic device side as described above, or all operations may be completed in the client device. The selection may be specifically performed according to the processing capability of the client device, the limitation of the user usage scenario, and the like. This is not a limitation of the present application. The client device may further include a processor if all operations are performed in the client device.
The client device may have a communication module (i.e., a communication unit), and may be in communication connection with a remote server to implement data transmission with the server. The server may include a server on the side of the task scheduling center, and in other implementation scenarios, the server may also include a server on an intermediate platform, for example, a server on a third-party server platform that is communicatively linked to the task scheduling center server. The server may include a single computer device, or may include a server cluster formed by a plurality of servers, or a server structure of a distributed apparatus.
Fig. 15 is a schematic block diagram of a system configuration of an electronic device 9600 according to an embodiment of the present application. As shown in fig. 15, the electronic device 9600 can include a central processor 9100 and a memory 9140; the memory 9140 is coupled to the central processor 9100. Notably, this fig. 15 is exemplary; other types of structures may also be used in addition to or in place of the structure to implement telecommunications or other functions.
In one embodiment, the high performance network long connection establishment method function may be integrated into the central processor 9100. The central processor 9100 may be configured to control as follows:
s101: establishing a long connection with a client according to a long connection establishment request of the client;
s102: selecting a corresponding tracker from pre-established trackers according to the type of the client, and monitoring the state of long connection by using the selected tracker; the states include creation, disconnection and operation;
s103: and sending the message corresponding to the state to the client by utilizing the pre-constructed splitter.
From the above description, the high-performance network long connection establishing method and device provided by the application can provide an open type generalized high-performance network long connection engine by constructing the connection pool, the splitter and the tracker, and ensure the unified management of the service endpoints and the high concurrency of message distribution, so that the parallel processing of multiple long connection scenes is realized, a protection mechanism can be provided for various abnormal conditions such as power failure, network failure, client violent operation and the like, and the access is simple and the service is stable.
In another embodiment, the high-performance network long connection establishing apparatus may be configured separately from the central processing unit 9100, for example, the high-performance network long connection establishing apparatus of the data composite transmission apparatus may be configured as a chip connected with the central processing unit 9100, and the function of the high-performance network long connection establishing method is realized by the control of the central processing unit.
As shown in fig. 15, the electronic device 9600 may further include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It is noted that the electronic device 9600 also does not necessarily include all of the components shown in fig. 15; further, the electronic device 9600 may further include components not shown in fig. 15, which can be referred to in the related art.
As shown in fig. 15, a central processor 9100, sometimes referred to as a controller or operational control, can include a microprocessor or other processor device and/or logic device, which central processor 9100 receives input and controls the operation of the various components of the electronic device 9600.
The memory 9140 can be, for example, one or more of a buffer, a flash memory, a hard drive, a removable media, a volatile memory, a non-volatile memory, or other suitable device. The information relating to the failure may be stored, and a program for executing the information may be stored. And the central processing unit 9100 can execute the program stored in the memory 9140 to realize information storage or processing, or the like.
The input unit 9120 provides input to the central processor 9100. The input unit 9120 is, for example, a key or a touch input device. Power supply 9170 is used to provide power to electronic device 9600. The display 9160 is used for displaying display objects such as images and characters. The display may be, for example, an LCD display, but is not limited thereto.
The memory 9140 can be a solid state memory, e.g., Read Only Memory (ROM), Random Access Memory (RAM), a SIM card, or the like. There may also be a memory that holds information even when power is off, can be selectively erased, and is provided with more data, an example of which is sometimes called an EPROM or the like. The memory 9140 could also be some other type of device. Memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application/function storage portion 9142, the application/function storage portion 9142 being used for storing application programs and function programs or for executing a flow of operations of the electronic device 9600 by the central processor 9100.
The memory 9140 can also include a data store 9143, the data store 9143 being used to store data, such as contacts, digital data, pictures, sounds, and/or any other data used by an electronic device. The driver storage portion 9144 of the memory 9140 may include various drivers for the electronic device for communication functions and/or for performing other functions of the electronic device (e.g., messaging applications, contact book applications, etc.).
The communication module 9110 is a transmitter/receiver 9110 that transmits and receives signals via an antenna 9111. The communication module (transmitter/receiver) 9110 is coupled to the central processor 9100 to provide input signals and receive output signals, which may be the same as in the case of a conventional mobile communication terminal.
Based on different communication technologies, a plurality of communication modules 9110, such as a cellular network module, a bluetooth module, and/or a wireless lan module, may be disposed in the same electronic device. The communication module (transmitter/receiver) 9110 is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide audio output via the speaker 9131 and receive audio input from the microphone 9132, thereby implementing ordinary telecommunications functions. The audio processor 9130 may include any suitable buffers, decoders, amplifiers and so forth. In addition, the audio processor 9130 is also coupled to the central processor 9100, thereby enabling recording locally through the microphone 9132 and enabling locally stored sounds to be played through the speaker 9131.
An embodiment of the present application further provides a computer-readable storage medium capable of implementing all the steps in the high-performance network long connection establishment method with a server or a client as an execution subject in the foregoing embodiment, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements all the steps in the high-performance network long connection establishment method with a server or a client as an execution subject in the foregoing embodiment, for example, when the processor executes the computer program, the processor implements the following steps:
s101: establishing a long connection with a client according to a long connection establishment request of the client;
s102: selecting a corresponding tracker from pre-established trackers according to the type of the client, and monitoring the state of long connection by using the selected tracker; the states include creation, disconnection and operation;
s103: and sending the message corresponding to the state to the client by utilizing the pre-constructed splitter.
From the above description, the high-performance network long connection establishing method and device provided by the application can provide an open type generalized high-performance network long connection engine by constructing the connection pool, the splitter and the tracker, and ensure the unified management of the service endpoints and the high concurrency of message distribution, so that the parallel processing of multiple long connection scenes is realized, a protection mechanism can be provided for various abnormal conditions such as power failure, network failure, client violent operation and the like, and the access is simple and the service is stable.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, 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.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (devices), 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 (18)

1. A method for establishing long connection of high-performance network is characterized by comprising the following steps:
establishing a long connection with a client according to a long connection establishment request of the client;
selecting a corresponding tracker from pre-established trackers according to the type of the client, and monitoring the state of the long connection by using the selected tracker; the states include create, disconnect, and run;
and sending the message corresponding to the state to the client by utilizing a pre-constructed splitter.
2. The method of claim 1, wherein the client comprises a resource client, and the step of pre-building a resource client tracker comprises:
establishing a long connection type of the resource client tracker by utilizing an EnumWsType enumeration type;
establishing a standard interface of the resource client tracker by using a method in an IWsProcessor interface;
and establishing the resource client tracker according to the long connection type of the resource client tracker and a standard interface of the resource client tracker.
3. The method for establishing the long connection in the high-performance network according to claim 2, wherein the method in the iwsProcessor interface includes a whaeddToPool method, a whanremovedFromPool method and a whanreceivedUpMsg method, and the establishing the standard interface of the resource client tracker by using the method in the iwsProcessor interface includes:
establishing a service logic standard interface after the initialization of the long connection corresponding to the resource client tracker by using the whaeddtopool method;
establishing a service logic standard interface after the long connection destruction corresponding to the resource client tracker by using the method of the whanremovedfrompool;
and establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the resource client tracker by using the whorereceivedUpMsg method.
4. The method of claim 1, wherein the client comprises a service client, and the step of pre-building a service client tracker comprises:
establishing a long connection type of the service client tracker by utilizing an EnumWsType enumeration type;
establishing a standard interface of the service client tracker by using a method in an IWsProcessor interface;
and establishing the service client tracker according to the long connection type of the service client tracker and a standard interface of the service client tracker.
5. The method for establishing the long connection in the high performance network according to claim 4, wherein the method in the iwsProcessor interface includes a whaeddToPool method, a whanremovedFromPool method and a whanreceivedUpMsg method, and the method in the iwsProcessor interface is used to establish the standard interface of the service client tracker, which includes:
establishing a service logic standard interface after long connection initialization corresponding to the service client tracker by using the whaeddtopool method;
establishing a service logic standard interface after the long connection destruction corresponding to the service client tracker by using the method of the whanremovedfrompool;
and establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the service client tracker by using the whorereceivedUpMsg method.
6. The method according to claim 1, wherein the establishing a long connection with the client according to the long connection establishment request of the client comprises:
establishing long connection with the client by using a void put method;
binding the relation between the unique identifier uuid of the long connection and the long connection object wsObj;
and binding the matched tracker according to the long connection type of the long connection.
7. The method according to claim 1, wherein the sending the message corresponding to the state to the client by using a pre-constructed splitter comprises:
determining whether a message to be sent is congested, if so, putting the message to be sent into a ring buffer of the splitter;
and sending the message to be sent in the annular buffer area to the client by utilizing a pre-supported memory mechanism and a lock-free concurrent mechanism.
8. The method for establishing the long connection in the high-performance network according to claim 1, further comprising:
and monitoring the full life cycle state of the long connection by utilizing a heartbeat mechanism in a pre-constructed connection pool.
9. A high performance network long connection setup apparatus, comprising:
the connection establishing unit is used for establishing long connection with the client according to a long connection establishing request of the client;
the state monitoring unit is used for selecting a corresponding tracker from pre-established trackers according to the type of the client and monitoring the state of the long connection by using the selected tracker; the states include create, disconnect, and run;
and the message sending unit is used for sending the message corresponding to the state to the client by utilizing a pre-constructed splitter.
10. The apparatus of claim 9, wherein the client comprises a resource client, comprising:
a connection type determining unit, configured to establish a long connection type of the resource client tracker by using an EnumWsType enumeration type;
the standard interface determining unit is used for establishing a standard interface of the resource client tracker by using a method in an IWsProcessor interface;
and the tracker establishing unit is used for establishing the resource client tracker according to the long connection type of the resource client tracker and the standard interface of the resource client tracker.
11. The apparatus of claim 10, wherein the methods in the iwsProcessor interface include a whaeddToPool method, a whanremovedFromPool method, and a whanreceivedUpMsg method, and the standard interface determination unit includes:
a first standard interface determining module, configured to establish a service logic standard interface after long connection initialization corresponding to the resource client tracker by using the whaeddedtopool method;
a second standard interface determining module, configured to establish a service logic standard interface after the long connection destruction corresponding to the resource client tracker by using the whenRemovedFromPool method;
and the third standard interface determining module is used for establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the resource client tracker by using the whenereceivedUpMsg method.
12. The apparatus of claim 9, wherein the client comprises a service client, comprising:
a connection type determining unit, configured to establish a long connection type of the service client tracker by using an EnumWsType enumeration type;
the standard interface determining unit is used for establishing a standard interface of the service client tracker by using a method in an IWsProcessor interface;
and the tracker establishing unit is used for establishing the service client tracker according to the long connection type of the service client tracker and the standard interface of the service client tracker.
13. The apparatus of claim 12, wherein the methods in the iwsProcessor interface include a whaeddToPool method, a whanremovedFromPool method, and a whanreceivedUpMsg method, and the standard interface determination unit includes:
a first standard interface determining module, configured to establish a service logic standard interface after long connection initialization corresponding to the service client tracker by using the whaeddedtopool method;
a second standard interface determining module, configured to establish a service logic standard interface after the long connection destruction corresponding to the service client tracker by using the whenRemovedFromPool method;
and the third standard interface determining module is used for establishing a service logic standard interface for processing the uplink message in the long connection corresponding to the service client tracker by using the whenereceivedUpMsg method.
14. The apparatus according to claim 9, wherein the connection establishing unit comprises:
the connection establishing module is used for establishing long connection with the client by using a void put method;
the relation binding module is used for binding the relation between the unique identifier uuid of the long connection and the long connection object wsObj;
and the tracker matching module is used for binding the matched tracker according to the long link type of the long link.
15. The apparatus of claim 9, wherein the message sending unit comprises:
the message buffer module is used for determining whether the message to be sent is congested, if so, the message to be sent is placed into a ring buffer area of the splitter;
and the message sending module is used for sending the message to be sent in the annular buffer area to the client by utilizing a pre-supported memory mechanism and a lock-free concurrent mechanism.
16. The apparatus for establishing a long connection in a high performance network according to claim 9, further comprising:
and the heartbeat monitoring unit is used for monitoring the full life cycle state of the long connection by utilizing a heartbeat mechanism in a pre-constructed connection pool.
17. 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 high performance network long connection establishment method according to any one of claims 1 to 8 when executing the program.
18. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the high performance network long connection establishment method of any one of claims 1 to 8.
CN202111186958.0A 2021-10-12 2021-10-12 High-performance network long connection establishing method and device Pending CN113923249A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111186958.0A CN113923249A (en) 2021-10-12 2021-10-12 High-performance network long connection establishing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111186958.0A CN113923249A (en) 2021-10-12 2021-10-12 High-performance network long connection establishing method and device

Publications (1)

Publication Number Publication Date
CN113923249A true CN113923249A (en) 2022-01-11

Family

ID=79239427

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111186958.0A Pending CN113923249A (en) 2021-10-12 2021-10-12 High-performance network long connection establishing method and device

Country Status (1)

Country Link
CN (1) CN113923249A (en)

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102932352A (en) * 2012-11-02 2013-02-13 北京奇虎科技有限公司 Method and server for communicating with client
CN103618741A (en) * 2013-12-09 2014-03-05 惠州华阳通用电子有限公司 TCP long connection communication system and method
CN105763634A (en) * 2016-04-14 2016-07-13 北京思特奇信息技术股份有限公司 Service realization method and device based on TCP long connection
CN107135279A (en) * 2017-07-07 2017-09-05 网宿科技股份有限公司 It is a kind of to handle the method and apparatus that request is set up in long connection
CN108243222A (en) * 2016-12-26 2018-07-03 航天信息股份有限公司 Server network architecture method and device
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
CN110351366A (en) * 2019-07-12 2019-10-18 西安雷迪信息技术有限公司 A kind of service scheduling method of Internet application, system and computer readable storage medium
CN110430238A (en) * 2019-07-05 2019-11-08 中国平安财产保险股份有限公司 Long connection management method, apparatus, equipment and computer readable storage medium
CN111447185A (en) * 2020-03-10 2020-07-24 平安科技(深圳)有限公司 Processing method of push information and related equipment
CN112118266A (en) * 2020-09-24 2020-12-22 焦点科技股份有限公司 Distributed state synchronization method based on cooperation of HTTP and WebSocket
CN112383617A (en) * 2020-11-12 2021-02-19 百度在线网络技术(北京)有限公司 Method, device, terminal equipment and medium for long connection
CN113301299A (en) * 2021-05-06 2021-08-24 厦门市思芯微科技有限公司 Multi-channel video transmission method, system, terminal and storage medium
CN113472846A (en) * 2021-05-28 2021-10-01 乐融致新电子科技(天津)有限公司 Message processing method, device, equipment and computer readable storage medium

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102932352A (en) * 2012-11-02 2013-02-13 北京奇虎科技有限公司 Method and server for communicating with client
CN103618741A (en) * 2013-12-09 2014-03-05 惠州华阳通用电子有限公司 TCP long connection communication system and method
CN105763634A (en) * 2016-04-14 2016-07-13 北京思特奇信息技术股份有限公司 Service realization method and device based on TCP long connection
CN108243222A (en) * 2016-12-26 2018-07-03 航天信息股份有限公司 Server network architecture method and device
CN107135279A (en) * 2017-07-07 2017-09-05 网宿科技股份有限公司 It is a kind of to handle the method and apparatus that request is set up in long connection
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
CN110430238A (en) * 2019-07-05 2019-11-08 中国平安财产保险股份有限公司 Long connection management method, apparatus, equipment and computer readable storage medium
CN110351366A (en) * 2019-07-12 2019-10-18 西安雷迪信息技术有限公司 A kind of service scheduling method of Internet application, system and computer readable storage medium
CN111447185A (en) * 2020-03-10 2020-07-24 平安科技(深圳)有限公司 Processing method of push information and related equipment
CN112118266A (en) * 2020-09-24 2020-12-22 焦点科技股份有限公司 Distributed state synchronization method based on cooperation of HTTP and WebSocket
CN112383617A (en) * 2020-11-12 2021-02-19 百度在线网络技术(北京)有限公司 Method, device, terminal equipment and medium for long connection
CN113301299A (en) * 2021-05-06 2021-08-24 厦门市思芯微科技有限公司 Multi-channel video transmission method, system, terminal and storage medium
CN113472846A (en) * 2021-05-28 2021-10-01 乐融致新电子科技(天津)有限公司 Message processing method, device, equipment and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
翟成彤: "基于长连接的分布式消息推送***设计与实现", 中国优秀硕士学位论文全文数据库 信息科技辑, 5 June 2019 (2019-06-05) *

Similar Documents

Publication Publication Date Title
CN108449410B (en) Message management method, system and related device in cloud platform
EP3547715B1 (en) Method and apparatus for reducing continuous-wakeup delay of bluetooth loudspeaker, and bluetooth loudspeaker
CN111031058A (en) Websocket-based distributed server cluster interaction method and device
CN110505275A (en) Data transmission method, system, server and computer readable storage medium
CN103209439A (en) Method, apparatus and device for monitoring data traffic
CN109376197B (en) Data synchronization method, server and computer storage medium
CN111338773A (en) Distributed timed task scheduling method, scheduling system and server cluster
CN112463535A (en) Multi-cluster exception handling method and device
CN111445331A (en) Transaction matching method and device
CN105142184A (en) Flow control method and electronic device
CN111510493B (en) Distributed data transmission method and device
CN102708063B (en) disk space management method and device
CN111666167A (en) Input event reading processing optimization method, nonvolatile memory and terminal equipment
CN114996053A (en) Remote volume replication transmission method, system, device and storage medium
WO2024067529A1 (en) Rdma-based link establishment method and apparatus, and device and storage medium
CN113971098A (en) RabbitMQ consumption management method and system
CN110381150B (en) Data processing method and device on block chain, electronic equipment and storage medium
CN111338905A (en) Application node data processing method and device
CN113923249A (en) High-performance network long connection establishing method and device
CN107241788A (en) The power consumption control method and device of wearable device
CN108363629B (en) Method, medium, apparatus and computing device for instant messaging
US9647966B2 (en) Device, method and non-transitory computer readable storage medium for performing instant message communication
CN115914375A (en) Disaster tolerance processing method and device for distributed message platform
CN104486215A (en) Message transmitting method and equipment
CN102684865A (en) Method, system and device for data synchronization

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