A server node service method and device based on TCP long connection

By calculating the average number of client connections and disconnecting and reallocating the excess to new service nodes, the problem of service nodes not being in service after TCP long connection expansion is solved, fast service and load balancing are achieved, and the cluster service capabilities are improved.

CN114296869BActive Publication Date: 2025-09-09TUS CLOUD CONTROL (BEIJING) TECH LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111564441.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-20
Publication Date
2025-09-09
Estimated Expiration
2041-12-20

AI Technical Summary

Technical Problem

In application scenarios based on TCP persistent connections, the expanded service nodes failed to provide services quickly, affecting the stability and reliability of system services.

Method used

By obtaining the number of service nodes and the total number of client connections, the average number of client connections that each service node needs to handle is calculated. Connections that exceed the average number in existing service nodes are disconnected and allocated to the newly added service nodes after expansion. The data allocation priority is adjusted to ensure load balancing.

Benefits of technology

The newly added service nodes after expansion were quickly put into service, which reduced the impact on client stability, alleviated the pressure on existing service nodes in the cluster, and improved the overall service capabilities of the cluster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114296869B_ABST
    Figure CN114296869B_ABST
Patent Text Reader

Abstract

The embodiments of this specification disclose a method and device for serving server nodes based on TCP long connections. The scheme may include: obtaining the number of service nodes and the total number of client connections that establish long connections with the service nodes; the service nodes include newly added service nodes after expansion and existing service nodes; determining the average number of client connections that each service node needs to process based on the number of service nodes and the total number of client connections; determining the target number of client connections that the existing service nodes need to disconnect based on the average number of client connections that each service node needs to process; disconnecting the target number of client connections from the existing service nodes; and allocating the target number of client connections that have been disconnected from the existing service nodes to the newly added service nodes after expansion. The method provided by the embodiments of this specification can ensure the stability of the service, improve the efficiency of service resource utilization, and quickly relieve the pressure on other service nodes in the cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of server technology, and in particular to a server node service method and device based on TCP long connection. Background Art

[0002] The Transmission Control Protocol (TCP) is a connection-oriented, reliable, byte-stream-based transport layer communication protocol. A client initiates a connection to a server, and the server accepts the client's connection, establishing a connection between the two parties. After a client and server complete a read or write operation, the connection between them is not automatically closed; subsequent read and write operations continue to use this connection.

[0003] In a TCP-based long connection application scenario, the client's message accessing the network service first reaches the load balancing scheduler. The scheduler selects a service node from a group of service nodes (service pool) on the backend based on the connection scheduling algorithm, sends the data message to the selected service node, and records the connection hash table locally. When the next message from this client connection arrives, the selected service node information is obtained from the connection hash table, and the data packet is sent to the service node again.

[0004] When the service capacity of the cluster server is insufficient, an effective solution is to improve the service capacity of the cluster through horizontal expansion (such as adding service nodes). For the newly added service nodes after expansion, if the client does not initiate a new connection, the pressure on the original service nodes will not be reduced. However, in order to put the newly added service nodes into service, it is necessary to restart the load balancer or other existing service nodes, prompting the disconnection of the connections established by each client, triggering the client to initiate a reconnection, and then the load balancer will re-distribute the connections according to the load balancing scheduling strategy. Only then will the newly added service nodes have the possibility to join the service, but this operation will affect the service stability and reliability of the entire system.

[0005] Therefore, there is an urgent need for a method to quickly put the expanded service nodes into service. Summary of the Invention

[0006] The embodiments of this specification provide a method and device for serving a server node based on a TCP persistent connection, so as to reduce the time that a service node is out of service after expansion and improve the stability of client connections during expansion and upgrade.

[0007] To solve the above technical problems, the embodiments of this specification are implemented as follows:

[0008] The server node service method based on TCP long connection provided in the embodiments of this specification includes:

[0009] Obtain the number of service nodes and the total number of client connections that have established persistent connections with the service nodes; the service nodes include newly added service nodes after expansion and existing service nodes;

