CN115242720A - Connection method and device for long connection service, electronic equipment and storage medium - Google Patents

Connection method and device for long connection service, electronic equipment and storage medium Download PDF

Info

Publication number
CN115242720A
CN115242720A CN202210927044.3A CN202210927044A CN115242720A CN 115242720 A CN115242720 A CN 115242720A CN 202210927044 A CN202210927044 A CN 202210927044A CN 115242720 A CN115242720 A CN 115242720A
Authority
CN
China
Prior art keywords
connection
node
current
service
target node
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
CN202210927044.3A
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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202210927044.3A priority Critical patent/CN115242720A/en
Publication of CN115242720A publication Critical patent/CN115242720A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/12Avoiding congestion; Recovering from congestion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0876Network utilisation, e.g. volume of load or congestion level
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/12Avoiding congestion; Recovering from congestion
    • H04L47/125Avoiding congestion; Recovering from congestion by balancing the load, e.g. traffic engineering

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Environmental & Geological Engineering (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The disclosure relates to a connection method, a connection device, electronic equipment and a storage medium of a long connection service, belonging to the field of internet, wherein the connection method of the long connection service comprises the following steps: recording the current connection state of the long connection service connected with the node contained in the server, and establishing the corresponding relation between the node and the current connection state; adjusting the connection quantity of at least one target node in the server according to the current connection condition recorded by each node in the server; and controlling the long connection service of the target node according to the adjusted connection number of the target node. The method and the device realize dynamic adjustment of the network connection quantity, are favorable for achieving the global network connection balance of the system and improving the availability of long connection service, and are further favorable for improving the reliability of service connection hotspots.

Description

Connection method and device for long connection service, electronic equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a connection method and apparatus for a long connection service, an electronic device, and a storage medium.
Background
With the rapid development of the internet, more and more traffic is being carried out through long connection services.
In a connection process for implementing a long connection service, many challenges are often faced, such as: network security, traffic restrictions, service layering, etc., all of which affect the availability of long connection services, especially some data transport class of traffic.
Disclosure of Invention
The application provides a connection method of a long connection service, which at least solves the problem of high availability of the long connection service in the related art.
According to a first aspect of the embodiments disclosed in the present application, there is provided a connection method for a long connection service, which is applied to a server and includes:
responding to the connection of the current long connection service, and recording the current connection state of the node connected by the current long connection service;
adjusting the connection quantity of at least one target node in the server according to the current connection conditions recorded by all nodes in the server;
and providing the connection of the long connection service of the target node according to the adjusted connection number of the target node.
As a possible implementation manner, the adjusting the connection number of at least one target node in the server according to the current connection status recorded by all nodes in the server includes:
acquiring the current accumulated connection quantity of each node in the server;
and determining the current connection quantity of the target node as the adjusted connection quantity according to the current accumulated connection quantity of all the nodes and a connection quantity calculation strategy.
As a possible implementation manner, the determining the current connection number of the target node according to the current accumulated connection number of all nodes further includes:
acquiring the load capacity of each node in the server;
determining the current connection quantity of the target node according to the load capacity of all nodes and the current accumulated connection quantity;
wherein the load capacity is determined according to a global configuration of the server.
As a possible implementation manner, the recording, in response to the connection of the current long connection service, the current connection status of the node to which the current long connection service is connected includes:
responding to the connection of the currently established long connection service, and storing the connection information of the currently established long connection service for the node connected by the currently established long connection service, or storing the current accumulated connection quantity of the node.
As a possible implementation manner, the obtaining a current accumulated connection number of each node in the server includes:
and for each node, counting the current accumulated connection quantity of the node according to the connection information currently stored by the node.
As a possible implementation, the method further comprises:
and under the condition that a set condition is met, triggering and adjusting the connection number of the target node.
As a possible implementation manner, the triggering, in the case that a set condition is met, to adjust the number of connections of the target node includes:
for each node, judging whether the current accumulated connection quantity of the node is greater than a set connection quantity threshold, determining the node as the target node under the condition that the current accumulated connection quantity of the node is greater than the connection quantity threshold, and triggering and adjusting the connection quantity of the target node;
the connection quantity threshold is determined according to the global configuration of the server, and different nodes in the server have different connection quantity thresholds.
As a possible implementation manner, the providing the long connection service of the target node according to the adjusted number of connections of the target node includes:
under the condition that the current accumulated connection number of the target node is larger than the adjusted connection number, disconnecting at least one current long connection service of the target node, and deleting the connection state record of the disconnected long connection service;
establishing at least one connection of a next long connection service under the condition that the current accumulated connection quantity of the target node is less than the adjusted connection quantity;
wherein, the first and the second end of the pipe are connected with each other,
the number of disconnected long connection services, the number of established next long connection services depends on the difference between the current accumulated number of connections and the adjusted number of connections.
According to a second aspect of the embodiments disclosed herein, there is provided a connection device for long connection service, the device comprising:
the recording module is configured to respond to the connection of the current long connection service and record the current connection state of the node connected with the current long connection service;
the coordination module is configured to adjust the connection number of at least one target node in the server according to the current connection conditions recorded by all nodes in the server;
a connection module configured to control connection of the long connection service of the target node according to the adjusted connection number of the target node.
As a possible implementation manner, the coordination module is configured to obtain a current accumulated connection number of each node in the server; and determining the current connection quantity of the target node according to the current accumulated connection quantity of all the nodes.
As a possible implementation manner, the coordination module is further configured to obtain a load capacity of each node in the server;
determining the current connection quantity of the target node according to the load capacity of all nodes and the current accumulated connection quantity;
wherein the load capacity is determined according to a global configuration of the server.
As a possible implementation manner, the recording module is configured to, in response to a connection of a currently established long connection service, store, for a node to which the currently established long connection service is connected, connection information of the currently established long connection service thereof, or store a current accumulated connection number of the node.
As a possible implementation, the coordination module is configured to count, for each node, a current accumulated connection number of the node according to the connection information currently stored by the node.
As a possible embodiment, the apparatus further comprises:
the triggering module is configured to trigger the coordination module to adjust the connection quantity when a set condition is met.
As a possible implementation manner, the triggering module is configured to determine, for each node, whether the current cumulative connection number of the node is greater than a set connection number threshold, determine that the node is the target node when the current cumulative connection number of the node is greater than the connection number threshold, and trigger the coordination module to adjust the connection number of the target node;
the connection quantity threshold is determined according to the global configuration of the server, and different nodes in the server have different connection quantity thresholds.
As a possible implementation manner, the connection module is configured to disconnect at least one current long connection service of the target node and delete a connection status record of the disconnected long connection service when the current accumulated connection number of the target node is greater than the adjusted connection number;
establishing at least one connection of a next long connection service under the condition that the current accumulated connection number of the target node is smaller than the adjusted connection number;
wherein, the first and the second end of the pipe are connected with each other,
the number of disconnected long connection services, the number of established next long connection services depends on the difference between the current accumulated number of connections and the adjusted number of connections.
According to a third aspect of the embodiments disclosed herein, there is provided an electronic device comprising:
a processor;
a memory for storing executable instructions of the processor;
wherein the processor is configured to execute the executable instructions to implement a connection method for any of the long connection services.
According to a fourth aspect of the embodiments disclosed herein, there is provided a computer-readable storage medium, where at least one instruction is executed by a processor of an electronic device, so that the electronic device can implement the method for connecting the long connection service according to any one of the above embodiments.
According to a fifth aspect of the embodiments disclosed herein, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the connection method of the long connection service described above.
The technical scheme provided by the embodiment disclosed by the application at least has the following beneficial effects:
according to the method and the system, the dynamic perception of network connection is realized by recording the current connection state of the nodes connected by the current long connection service, the connection quantity of at least one node in the service end is adjusted by adjusting the connection quantity of the nodes according to the current connection state recorded by each node in the service end, the dynamic adjustment of the network connection quantity is realized, the global network connection balance of the system is favorably achieved, the availability of the long connection service is improved, and the reliability of a service connection hotspot is favorably improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as unduly limiting the disclosure.
FIG. 1 is a flow diagram illustrating a method of connection for a long connection service in accordance with an exemplary embodiment;
FIG. 2 is a schematic diagram of a business system;
FIG. 3 is a flow diagram illustrating a method for connecting long connection services in accordance with an example embodiment;
FIG. 4 is a schematic diagram illustrating a connection device for a long connection service in accordance with an exemplary embodiment;
FIG. 5 is a schematic diagram of an electronic device shown in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions disclosed in the present application better understood, the technical solutions in the embodiments disclosed in the present application will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in other sequences than those illustrated or described herein. The implementations described in the following exemplary examples do not represent all implementations consistent with the disclosure of the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
The existing way to guarantee the availability of long connection services is:
performing statistics according to the set time information based on the historical connection information recorded by the access log of the terminal device to obtain the historical connection number kept in the target time information,
comparing and analyzing the target connection quantity configured by the system with the historical connection quantity kept in the target time information to obtain a dynamic connection quantity threshold value corresponding to the target time information,
and adjusting the connection quantity of the long connection service in the current time information according to the dynamic connection quantity threshold, and triggering data flow control or alarm if the connection quantity of the long connection service in the current time information is greater than the dynamic connection quantity threshold, wherein the connection quantity of the long connection service in the current time information is obtained by counting according to the current time based on the connection information recorded by the access log, and the time information comprises time period information or timestamp information.
The applicant researches and discovers that in a mode that historical connection information recorded by an access log of a terminal device is counted according to designated time information, and the connection number of the current long connection service is dynamically adjusted according to the counting result, under the condition that the payload (payload) of each long connection service is fixed, the adjustment of the connection number can be triggered only in the designated time information, and therefore the adjustment of the connection number is not real-time.
In view of the above, the present application provides a method for connecting a long connection service, which can achieve adaptive adjustment of the number of connections of the long connection service.
Referring to fig. 1, fig. 1 is a flowchart illustrating a connection method for a long connection service according to an exemplary embodiment. The method is applied to a service end side and comprises the following steps:
step 101, recording the current connection state of a long connection service connected with a node contained in a server, and establishing a corresponding relation between the node and the current connection state; in this step, the long connection service means that a plurality of packets can be continuously transmitted over one connection, and if no packet is transmitted during the connection holding period, both sides that need to be connected transmit a link check packet. The long connection service is mostly used for frequent and point-to-point communication, and the number of simultaneous connections is not too large, including but not limited to, mobile phone push, database connection, live broadcast service, and the like. This is because each Transmission Control Protocol (TCP) connection requires a three-step handshake, and if each operation is a short connection, the processing speed is reduced so much that, in the case of a long connection, each operation is not disconnected after completion, and it is only necessary to directly send a packet in the next operation, without establishing a TCP connection.
The node is a functional entity with the capability of providing long connection service connection, and belongs to a service end entity relative to the logic function of a connected terminal; in terms of morphology, a node may be a distributed network device, for example, a cluster device in a cluster system, or a functional entity located in the cluster device, and may also include at least one of a server, multiple servers, a cloud computing platform, or a virtualization center. It may also be a terminal device that may provide a long connection service connection, for example, a terminal device connected in a mesh network, it being understood that the terminal device is just like a network device of a server side in terms of the functional logic that provides the long connection service connection. In any form of device or functional entity, a functional entity capable of providing a long connection service connection to a requester can be understood as a node included in a server.
The connection condition is used to characterize the capability of the long connection service provided by the node, and may include information such as the number of connections, connection information, e.g., connection Identification (ID), connection duration, connection frequency, payload transmitted during connection, quality of service (QOS), etc., it should be understood that the connection condition is not limited to the above information, and any parameter index may be used to characterize the capability of the long connection service provided by the node. The current connection status may be understood as the capability of the node to provide the long connection service within the time closest to the recording time, and it should be understood that the current connection status is not limited to the recording time, and means the connection status with real-time property.
Taking the number of connections as an example, the number of connections is used to represent the number of long connection service connections counted by setting a time, for example, setting a timestamp, and may include the number of connections of a long connection service connection currently established by a node, and may also include the number of connections of a long connection service connection established by a node and still currently kept connected, and may not include the number of connections of a long connection service established by a node and currently disconnected in order to reduce occupation of storage resources. The accumulated connection number is used for representing the counted number of the long connection service connections in the set time period, and is equivalent to the accumulation of a plurality of connection numbers.
In the case of describing the connection status by using the connection information of the long connection service, the connection number may be determined by counting the number of different connection information at a set time, and the accumulated connection number may be determined by counting the number of different connection information within a set time period.
In one embodiment, when the terminal initiates a connection request of the long connection service to the server, the server responds to the connection of the current long connection service and records the current connection status of the node connected by the current long connection service,
in this embodiment, the terminal is a requester for initiating a long connection service, and the device type of the terminal may include: at least one of a smart phone, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III, motion Picture Experts compression standard Audio Layer 3) player, an MP4 (Moving Picture Experts Group Audio Layer iv, motion Picture Experts compression standard Audio Layer 4) player, a laptop portable computer, or a desktop computer. For example, the any terminal may be a smartphone, or other hand-held portable electronic device. The following embodiments are illustrated with the terminal comprising a smartphone.
Those skilled in the art will appreciate that the number of terminals may be greater or less. For example, the number of the terminals may be only one, or several tens or hundreds of the terminals, or more. The number of terminals and the type of the device are not limited in the embodiments of the present disclosure.
Taking content push as an example, a mobile phone terminal a initiates a Connection request for establishing a long Connection service to a destination IP address through a connector Connection Header of a hypertext transfer protocol (HTTP), a node b where the destination IP address is located responds to the Connection request, establishes a Connection of the long Connection service with the mobile phone terminal, and records a current Connection status c of the node b itself, so that, in a case that the Connection status records that the currently established long Connection service is connected, connection status data of the node b can be increased every time a long Connection service Connection is established, and in a case that the Connection status records also include the established long Connection service Connection and currently maintains the Connection, the Connection status can be updated at a timing of the newly established Connection of the long Connection service every time a Connection node of the long Connection service is established, thereby being beneficial to improving instantaneity and accuracy of the Connection status of the node itself providing the long Connection service.
The recorded connection status may be stored in the node itself or reported. In order to better coordinate the load of each node for load balancing, in this embodiment, the node reports the recorded connection status to the server. The node can report the current connection state after the establishment of the current long connection service connection is completed, namely reporting the current connection state based on the connection event of the long connection service connection; the current connection status can also be reported according to the set time, for example, the current connection status is reported periodically; the current connection status may be reported based on an information interaction protocol of the connection status between the node and the server, for example, the server sends a current connection status reporting instruction to the node, and the node reports the current connection status in response to the reporting instruction; or reporting the idle state of the node, wherein the idle state is determined by the node according to the busy degree of the processor of the node.
Taking the node b as an example, the node b reports the current connection status c after the establishment of the current long connection service connection is completed, which is beneficial to improving the real-time performance; the current connection status may also be reported at intervals of a set period of time, and the current connection status may also be reported in response to a reporting instruction from the server, or the current connection status may be reported when the node is detected to be in an idle state.
As an example, the server receives a connection status reported by a current node, and stores the connection status reported by the current node, and in view of a large number of nodes on the server side and a large amount of information of the connection status, a corresponding relationship between the node and the current connection status is established, so that the server manages each node, where each node in the corresponding relationship may be distinguished by using node identification information, for example, using IP address information of the node as the identification information.
102, obtaining at least one target node from the nodes contained in the server according to the current connection state, obtaining the connection quantity of the target node after adjustment based on the current connection state,
in this step, the target node is a node for adjusting the long connection service connection it provides; the number of the target nodes may be one or multiple, and the number may be dynamically changed, for example, the number of the target nodes acquired this time is a first number, the number of the target nodes acquired next time is a second number, the first number and the second number are different, and the number of the target nodes may be determined according to factors such as service requirements, network conditions, flow control, QOS, and the like.
Each target node may have different attributes, e.g., the target node has higher QOS capability, or the target node has better flow control, or the target node carries a particular service, etc., which also provides a selection policy for the selection of the target node.
As an example, the target node may be selected according to the current connection status in combination with the service type, for example, under the condition that the current connection status is the same or similar, a node carrying a service whose QOS requirement is lower than a set threshold is preferentially selected as the target node, so that the node carrying the service whose QOS requirement is not lower than the set threshold is prevented from being selected as the target node, thereby facilitating the improvement of the reliability of the long connection service connection of the node carrying the service whose QOS requirement is not lower than the set threshold, and for example, the node carrying the message service is preferentially selected as the target node, and the node carrying the content service is not preferentially selected as the target node, and in the case that the type of the service carried by the node is ambiguous, the target node may be selected in combination with the specific gravity of the service type, for example, if the specific gravity of the message service carried by the node is greater than the set specific gravity threshold, it is said that the message service carried by the node is greater, so that the node may be preferentially taken as the target node;
the selection of the target node can be selected according to the current connection condition and the communication type, for example, under the condition that the current connection conditions are the same or similar, the node bearing the non-real-time communication is preferentially selected as the target node, and the node bearing the real-time communication is not preferentially selected as the target node;
the selection of the target node can also be selected according to the current connection condition and the load capacity, for example, under the condition that the current connection conditions are the same or similar, the node with the load capacity smaller than a set load threshold value is preferentially selected as the target node, so that the reliability reduction of the long connection service connection caused by the insufficient load capacity of the node is avoided;
the selection of the target node can be selected according to the current connection state and the current node connected by the long connection service, for example, after the node responds to the current long connection service connection and reports the connection state, the node is preferentially taken as the target node so as to improve the real-time control of the long connection service connection;
the target node can be selected according to the current connection state and the combination of the selection modes, and the target node is preferentially selected according to the comprehensive result of multiple dimensions.
It should be understood that, the selection of the target node according to the current connection status in combination with the other dimension is beneficial to quickly acquiring the target node under the condition that the current connection statuses are the same or similar, so that the acquisition efficiency of the target node is improved, the acquired target node is targeted, and the high performance of the whole system is favorably exerted; even if the target node is selected according to the current connection condition without combining another dimension, the connection stability of the long connection service is favorably improved because the current connection condition has instantaneity.
The time for acquiring the target node can be performed according to the set time condition, and when the set time condition is met, the selection of the target node is triggered. Timing conditions include, but are not limited to: event conditions, e.g., to establish a long connection service connection as an event; a temporal condition, e.g., a set time or a periodic time arrival; the node device condition, for example, a parameter of the node device reaches a set parameter threshold, where the node may be a set node or all node devices.
In this step, in order to obtain a target node from nodes included in the server according to the current connection status, in one embodiment, the current cumulative connection number of each node in the server is obtained according to the current connection status and a corresponding relationship between the node and the current connection status, where each node refers to each node of the current connection status obtained by the server, and each node refers to each node that reports the connection status in combination with a situation that the server receives the connection status reported by the node; therefore, the server can globally obtain the current long connection service condition of each node; here, in view of the high sensitivity of the long connection to the number of simultaneous connections, the connection condition may be described in terms of the number of connections, and the current cumulative number of connections may be obtained by counting the number of connections.
For example, the server receives current connection conditions reported by m nodes, where m is a natural number greater than or equal to 1, and traverses each node, for example, according to a corresponding relationship between the node 1 and the current connection conditions, the server obtains the current connection quantity of the node 1, where the current connection quantity includes the connection quantity 3 reported by the timestamp 1 and the connection quantity 4 reported by the timestamp 2, the current cumulative connection quantity of the node 1 is 7, and so on, the current cumulative connection quantity of the m nodes in the server can be obtained.
As an example, in the case that the current connection status is current connection information of a long connection service, node identification information of each node in a server may be obtained, current sub-connection information corresponding to the node identification information of each node is obtained from the current connection information, and a current cumulative connection number of each node is obtained according to an information number of the current sub-connection information corresponding to the node identification information of each node. The current connection information of the long connection service is used for obtaining the current accumulated connection quantity of each node, and the current accumulated connection quantity obtaining mode only needs to report the current connection information for each node, so that the processing requirement of the node on the connection condition is reduced, the reliability of the node operation is improved, and the upgrading and the development of the service end on the node management are facilitated.
For example, the server receives current connection information reported by m nodes, and traverses each node, for example, node identifier 1 of node 1 corresponds to sub-connection identifier ID1, sub-connection identifier ID2, and sub-connection identifier ID6, so that the current connection number of node 1 can be determined to be 3 according to different identifiers of sub-connections, and so on, so as to obtain the current cumulative connection number of m nodes in the server. In order to improve the stability of the long connection service connection, in one embodiment, a target node is determined based on the current cumulative connection number of each node in the server, and the target node is selected from a node set included in the server, where each node refers to each node that has obtained the current cumulative connection number in the above manner, and it should be understood that, for a node that may not have obtained the current cumulative connection number due to some reason, the node may be processed by other technical means, and details are not described here. Similarly, when the current accumulated connection number is equal or close, another dimension can be combined to determine the target node.
For example, if the node 1 mainly carries a message service and the node 2 mainly carries a content service, the node 1 is preferably used as the target node.
As an example, a connection number threshold value pre-configured for each node in the server is obtained, and a node with the current cumulative connection number greater than the connection number threshold value is taken as a target node, because the connection number threshold values configured for each node are different and are selected from a node set, the selected target node has higher real-time performance, and meanwhile, the reliability and the adaptability of the long connection service are improved from the system level.
For example, if the current cumulative connection number of the node 1 is i, the threshold of the connection number of the node 1 is T1, the current cumulative connection number of the node 2 is j, and the threshold of the connection number of the node 2 is T2, if the current cumulative connection number i is greater than T1, it indicates that the current long connection service of the node 1 has too many connections, and therefore, the node 1 is determined as the target node, and similarly, if the current cumulative connection number j is greater than T2, it indicates that the current long connection service of the node 2 has too many connections, and therefore, the node 2 is determined as the target node.
After the target node is determined, an adjustment of the number of connections may be made to the target node. The adjusted connection number of the target node may be determined in a multidimensional manner by combining factors such as the service type, the communication mode, the load capacity, the proportion of each service type, QOS, and flow control of the target node, and it should be understood that the factors are not limited to the above factors, and any factors beneficial to performing long connection service connection of the target node may be considered. One implementation mode is that the adjusted connection number of the target node is determined based on the current accumulated connection number of the target node, so that the real-time adjustment of the connection number of the target node is realized;
for example, the current cumulative connection number of the node 1 is i, the connection number threshold of the node 1 is T1, and if the current cumulative connection number is i is greater than T1, it is indicated that the current long connection service of the node 1 is connected too much, the node 1 is determined as a target node, and considering that the connection number threshold may form a constraint on the node, therefore, the node 1 may determine the adjusted connection number according to a difference between the current cumulative connection number i and the connection number threshold as T1, it should be understood that the difference may be a difference between the current cumulative connection number i and the connection number threshold, or may be a parameter used for describing a difference degree between the current cumulative connection number i and the connection number threshold as a proportional relationship, and in this embodiment, the difference is used for description, which is beneficial to reducing complexity of an algorithm.
As an example, the load capacity preconfigured by the service end for the target node is obtained, the current connection number of the target node is determined according to the load capacity of the target node and the current accumulated connection number, and the current connection number of the target node is adjusted by combining the load capacity and the current accumulated connection number, so that the current connection number is more matched with the long connection service capacity which can be provided by the target node, the interruption of connection of the long connection service due to triggering of control of data traffic of the target node is avoided, and the reliability and high availability of the long connection service are improved. For example, the load capacity of the target node can support k long connection service connections, the current accumulated connection number is i, the current long connection service connections and the current accumulated connection number are subjected to weighted summation, and the result of the weighted summation is used as the adjusted connection number. It should be understood that, since the description parameters of the load capacity are different, in a specific application, the adjusted connection number may be determined according to the conversion of the description parameters of the load capacity in combination with the conversion of the corresponding equivalent of the current cumulative connection number.
And 103, controlling the connection of the long connection service of the target node according to the adjusted connection number of the target node.
In this step, the controlled long connection service connection may be any parameter that can improve the availability of the long connection service connection, such as controlling the connection duration, connection frequency, payload, traffic, QOS, number of connections, etc.
In view of the sensitivity of long connection service connections to the number of connections, one embodiment is to control the number of connections of the long connection service of the target node. In particular, the amount of the solvent to be used,
acquiring the current accumulated connection quantity of the target node;
under the condition that the current accumulated connection quantity of the target node is larger than the adjusted connection quantity, determining the disconnection quantity of the current long connection service of the target node based on the difference value between the current accumulated connection quantity and the adjusted connection quantity, disconnecting the current long connection service of the target node according to the disconnection quantity, and deleting the connection condition record of the disconnected long connection service;
and under the condition that the current accumulated connection quantity of the target node is smaller than the adjusted connection quantity, determining the redundancy quantity of the current long connection service of the target node based on the difference between the current accumulated connection quantity and the adjusted connection quantity, and establishing the connection of the long connection service of the target node according to the redundancy quantity.
Through the implementation mode, the self-adaptive adjustment of the connection of the long connection service of the target node is facilitated, the load balance of the long connection service is facilitated, the controlled connection quantity is determined by adopting the difference, and the complexity of the algorithm is reduced. It should be understood that the specific connection to be disconnected according to the number of disconnections may be selected according to a disconnection selection policy, for example, a connection with a long connection service connection setup time not exceeding a set duration may be disconnected, a connection with a payload less than a set payload threshold may be disconnected, a connection that will trigger flow control may be disconnected, a connection with a fault may be disconnected, a connection to be disconnected may be selected according to a traffic type and/or a proportion of various traffic types, or any combination of the above disconnection situations. Similarly, the connection established according to the redundancy number may specifically be which connection is selected according to an establishment selection policy, for example, the currently requested connection may be established, the requested connection may also be established according to the traffic type and/or the proportion of various traffic types, or the connection requiring the transfer node may be established through interaction between nodes, or any combination of the above establishment situations.
For the purpose of understanding the present application, the following description is made by taking a long connection service as an example in a service system, and it should be understood that the service system is not limited to a specific service, and may be applied to at least one of a plurality of service types, for example, a content service, a live broadcast service, a message service, and the like.
The service system provides services while facing a lot of challenges, and besides operation and maintenance needs flow control, the service system itself needs to support basic flow control logic, which means that long connection services in a long connection application scenario are also affected by flow control. In order to enable a service system to reliably provide services, the self-adaptive adjustment of the number of the connections of the long connection service is beneficial to solving the hot spot of service link.
Referring to fig. 2, fig. 2 is a schematic diagram of a service system. As an example, the service system includes a client located at a terminal side, and a service side for carrying services, where the service side may be a distributed cluster system composed of several independent devices, and these independent devices are generally referred to as nodes; to facilitate management of the cluster system, the server may further include a distributed application coordination service client, such as zookeeper, which corresponds to the central distributor in this embodiment; the server may further include a client for performing system global configuration for the cluster system.
Referring to fig. 3, fig. 3 is a flow chart illustrating a connection method for a long connection service according to an exemplary embodiment. The method comprises the following steps:
step 301, a server side client for performing system global configuration on a cluster system configures the cluster system and loads configured configuration information into the cluster system;
the cluster system comprises a plurality of nodes, the server-side client can manage the nodes in the cluster system, and the configuration information comprises the load capacity of each node in the cluster system and the connection number threshold of the supported long connection service.
In step 302, the client on the terminal side receives a connection request of a long connection service from the terminal,
here, the client on the terminal side is an application running in the terminal, and may be an application in a smartphone, for example. The Connection request may include a Connection Header with HTTP and a destination IP address. In step 303, in response to the connection request of the long connection service, the client on the terminal side establishes a connection with a node in the cluster system on the service side, where the node is referred to as a first node for convenience of description. Step 304, the first node responds to the established connection of the current long connection service, and reports the connection state of the current long connection service to the zookeeper so that the zookeeper can record and store the reported connection state;
it should be understood that when clients of a plurality of terminal sides respectively respond to connection requests of long connection services from terminals thereof, each terminal respectively establishes a connection of the long connection services with each node in the cluster system, each node respectively responds to the currently established long connection service, and reports at least a connection status of the currently established long connection service to zookeeper, and may also report a previously established long connection service that is currently in a connection state as a connection status of the current long connection service to zookeeper; and the zookeeper records and stores the reported connection conditions respectively, so that the zookeeper records and stores the connection conditions of the long connection services of all the nodes as compared with a database, and establishes the corresponding relation between the nodes and the current connection conditions so as to be convenient for the zookeeper to manage all the nodes.
As another example, the connection status may be a current connection number reported by a node, or connection information of a long connection service reported by the node, where the connection information may only include a connection identifier, for example, a connection ID, so as to reduce the storage space occupation of zookeeper. In view of the fact that a node can generally provide a connection of a long connection service for multiple terminals at the same time, and also provide a connection of multiple long connection services for the same terminal, these connections have different connection information, and may be referred to as sub-connections of the node.
In step 305, it is determined whether or not to trigger the adjustment of the number of connections, and if the set conditions are satisfied, the adjustment of the number of connections is triggered, and step 306 is executed.
Taking the current connection quantity accumulated by each node recorded by the zookeeper as an example, judging whether the stored current accumulated connection quantity of each node is larger than a set connection quantity threshold of the node or not by the zookeeper based on the stored current accumulated connection quantity of each node, if so, determining that the node is a target node, and triggering the adjustment of the connection quantity of the target node, otherwise, determining that the node is not the target node.
Taking the connection information of each node recorded by the zookeeper as an example, the zookeeper counts the current accumulated connection quantity of each node in real time according to the currently stored sub-connection information of each node, stores the statistical result to obtain the current accumulated connection quantity of each node, judges whether the stored current accumulated connection quantity of each node is greater than the set connection quantity threshold value of the node, determines that the node is a target node if the current accumulated connection quantity of each node is greater than the set connection quantity threshold value of the node, and triggers the adjustment of the connection quantity of the target node, otherwise, determines that the node is not the target node.
The connection quantity threshold is determined according to the global configuration of the server, and each node reports the connection quantity threshold to the zookeeper during system configuration; different nodes may have different connection number thresholds so that the number of connections matches the load capacity of the node.
The setting condition may also be a set target time threshold, for example, when the timing time arrives, the adjustment of the connection number is triggered; different nodes may have different target time thresholds so that the number of connections matches the operating conditions of the node.
And step 306, sending the current accumulated connection number of all the nodes in the cluster system to the target node by the zookeeper for adjusting the connection number.
For example, in this embodiment, after the first node responds to the connection of the current long connection service, when the current cumulative connection number of the first node is greater than the threshold of the connection number of the first node, the first node is selected as a target node, and zookeeper sends the current cumulative connection number of all nodes to the first node, so that the first node adjusts the connection number from the current cumulative connection number of the global node, thereby being beneficial to improving the high availability of the service system as a whole.
And 307, the target node calculates the connection quantity required to be adjusted by the target node according to the current accumulated connection quantity of all the nodes and the connection quantity calculation strategy respectively.
As an example, a first node is used as a target node, and the connection number of the first node is determined as the adjusted connection number according to the current accumulated connection number of all nodes and the connection number calculation policy of the first node.
The calculation policy of the number of connections of each target node may be the same or different.
Furthermore, the load capacity of all the nodes can be combined for adjustment, so that the balance of the network connection quantity is improved.
As an example, a first node obtains the load capacity of each node in the server, and determines the current connection number of the first node according to the load capacities of all nodes and the current accumulated connection number;
the load capacity is determined according to the global configuration of the server, each node reports the load capacity to the zookeeper during system configuration, and the target node pushes the load capacity of all the nodes during trigger adjustment of the zookeeper.
And 308, controlling the connection of the long connection service for the target node according to the adjusted connection number.
As an example:
if the current accumulated connection quantity of the target node is larger than the adjusted connection quantity, disconnecting the current long connection services of the quantity, and deleting the connection condition records of the disconnected long connection services;
if the current accumulated connection quantity of the target node is less than the adjusted connection quantity, establishing a plurality of connections of the next long connection service;
wherein the content of the first and second substances,
the number of disconnections of the disconnected long connection service, the number of redundancies of the established next long connection service depends on the difference between the current accumulated number of connections and the adjusted number of connections.
In particular, the amount of the solvent to be used,
acquiring the current accumulated connection quantity of the target node;
under the condition that the current accumulated connection quantity of the target node is larger than the adjusted connection quantity, determining the disconnection quantity of the current long connection service of the target node based on the difference value between the current accumulated connection quantity and the adjusted connection quantity, disconnecting the current long connection service of the target node according to the disconnection quantity, and deleting the connection condition record of the disconnected long connection service;
and under the condition that the current accumulated connection quantity of the target node is smaller than the adjusted connection quantity, determining the redundancy quantity of the current long connection service of the target node based on the difference value between the current accumulated connection quantity and the adjusted connection quantity, and establishing the connection of the long connection service of the target node according to the redundancy quantity.
As an example, if the current accumulated connection number of the first node is greater than the adjusted connection number, notifying the terminal to disconnect the currently established long connection service according to the disconnection number, and deleting the connection status record of the disconnected long connection service; and if the current accumulated connection quantity of the first node is less than the adjusted connection quantity, establishing the connection of the new long connection service according to the redundancy quantity.
The connection method of the long connection service in this embodiment can dynamically sense network connection by recording the connection status of the current long connection service of each node in real time, and can dynamically distribute network connection by adjusting the current connection number of target nodes according to the connection status of all nodes, thereby facilitating load balancing of each node, improving high availability of the long connection service, and providing stable service for the terminal.
Referring to fig. 4, fig. 4 is a schematic diagram illustrating a connection device for a long connection service according to an exemplary embodiment. The device comprises a plurality of devices which are connected with each other,
a recording module 41, configured to record a current connection status of a long connection service connected to a node included in the server, and establish a correspondence between the node and the current connection status;
a coordination module 42, configured to obtain at least one target node from nodes included in the server according to the current connection status, and obtain the connection number of the target node after adjustment based on the current connection status; a connection module 43 configured to control the connection of the long connection service of the target node according to the adjusted number of connections of the target node.
Wherein, the first and the second end of the pipe are connected with each other,
the coordination module 42 is configured to:
acquiring the current accumulated connection quantity of each node in the server according to the current connection condition and the corresponding relation between the node and the current connection condition;
determining the target node from the nodes contained in the server based on the current accumulated connection quantity of each node in the server;
and determining the adjusted connection number of the target node based on the current accumulated connection number of the target node.
The coordination module 42 is further configured to:
acquiring the load capacity of the server to the target node configured in advance;
and determining the current connection quantity of the target node according to the load capacity of the target node and the current accumulated connection quantity.
The recording module 41 is configured to:
responding to a long connection service request aiming at a current node, and receiving a connection condition reported by the current node, wherein the connection condition comprises the accumulated connection quantity or the connection information of the long connection service;
and storing the connection state reported by the current node.
The connection module 43 is configured to:
acquiring the current accumulated connection quantity of the target node;
under the condition that the current accumulated connection quantity of the target node is larger than the adjusted connection quantity, determining the disconnection quantity of the current long connection service of the target node based on the difference value between the current accumulated connection quantity and the adjusted connection quantity, disconnecting the current long connection service of the target node according to the disconnection quantity, and deleting the connection condition record of the disconnected long connection service;
and under the condition that the current accumulated connection quantity of the target node is smaller than the adjusted connection quantity, determining the redundancy quantity of the current long connection service of the target node based on the difference value between the current accumulated connection quantity and the adjusted connection quantity, and establishing the connection of the long connection service of the target node according to the redundancy quantity.
Referring to fig. 5, fig. 5 is a schematic diagram of an electronic device according to an exemplary embodiment. The electronic device includes a processor; a memory for storing executable instructions of the processor;
wherein the processor is configured to execute the executable instructions to implement any of the service tag exhibition methods.
In an exemplary embodiment, a computer-readable storage medium including at least one instruction, such as a memory including at least one instruction, is also provided, where the at least one instruction is executable by a processor in a computer device to perform the service tag exhibition method in the above embodiments.
Alternatively, the computer-readable storage medium may be a non-transitory computer-readable storage medium, and the non-transitory computer-readable storage medium may include a ROM (Read-Only Memory), a RAM (Random-Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, and the like, for example.
In an exemplary embodiment, a computer program product is further provided, which includes one or more instructions that can be executed by a processor of a computer device to implement the service tag display method according to the foregoing embodiments.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice in the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and alterations are possible without departing from the scope thereof. The scope of the present disclosure is to be limited only by the terms of the appended claims.

Claims (10)

1. A connection method of long connection service is characterized in that the method is applied to a service end and comprises the following steps:
recording the current connection state of the long connection service connected with the node contained in the server, and establishing the corresponding relation between the node and the current connection state;
acquiring at least one target node from nodes contained in the server according to the current connection state, and acquiring the connection quantity of the target node after adjustment based on the current connection state;
and controlling the connection of the long connection service of the target node according to the adjusted connection number of the target node.
2. The connection method according to claim 1, wherein the obtaining at least one target node from nodes included in the server according to the current connection status, and obtaining the adjusted connection number of the target node based on the current connection status comprises:
acquiring the current accumulated connection quantity of each node in the server according to the current connection condition and the corresponding relation between the node and the current connection condition;
determining the target node from the nodes contained in the server based on the current accumulated connection quantity of each node in the server;
and determining the adjusted connection number of the target node based on the current accumulated connection number of the target node.
3. The connection method according to claim 2, wherein the determining the adjusted number of connections of the target node based on the current accumulated number of connections of the target node further comprises:
acquiring the load capacity of the server to the target node configured in advance;
and determining the current connection quantity of the target node according to the load capacity of the target node and the current accumulated connection quantity.
4. The connection method according to claim 2, wherein the determining the target node from the nodes included in the server based on the current cumulative connection number of all the nodes comprises:
acquiring a connection quantity threshold value pre-configured for each node in the server;
and taking the nodes of which the current accumulated connection quantity is greater than the threshold value of the connection quantity in the nodes contained in the server as the target nodes.
5. The connection method according to claim 2, wherein the controlling the connection of the long connection service of the target node according to the adjusted number of connections of the target node comprises:
acquiring the current accumulated connection quantity of the target node;
under the condition that the current accumulated connection quantity of the target node is larger than the adjusted connection quantity, determining the disconnection quantity of the current long connection service of the target node based on the difference value between the current accumulated connection quantity and the adjusted connection quantity, disconnecting the current long connection service of the target node according to the disconnection quantity, and deleting the connection condition record of the disconnected long connection service;
and under the condition that the current accumulated connection quantity of the target node is smaller than the adjusted connection quantity, determining the redundancy quantity of the current long connection service of the target node based on the difference between the current accumulated connection quantity and the adjusted connection quantity, and establishing the connection of the long connection service of the target node according to the redundancy quantity.
6. The connection method according to claim 1, wherein the recording of the current connection status of the long connection service connected to the node included in the server includes:
responding to a long connection service request aiming at a current node, and receiving a connection condition reported by the current node, wherein the connection condition comprises the current accumulated connection quantity or the connection information of the long connection service;
and storing the connection state reported by the current node.
7. A connection device for long connection services, the device comprising:
the recording module is configured to record the current connection state of the long connection service connected with the node contained in the server and establish the corresponding relation between the node and the current connection state;
the coordination module is configured to acquire at least one target node from nodes included in the server according to the current connection state, and acquire the connection number of the target node after adjustment based on the current connection state; a connection module configured to control connection of the long connection service of the target node according to the adjusted connection number of the target node.
8. An electronic device, comprising:
a processor;
a memory for storing executable instructions of the processor;
wherein the processor is configured to execute the executable instructions to implement the method of connection for a long connection service as claimed in any one of claims 1 to 6.
9. A computer-readable storage medium, wherein at least one instruction of the computer-readable storage medium, when executed by a processor of an electronic device, enables the electronic device to implement the method for connecting the long connection service as claimed in any one of claims 1 to 6.
10. A computer program product comprising a computer program which, when executed by a processor, implements a method of connection for a long connection service as claimed in any one of claims 1 to 6.
CN202210927044.3A 2022-08-03 2022-08-03 Connection method and device for long connection service, electronic equipment and storage medium Pending CN115242720A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210927044.3A CN115242720A (en) 2022-08-03 2022-08-03 Connection method and device for long connection service, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210927044.3A CN115242720A (en) 2022-08-03 2022-08-03 Connection method and device for long connection service, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115242720A true CN115242720A (en) 2022-10-25

Family

ID=83677628

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210927044.3A Pending CN115242720A (en) 2022-08-03 2022-08-03 Connection method and device for long connection service, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115242720A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106357747A (en) * 2016-08-30 2017-01-25 维沃移动通信有限公司 Server load management method and device
WO2021078294A1 (en) * 2019-10-25 2021-04-29 北京金山云网络技术有限公司 Service coordination method and apparatus for distributed storage system, and electronic device
CN113810304A (en) * 2021-09-30 2021-12-17 深圳前海微众银行股份有限公司 Load balancing method, device, equipment and computer storage medium
CN114296869A (en) * 2021-12-20 2022-04-08 云控智行科技有限公司 Server node service method and device based on TCP long connection

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106357747A (en) * 2016-08-30 2017-01-25 维沃移动通信有限公司 Server load management method and device
WO2021078294A1 (en) * 2019-10-25 2021-04-29 北京金山云网络技术有限公司 Service coordination method and apparatus for distributed storage system, and electronic device
CN113810304A (en) * 2021-09-30 2021-12-17 深圳前海微众银行股份有限公司 Load balancing method, device, equipment and computer storage medium
CN114296869A (en) * 2021-12-20 2022-04-08 云控智行科技有限公司 Server node service method and device based on TCP long connection

Similar Documents

Publication Publication Date Title
EP3451614B1 (en) Dispatching method and device in content delivery network
KR101072966B1 (en) Method, device and system for distributing file data
CN102281190B (en) Networking method for load balancing apparatus, server and client access method
CN113438129B (en) Data acquisition method and device
CN106993014A (en) The method of adjustment of cache contents, apparatus and system
US20230412456A1 (en) Data communication method and apparatus, electronic device, and storage medium
CN102420868B (en) The providing method of service, apparatus and system
CN113301299B (en) Multi-channel video transmission method, system, terminal and storage medium
CN103312593B (en) A kind of message distributing system and method
CN114071168B (en) Mixed-flow live stream scheduling method and device
EP3993329A1 (en) Network data scheduling method and edge node
EP4070529A1 (en) User plane function load control
CN115002238A (en) Traffic transmission method, device, equipment and storage medium
CN111865674A (en) Log processing method, device and medium
CN106101468B (en) Method and device for determining transmission link
CN108551571B (en) Monitoring video distribution method, device and system and distribution server
CN112019604B (en) Edge data transmission method and system
CN110661673A (en) Heartbeat detection method and device
CN112866390A (en) Data transmission method, device, terminal equipment and storage medium
CN101695049A (en) Method and device for processing businesses in monitoring system
CN115242720A (en) Connection method and device for long connection service, electronic equipment and storage medium
CN112311826A (en) Method, device and system for processing access request in content distribution system
CN106686034B (en) CDN scheduling enhancement method, device and system
EP3435615B1 (en) Network service implementation method, service controller, and communication system
CN113438494A (en) Data processing method and device

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