[0010] Determining an average number of client connections that each service node needs to process based on the number of service nodes and the total number of client connections;

[0011] Determining a target number of client connections that the existing service nodes need to disconnect based on an average number of client connections that each service node needs to process;

[0012] Disconnecting the target number of client connections from the existing service node;

[0013] The target number of client connections disconnected from the existing service nodes are allocated to the newly added service nodes after the expansion.

[0014] Optionally, before obtaining the number of service nodes and the total number of client connections that have established long connections with the service nodes, the method further includes:

[0015] The data allocation priorities of the newly added service nodes after the expansion and the existing service nodes are adjusted so that the data allocation priority of the newly added service nodes after the expansion is higher than the data allocation priority of the existing service nodes.

[0016] Optionally, obtaining a maximum allowed connection window period of the disconnected client and a connection time for the disconnected client to establish a connection with the newly added service node after the expansion;

[0017] When the connection time is longer than the maximum allowed connection window period, the allocation priority of the newly added service node after the expansion is adjusted to be the same as the data allocation priority of the existing service node.

[0018] Optionally, after allocating the number of client connections that need to be disconnected from the existing service node to the newly added service node after the expansion, the method further includes:

[0019] The data allocation priority of the newly added service node after the expansion is adjusted to be the same as the data allocation priority of the existing service node.

[0020] An embodiment of the present disclosure provides a server node service device based on a TCP persistent connection, comprising: a first acquisition module for acquiring the number of service nodes and the total number of client connections that have established persistent connections with the service nodes; the service nodes include newly added service nodes after expansion and existing service nodes;

[0021] A first determining module is configured to determine an average number of client connections that each of the service nodes needs to process based on the number of the service nodes and the total number of client connections;

[0022] a second determining module, configured to determine a target number of client connections that the existing service nodes need to disconnect based on an average number of client connections that each of the service nodes needs to process;

[0023] A client connection disconnection module, configured to disconnect the target number of client connections from the existing service nodes;

[0024] The allocation module is configured to allocate the target number of client connections disconnected from the existing service nodes to the newly added service nodes after the capacity expansion.

[0025] Optionally, the first adjustment module is configured to adjust the data allocation priorities of the newly added service nodes after the expansion and the existing service nodes, so that the data allocation priority of the newly added service nodes after the expansion is higher than the data allocation priority of the existing service nodes.

[0026] Optionally, the device further includes:

[0027] A second acquisition module is configured to acquire a maximum allowed connection window of the disconnected client and a connection time for the disconnected client to establish a connection with the newly added service node after the expansion;

[0028] The second adjustment module is configured to adjust the allocation priority of the newly added service node after the expansion to be the same as the data allocation priority of the existing service node when the connection time is longer than the maximum allowed connection window period.

[0029] Optional,

[0030] The third adjustment module is configured to adjust the data allocation priority of the newly added service node after the expansion to be the same as the data allocation priority of the existing service node.

[0031] One embodiment of this specification can achieve at least the following beneficial effects:

[0032] By obtaining the number of service nodes and the total number of client connections, the average number of client connections per service node is calculated. Clients exceeding the average number of client connections from existing service nodes are disconnected and assigned to newly added service nodes after capacity expansion. The method described in the embodiments of this specification only disconnects some clients from existing service points, minimizing the impact on stable client connections. It also enables rapid service provisioning of newly added nodes after capacity expansion, improving service resource utilization efficiency and rapidly alleviating pressure on other service nodes in the cluster, rapidly improving the overall service capabilities of the cluster. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0034] Figure 1 This is a schematic diagram of the overall solution flow of the server node service method based on TCP long connection in the embodiment of this specification;

[0035] Figure 2 A flowchart of a server node service method based on a TCP persistent connection provided in an embodiment of this specification;

[0036] Figure 3 A schematic diagram of the overall architecture of the server node service method based on TCP persistent connection provided in this embodiment;

[0037] Figure 4 A schematic diagram of the overall architecture after expansion provided in the embodiments of this specification;

[0038] Figure 5 A schematic diagram of the overall architecture after allocation provided in the embodiments of this specification;

[0039] Figure 6 The embodiments of this specification provide corresponding Figure 2 Schematic diagram of the structure of the server node service device based on TCP long connection. DETAILED DESCRIPTION

[0040] To make the purpose, technical solutions, and advantages of one or more embodiments of this specification more clear, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of one or more embodiments of this specification.

[0041] It should be understood that although the terms first, second, third, etc. may be used in this application document to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other.

[0042] The technical solutions provided by the various embodiments of this specification are described in detail below with reference to the accompanying drawings.

[0043] When a server cluster is expanded, the newly added service nodes are often left "out of service" for a period of time because no clients initiate persistent connections. This technical solution aims to reduce the duration of this "out of service" state, minimize the impact on existing nodes in the cluster, and mitigate the cascading volatility of the cluster caused by expansion.

[0044] In order to solve the defects in the prior art, this solution provides the following embodiments:

[0045] Figure 1 This is a schematic diagram of the overall solution flow of a server node service method based on TCP long connection in the embodiment of this specification. Figure 1 As shown, the overall solution of the present application includes a client 10, a load balancing scheduler 20, and a server 30. The message from the client 10 accessing the server 30 first reaches the load balancing scheduler 20. The load balancing scheduler 20 selects a service node from multiple service nodes of the server 30 according to the connection scheduling algorithm, sends the data message to the selected service node, and records the connection hash table locally. When the next message from this client 10 arrives, the selected service node information is obtained from the connection hash table and the data packet is sent to the service node again.

[0046] When the server 30 node is expanded, the technical solution of the present application is applied when allocating connections to the client 10 of the newly added service node after the expansion.

[0047] Figure 2 The flowchart of a server node service method based on TCP persistent connection provided by the embodiment of this specification is as follows. From the program perspective, the execution subject of the process can be a program installed on the application server or application terminal.

[0048] like Figure 2 As shown, the process may include the following steps:

[0049] Step 202: Acquire the number of service nodes and the total number of client connections that have established long connections with the service nodes; the service nodes include newly added service nodes after expansion and existing service nodes.

[0050] In actual applications, the total number of long connections established with the service node can be obtained by counting the client's IP+port.

[0051] Step 204: Determine the average number of client connections that each service node needs to process based on the number of service nodes and the total number of client connections.

[0052] In this embodiment, the average number N of client connections may be calculated using Formula 1 based on the number of service nodes and the total number of client connections. Formula 1 is as follows:

[0053] Average number of client connections N = total number of client connections / number of service nodes

[0054] If the number of service nodes is not divisible by the total number of client connections, the remaining value indicates that among the existing service nodes, at least that value of service nodes must handle a number of connections equal to N plus 1, thereby obtaining the specific number of connections that each service node actually needs to handle.

[0055] Step 206: Determine a target number of client connections that the existing service nodes need to disconnect based on the average number of client connections that each service node needs to process.

[0056] Based on the client connections that are currently actually connected to the existing service node, N or N+1 connections are selected based on the algorithm strategy as client connections that can continue to be connected, and the client connections other than N or N+1 connections are used as configuration data requiring the service node to disconnect, and are sent to the corresponding service node.

[0057] When selecting client connections to continue to maintain, a random algorithm can be selected for screening, or a sequential search or reverse search method can be used to determine the connections to be disconnected. It should be understood that the embodiments of this specification are not limited to the above algorithms, and any algorithm that can determine the disconnection of N or N+1 connections can be used in this application.

[0058] Step 208: disconnect the target number of client connections from the existing service node.

[0059] In the configuration data that needs to be actively disconnected in the existing service node, the corresponding TCP connection is found from the "client connection status" cache in the process, and the connection between the client and the service node is actively disconnected.

[0060] Step 210: Distribute the target number of client connections disconnected from the existing service node to the newly added service node after the expansion.

[0061] After a client that has established a connection to an existing service node receives a server-initiated disconnection, it will re-initiate a connection request. The client connection that re-initiated the request will be assigned to the newly added service node after the expansion.

[0062] The real-time service method for server nodes based on TCP persistent connections, described in the embodiments of this specification, obtains the average number of client connections to a service node and redistributes the target number of client connections that need to be disconnected from existing service nodes to newly added service nodes after capacity expansion. This enables rapid service of newly added service nodes after capacity expansion and shortens the time that newly added service nodes are out of service. Because only the target number of client connections are reconnected, the impact on client stability is minimized, effectively alleviating pressure on existing service nodes in the cluster and improving the overall service capabilities of the cluster.

[0063] It should be understood that in the methods described in one or more embodiments of this specification, the order of some steps can be adjusted according to actual needs, or some steps can be omitted.

[0064] based on Figure 2 The present specification also provides some specific implementation methods of the method, which are described below.

[0065] Optionally, before obtaining the number of service nodes and the total number of client connections that have established long connections with the service nodes, the method further includes:

[0066] The data allocation priorities of the newly added service nodes after the expansion and the existing service nodes are adjusted so that the data allocation priority of the newly added service nodes after the expansion is higher than the data allocation priority of the existing service nodes.

[0067] Data allocation priority refers to the order in which data is allocated to service nodes. Service nodes with higher data allocation priorities are allocated fewer client connections. In this embodiment, data allocation priority can be adjusted by adjusting the load balancing scheduling weights of service nodes. For example, the load balancing scheduling weight of newly added service nodes after expansion can be adjusted to 999999, while the load balancing scheduling weights of existing service nodes can be adjusted to 0. After this adjustment, when client connections are redistributed, they will be allocated to the newly added service nodes after expansion, and not to existing service nodes.

[0068] Through the above method, the newly added service nodes after expansion can quickly obtain data connections, further shortening the out-of-service time of the newly added service nodes after expansion.

[0069] Optionally, obtaining a maximum allowed connection window period of the disconnected client and a connection time for the disconnected client to establish a connection with the newly added service node after the expansion;

[0070] When the connection time is longer than the maximum allowed connection window period, the allocation priority of the newly added service node after the expansion is adjusted to be the same as the data allocation priority of the existing service node.

[0071] The maximum allowed connection window can be adjusted dynamically. However, if the maximum allowed connection window is set too long, clients that are not actively disconnected by the server and are reconnecting will be diverted to the newly added service nodes after the expansion, resulting in load imbalance.

[0072] When all disconnected client connections are reconnected, or the maximum allowed connection window expires, the data allocation priority of the existing service nodes will be restored first, and then the allocation priority of the newly added service nodes after expansion will be adjusted to be the same as the data allocation priority of the existing service nodes.

[0073] The above method avoids load imbalance in newly added service nodes after expansion.

[0074] Optionally, after allocating the number of client connections that need to be disconnected from the existing service node to the newly added service node after the expansion, the method further includes:

[0075] The data allocation priority of the newly added service nodes after the expansion is adjusted to be the same as the data allocation priority of the existing service nodes. It should be noted that when the client re-initiates a new connection, it will be allocated to any service node without distinction. In this embodiment, the weights of the newly added service nodes after the expansion and the existing service nodes can be adjusted to any value between 0 and 999999.

[0076] Through the above method, the data allocation priority of the newly added service nodes after expansion is adjusted to be the same as the data allocation priority of the existing service nodes, that is, the data allocation priority of all service nodes is the same, which can enable the load balancing scheduler to balance the load and distribute new connection requests to all service nodes.

[0077] According to the above description, the embodiment of this specification provides a real-time service method for server nodes based on TCP long connections in an actual application scenario.

[0078] Figure 3 The overall architecture diagram of the server node service method based on TCP long connection provided in this embodiment. Figure 3 As shown, in this embodiment, a cluster of three service nodes, S1, S2 and S3, is used. The load balancing scheduling strategy adopts polling, and the TCP long connection service scenario for 3000 concurrent clients (C1~C3000) is used as an example to illustrate. When the client is fully loaded, each service node S1, S2, and S3 serves 1000 clients. Figure 4 The overall architecture diagram after expansion provided in this embodiment is as follows: Figure 4 As shown in the figure, after expansion, two new service nodes S4 and S5 are added.

[0079] In this embodiment, the number of service nodes is 5, and the total number of client connections is 3000. Among them, the number of newly added nodes after expansion is 2, and the number of existing service nodes is 3.

[0080] In this embodiment, the average number of client connections that each service node needs to process = 3000 / 5 = 600.

[0081] Since the number of clients initially served by the existing service node is 1,000 and the average number of client connections is 600, the target number of client connections that the existing service node needs to disconnect is 400.

[0082] In this embodiment, a sequential search method is adopted to determine the target number of client connections that need to be disconnected.

[0083] The 1,200 client connections disconnected by S1, S2, and S3 are evenly distributed to S4 and S5. Figure 5 The overall architecture diagram after allocation provided in this embodiment is as follows: Figure 5 As shown, 600 client connections are allocated to S4 and S5 respectively.

[0084] Through the above method, by filtering out some connections from existing service nodes instead of reconnecting all connections, the impact on client stability is reduced, and the expanded service nodes are quickly put into service, thereby improving service resource utilization.

[0085] The embodiments of this specification can be used in a cloud control platform application scenario based on TCP persistent connections. The cloud control platform uploads data collected in real time by roadside visual perception devices (such as cameras, millimeter-wave radars, lidars, etc.) to the cloud via a roadside computing unit (RCU). The vehicle-mounted terminal collects data on various elements on the road and uploads it to the cloud. The cloud uses algorithms such as data fusion and collaborative decision-making control to send vehicle movement decisions and controls to the vehicle, as well as a platform for collaborative and comprehensive control of traffic control systems. Various traffic participants on the road will access the RCU in real time, and the client programs on the RCU will run continuously. Unless there are special exceptions, the connection will not be disconnected. Therefore, if the server does not actively disconnect, the newly expanded service nodes will not be able to provide services to these RCUs.

[0086] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method. Figure 6 The embodiments of this specification provide corresponding Figure 2 A schematic diagram of the structure of a server node service device based on TCP long connection. Figure 6 As shown, the device may include:

[0087] The first acquisition module 601 is used to obtain the number of service nodes and the total number of client connections that have established long connections with the service nodes; the service nodes include newly added service nodes after expansion and existing service nodes;

[0088] A first determining module 603 is configured to determine an average number of client connections that each service node needs to process based on the number of service nodes and the total number of client connections;

[0089] A second determining module 605 is configured to determine a target number of client connections that the existing service nodes need to disconnect based on an average number of client connections that each service node needs to process;

[0090] A client connection disconnection module 607 is configured to disconnect the target number of client connections from the existing service node;

[0091] The allocating module 609 is configured to allocate the target number of client connections disconnected from the existing service nodes to the newly added service nodes after the capacity expansion.

[0092] based on Figure 6 The present specification also provides some specific implementation plans of the method, which are described below.

[0093] Optionally, the first adjustment module is configured to adjust the data allocation priorities of the newly added service nodes after the expansion and the existing service nodes, so that the data allocation priority of the newly added service nodes after the expansion is higher than the data allocation priority of the existing service nodes.

[0094] Optionally, the device further includes:

[0095] A second acquisition module is configured to acquire a maximum allowed connection window of the disconnected client and a connection time for the disconnected client to establish a connection with the newly added service node after the expansion;

[0096] The second adjustment module is configured to adjust the allocation priority of the newly added service node after the expansion to be the same as the data allocation priority of the existing service node when the connection time is longer than the maximum allowed connection window period.

[0097] Optionally, the device further includes:

[0098] The third adjustment module is configured to adjust the data allocation priority of the newly added service node after the expansion to be the same as the data allocation priority of the existing service node.

[0099] It is understood that the above modules refer to computer programs or program segments for performing one or more specific functions. In addition, the distinction between the above modules does not mean that the actual program codes must also be separated.

[0100] While the foregoing descriptions of specific embodiments of this specification describe certain embodiments, in some cases, the actions or steps recited in the claims may be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0101] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to in detail.

[0102] The devices, equipment and methods provided in the embodiments of this specification correspond to each other. Therefore, the devices and equipment also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the corresponding devices and equipment will not be repeated here.

[0103] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures such as diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system onto a PLD through their own programming, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages ​​and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.

[0104] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.

[0105] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0106] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this application, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0107] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0108] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0109] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0110] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.

[0111] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0112] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0113] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0114] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0115] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0116] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0117] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A server node service method based on TCP long connection, characterized in that: include: Obtain the number of service nodes and the total number of client connections that have established long connections with the service nodes; The service nodes include newly added service nodes after expansion and existing service nodes; Determining an average number of client connections that each service node needs to process based on the number of service nodes and the total number of client connections; Determining a target number of client connections that the existing service nodes need to disconnect based on an average number of client connections that each service node needs to process; Disconnecting the target number of client connections from the existing service node; Allocating the target number of client connections disconnected from the existing service nodes to the newly added service nodes after the expansion; The data allocation priority of the newly added service node after the capacity expansion is adjusted to be the same as the data allocation priority of the existing service node.

2. The server node service method based on TCP long connection according to claim 1, characterized in that: Before obtaining the number of service nodes and the total number of client connections that have established long connections with the service nodes, the method further includes: The data allocation priorities of the newly added service nodes after the expansion and the existing service nodes are adjusted so that the data allocation priority of the newly added service nodes after the expansion is higher than the data allocation priority of the existing service nodes.

3. The server node service method based on TCP long connection according to claim 2, characterized in that: The method further comprises: Obtaining a maximum allowed connection window period of the disconnected client and a connection time for the disconnected client to establish a connection with the newly added service node after the expansion; When the connection time is longer than the maximum allowed connection window period, the allocation priority of the newly added service node after the expansion is adjusted to be the same as the data allocation priority of the existing service node.

4. A server node service device based on TCP long connection, characterized in that: include: A first acquisition module is used to acquire the number of service nodes and the total number of client connections that have established long connections with the service nodes; The service nodes include newly added service nodes after expansion and existing service nodes; A first determining module is configured to determine an average number of client connections that each of the service nodes needs to process based on the number of the service nodes and the total number of client connections; a second determining module, configured to determine a target number of client connections that the existing service nodes need to disconnect based on an average number of client connections that each of the service nodes needs to process; A client connection disconnection module, configured to disconnect the target number of client connections from the existing service nodes; An allocating module, configured to allocate the target number of client connections disconnected from the existing service nodes to the newly added service nodes after the expansion; The third adjustment module is configured to adjust the data allocation priority of the newly added service node after the expansion to be the same as the data allocation priority of the existing service node.

5. The server node service device based on TCP long connection according to claim 4, characterized in that: The first adjustment module is configured to adjust the data allocation priorities of the newly added service nodes after the expansion and the existing service nodes, so that the data allocation priorities of the newly added service nodes after the expansion are higher than the data allocation priorities of the existing service nodes.

6. The server node service device based on TCP long connection according to claim 5, characterized in that: The device further comprises: A second acquisition module is configured to acquire a maximum allowed connection window of the disconnected client and a connection time for the disconnected client to establish a connection with the newly added service node after the expansion; The second adjustment module is configured to adjust the allocation priority of the newly added service node after the expansion to be the same as the data allocation priority of the existing service node when the connection time is longer than the maximum allowed connection window period.

Citation Information

Patent Citations

  • Load balancing methods and network equipment

    CN109617986A