CN111147389A - TCP long connection server load balancing system and method - Google Patents

TCP long connection server load balancing system and method Download PDF

Info

Publication number
CN111147389A
CN111147389A CN201811315092.7A CN201811315092A CN111147389A CN 111147389 A CN111147389 A CN 111147389A CN 201811315092 A CN201811315092 A CN 201811315092A CN 111147389 A CN111147389 A CN 111147389A
Authority
CN
China
Prior art keywords
tcp
service
gateway
server
terminal
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
CN201811315092.7A
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.)
Aisino Dudley Information Systems Shanghai Co ltd
Original Assignee
Yingli Dufu Information System Shanghai 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 Yingli Dufu Information System Shanghai Co ltd filed Critical Yingli Dufu Information System Shanghai Co ltd
Priority to CN201811315092.7A priority Critical patent/CN111147389A/en
Publication of CN111147389A publication Critical patent/CN111147389A/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
    • H04L47/125Avoiding congestion; Recovering from congestion by balancing the load, e.g. traffic engineering
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer And Data Communications (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention aims at the application scene that the communication between the terminal and the server needs to adopt TCP long connection communication, and realizes the system and the method for carrying out communication load balancing management at the server end. Through the load balancing of the server side, on one hand, a more flexible load balancing strategy can be implemented, and meanwhile, the defects of other load distribution modes such as static load distribution and random server selection of the terminal when a large number of terminals use TCP for long-distance connection communication at present are avoided. The system and the method realized by the invention can be widely applied to systems which need to access a large number of terminals through long connection of TCP (transmission control protocol) and have higher requirement on the overall reliability of the systems, such as banks, securities and the like.

Description

TCP long connection server load balancing system and method
Technical Field
The invention solves the problem of realizing load balance at the server end when TCP long connection is adopted as a communication mode in the communication between the server cluster and the terminal. The system can be widely applied to a system which needs to be accessed into a large number of terminals through long TCP connection in banks, securities and the like and has higher requirement on the overall reliability of the system.
Background
TCP communication is a widely used communication method between systems. In many systems, long TCP connections are used as communication methods between a terminal and a server, that is, when the terminal communicates with the server, after a TCP link is established through three handshakes, the TCP link is always maintained for subsequent message communication with the server. The long connection of the TCP and the short connection (namely, the communication mode of establishing and breaking the link for each communication) have certain advantages in the aspects of safety, efficiency and the like. However, since the server needs to maintain a TCP link for each online terminal, when the number of terminals is large, the number of links that the server can simultaneously maintain is limited due to the limitation of the server operating system and the limitation of server resources, and when the system scale is enlarged, in order to support more terminal accesses, a plurality of TCP gateway applications dedicated to communication generally need to be deployed at the server. At this time, a certain load balancing strategy is needed to connect the terminals to each TCP gateway application in a decentralized manner. The common load balancing implementation methods of the TCP long connection at present are as follows:
hardware load balancing
Namely, a hardware load balancing device, such as F5, is deployed between the terminal and the server TCP gateway.
The advantages are that: the load balancing algorithm is flexible and configurable, and the correspondence is completely transparent.
The disadvantages are as follows: since the TCP link is maintained for a long time, a large amount of resources of the hardware load balancing device are occupied. The cost is very high.
Static load balancing
I.e. the TCP gateway to which the terminal is assigned in advance.
The advantages are that: the implementation mode is simple, and the existing application is not required to be modified.
The disadvantages are as follows: once a TCP gateway fails, all terminals directed to that gateway cannot be used.
Terminal load balancing
The list of TCP gateways is stored in the terminal, and the terminal selects one of the TCP gateways to initiate a link establishment request according to a certain strategy when the terminal is ready to establish a connection. When one TCP gateway fails to connect, another TCP gateway is automatically selected to attempt to establish a link.
The advantages are that: the problem of single point of failure of the server is solved.
The disadvantages are as follows: the end application needs separate code to support the above logic. In addition, when the TCP gateway changes (increases/decreases), an additional mechanism is required to be implemented to notify each terminal, further increasing the complexity of the terminal application.
The invention comprehensively considers the characteristics of the server and the terminal application, effectively avoids the defects of common load balancing, realizes the server-side dynamic load balancing system facing TCP long-connection communication, and can support independent application deployment.
Disclosure of Invention
The invention aims at a system that a large number of terminals adopt TCP long connection to communicate with a server system, and realizes a dynamic load balancing system facing the TCP long connection and based on server load. The system mainly comprises three service modules (see fig. 1):
TCP gateway service
TCP gateway management service
TCP proxy service
The service modules are respectively deployed in the server and the terminal and are between the terminal application and the server application. The TCP gateway service and the TCP gateway management service are deployed at a server side, and the TCP proxy service is deployed at a terminal. The functions of each service module are as follows:
TCP gateway service
1. And providing a TCP socket server interface, and managing and maintaining a TCP long connection communication link established by a terminal application or a TCP proxy service running on the terminal.
2. And bidirectional message forwarding, namely forwarding the message sent by the terminal application through the TCP proxy service to the background server application, and forwarding a response message of the background server application to the terminal.
TCP gateway management service
1. And the load and the health condition of each running instance of the TCP gateway service module are monitored in a centralized manner.
2. And providing a service for distributing the TCP gateway service operation instance to the terminal.
TCP proxy service
1. And (3) proxy TCP long connection communication of the terminal, namely providing a TCP socket server interface, receiving the established link of the terminal application and keeping the established TCP communication link. And after the link establishment with the terminal is finished, the link establishment is initiated to the TCP gateway service as a TCP socket client, and the established TCP link is maintained.
2. And the message is forwarded in a two-way manner, namely, the message sent by the terminal application is forwarded to the background server application through the TCP gateway service, and the message responded by the background server application forwarded by the TCP gateway service is sent to the terminal application.
3. Before a link is required to be established with the TCP gateway service each time, a TCP gateway management service interface is called to acquire the service address and the port information of the TCP gateway service.
The working flow of each service module in the invention is as follows (see fig. 2):
and 1, the TCP gateway service outputs the current load state information at regular time. The output supports multiple ways (one deployment is selected according to the system environment):
1) the load information is periodically output to a designated cache or file.
2) And calling a service interface managed by the TCP gateway, and directly uploading load information to the TCP gateway management service.
3) And providing a load query interface for the TCP gateway management service to directly query the TCP gateway service load condition.
And 2, the TCP gateway management service acquires the load state information of the TCP gateway service. Acquiring TCP gateway service load information in two modes corresponding to the TCP gateway service:
1) corresponding to 1-1), and periodically reading the cache or the file to acquire the load information of the TCP gateway service.
2) Corresponding to 1-2), the receiving TCP gateway obtains the load information of the TCP gateway service through real-time communication.
3) Corresponding to 1-3), calling a TCP gateway load query interface to acquire the load information of the TCP gateway service.
3. And after the terminal application is started, a TCP link establishment request is sent to a TCP proxy service operated by the terminal system.
And 4, the TCP proxy service receives the terminal application link establishment request and immediately sends a TCP gateway allocation request message to the pre-configured TCP gateway management service.
And 5, after receiving a request message for allocating the TCP gateway from the TCP proxy service, the TCP gateway management service calculates and allocates the TCP gateway according to the requirement of the system strategy, and sends the service information (the address and the port number of the server) of the TCP gateway back to the TCP proxy service. Allocation policies include, but are not limited to:
1) average load
2) Load in turns (Round-robin)
3) Priority group
And 6, after receiving the TCP gateway service information, the TCP proxy service initiates a link establishment request to the TCP service gateway and maintains the established TCP link. And finishing the establishment of the long TCP connection channel.
And 7, the TCP gateway service receives the link establishment request after receiving the link establishment request of the TCP proxy service, maintains the established TCP link, and updates the load information to the TCP gateway management service in the same way as the step 1.
8. When the terminal application needs to send the message to the server application, the message is sent to the TCP agent firstly.
And 9, the TCP proxy service receives the terminal application message and forwards the terminal application message to the TCP gateway service.
And 10, the TCP gateway service receives the message sent by the terminal and forwards the message to the server side application (or the application cluster).
11. When the server application needs to send data to the client, for example, a response message or a command message, the message is sent to the TCP gateway service.
And 12, the TCP gateway service forwards the server application message to the TCP proxy service of the corresponding terminal.
The TCP proxy service forwards the server application message to the terminal application.
Drawings
FIG. 1 is a diagram of TCP long connection server load balancing module relationships according to the present invention
FIG. 2 is a flow chart of TCP long connection server load balancing according to the present invention
Detailed Description
TCP gateway service
A variety of programming languages and third party frameworks may be used for implementation, including but not limited to C/C + +, Java, Groovy, Python, and so forth.
And deploying a plurality of operation instances in one or more servers according to the number of terminals needing to be accessed and the high-reliability redundancy condition of the system.
Since the TCP long connection link of the terminal has already been taken over by the TCP gateway service, the server application can be adapted to a short connection (on-demand connection) based mode of operation, e.g. TCP short connection (on-demand connection), HTTP request, etc., to reduce the resource occupation of the server application.
TCP gateway management service
A variety of programming languages and third party frameworks may be used for implementation, including but not limited to C/C + +, Java, Groovy, Python, and so forth.
The TCP gateway management service may deploy one or more running instances in one or more servers, depending on the high reliability requirements of the system.
TCP proxy service
A variety of programming languages and third party frameworks may be used for implementation, including but not limited to C/C + +, Java, Groovy, Python, and so forth.
In order to ensure that the working modes of the terminal application and the server application are not interfered, when the TCP proxy service detects that the terminal application is disconnected, the link with the TCP gateway service is disconnected after the message to be sent in the cache is sent to the TCP gateway service. Vice versa, when the link between the TCP proxy service and the TCP gateway service is interrupted, the TCP proxy service should send the message to be sent in the cache to the terminal application and then break the link with the terminal application.

Claims (8)

1. A system for load balancing at a server end for TCP long connection communication comprises a TCP gateway service module, a TCP gateway management service module and a TCP proxy service module, wherein the TCP gateway service module and the TCP gateway management service module run one or more instances at the server end, and the TCP proxy service runs independently on each access terminal or is embedded in terminal application; meanwhile, TCP gateway services are distributed to TCP gateway management service requests operated by a server side, and the TCP gateway management services calculate and distribute the TCP gateway services to TCP proxy services according to specified algorithms according to load information obtained from each TCP gateway service; after the communication link is established, a request message of the terminal application is forwarded to the server application through the TCP proxy service and the TCP gateway service, and a response message or a command of the server application is sent to the terminal application through the TCP gateway service and the TCP proxy service.
2. The load balancing system of the TCP long connection communication server according to claim 1, wherein each running instance of the TCP gateway service module provides a TCP socket server interface, receives a link establishment request from an application running in a terminal or a TCP proxy service, and maintains and manages an established TCP link; bidirectional forwarding of messages between a terminal application and a server application; the method provides self load information for the TCP gateway management service in various modes, including file/cache, calling TCP gateway management service interface, providing load query interface and the like.
3. The load balancing system of the TCP long connection communication server according to claim 1, wherein the TCP gateway management service module centrally manages the running instance of the TCP gateway service, and obtains the load information of the running instance of the TCP gateway service in various ways, including file/cache, invoking a TCP gateway management service interface, providing a load query interface, and the like; and processing a request of a TCP proxy service on the terminal for allocating a TCP gateway service instance, and allocating the TCP gateway service instance according to a specified algorithm.
4. The TCP long connection communication server side load balancing system according to claim 1, wherein the TCP proxy service module provides a TCP socket server interface, receives a link establishment request sent by a terminal application, and maintains and manages the established TCP link; allocating a TCP gateway service operation instance to the TCP gateway management service request; initiating a link establishment request to the distributed TCP gateway service, and maintaining the established link; and bidirectional forwarding the message between the terminal application and the server application.
5. A method for balancing load at a server end for TCP long connection communication comprises a TCP gateway service, a TCP gateway management service and a TCP proxy service, wherein the TCP gateway service and the TCP gateway management service run one or more instances at the server end, and the TCP proxy service runs independently on each access terminal or is embedded in terminal application; meanwhile, TCP gateway services are distributed to TCP gateway management service requests operated by a server side, and the TCP gateway management services calculate and distribute the TCP gateway services to TCP proxy services according to specified algorithms according to load information obtained from each TCP gateway service; after the communication link is established, a request message of the terminal application is forwarded to the server application through the TCP proxy service and the TCP gateway service, and a response message or a command of the server application is sent to the terminal application through the TCP gateway service and the TCP proxy service.
The TCP proxy service provides a TCP server interface facing the terminal application and manages and maintains a TCP long connection communication link with the terminal application; meanwhile, TCP gateway services are distributed to TCP gateway management service requests operated by a server side, and the TCP gateway management services calculate and distribute the TCP gateway services to TCP proxy services according to specified algorithms according to load information obtained from each TCP gateway service; after the TCP proxy service obtains the distributed TCP gateway service information, a TCP long connection link is established with the specified TCP gateway service to complete the communication link from the terminal to the server system.
7. A system comprising an application layer, a connector as claimed in any one of claims 1 to 4 and a target system.
8. A computer readable storage medium having stored thereon computer program instructions for performing the method of claim 5 or 6.
CN201811315092.7A 2018-11-06 2018-11-06 TCP long connection server load balancing system and method Pending CN111147389A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811315092.7A CN111147389A (en) 2018-11-06 2018-11-06 TCP long connection server load balancing system and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811315092.7A CN111147389A (en) 2018-11-06 2018-11-06 TCP long connection server load balancing system and method

Publications (1)

Publication Number Publication Date
CN111147389A true CN111147389A (en) 2020-05-12

Family

ID=70515989

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811315092.7A Pending CN111147389A (en) 2018-11-06 2018-11-06 TCP long connection server load balancing system and method

Country Status (1)

Country Link
CN (1) CN111147389A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112749015A (en) * 2021-01-25 2021-05-04 杭州迪普科技股份有限公司 Load balancing method and device
CN118432957A (en) * 2024-07-04 2024-08-02 阿里云计算有限公司 Network communication management and control method, readable storage medium, device and product

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7768939B1 (en) * 2007-01-02 2010-08-03 Juniper Networks, Inc. Network proxy with asymmetric connection connectivity
CN102904905A (en) * 2012-11-13 2013-01-30 无锡江南计算技术研究所 Application security proxy method and application security proxy system
CN103731933A (en) * 2014-01-10 2014-04-16 北京百度网讯科技有限公司 Wireless connection construction method and system and mobile terminal
CN107689878A (en) * 2016-08-04 2018-02-13 创盛视联数码科技(北京)有限公司 TCP length connection SiteServer LBSs based on name scheduling

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7768939B1 (en) * 2007-01-02 2010-08-03 Juniper Networks, Inc. Network proxy with asymmetric connection connectivity
CN102904905A (en) * 2012-11-13 2013-01-30 无锡江南计算技术研究所 Application security proxy method and application security proxy system
CN103731933A (en) * 2014-01-10 2014-04-16 北京百度网讯科技有限公司 Wireless connection construction method and system and mobile terminal
CN107689878A (en) * 2016-08-04 2018-02-13 创盛视联数码科技(北京)有限公司 TCP length connection SiteServer LBSs based on name scheduling

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112749015A (en) * 2021-01-25 2021-05-04 杭州迪普科技股份有限公司 Load balancing method and device
CN112749015B (en) * 2021-01-25 2023-07-25 杭州迪普科技股份有限公司 Load balancing method and device
CN118432957A (en) * 2024-07-04 2024-08-02 阿里云计算有限公司 Network communication management and control method, readable storage medium, device and product

Similar Documents

Publication Publication Date Title
CN112671882B (en) Same-city double-activity system and method based on micro-service
KR101227121B1 (en) Delayed downloading video service using peer-to-peer(p2p) content distribution network
KR101914488B1 (en) Server cluster and method for push notification service
CN105338086A (en) Distributed message forwarding method
CN110351246A (en) Server cluster system Socket management method and device
CN107689878A (en) TCP length connection SiteServer LBSs based on name scheduling
CN102316160A (en) Website system and communication method thereof
CN113596191A (en) Data processing method, network element equipment and readable storage medium
CN103795569A (en) Server connection method and device based on connection pool
CN110995617B (en) MQTT-based data transmission method and device, computer equipment and storage medium
CN112398845B (en) Data transmission method, data transmission device, data transmission system and electronic equipment
CN111787079A (en) Communication method, device, server, system and medium based on communication group
CN111147389A (en) TCP long connection server load balancing system and method
CN114900526B (en) Load balancing method and system, computer storage medium and electronic equipment
US20160212052A1 (en) Methods, systems, and computer readable media for balancing diameter message traffic received over long-lived diameter connections
CN109194993B (en) Media file distribution method and file distribution platform
CN103703745A (en) Method and apparatus for interconnecting a user agent to a cluster of servers
CN107438098B (en) Dynamic content distribution method and system
CN114168312A (en) Distributed cluster load balancing method and device and storage medium
CN117354312A (en) Access request processing method, device, system, computer equipment and storage medium
Nishimura et al. Applying flexibility in scale-out-based web cloud to future telecommunication session control systems
KR101251630B1 (en) System and method for providing push service
KR101382177B1 (en) System and method for dynamic message routing
CN107508760B (en) Method for load distribution based on line source IP
CN101170544A (en) A communication method in high-availability cluster system based on single practical IP address

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
TA01 Transfer of patent application right

Effective date of registration: 20211116

Address after: 200135 Part C + D, mezzanine, building 74, plot F24, No. 11, futexi Second Road, China (Shanghai) pilot Free Trade Zone, Pudong New Area, Shanghai

Applicant after: Aisino Dudley information systems (Shanghai) Co.,Ltd.

Address before: 200131 plant 70, No. 36, Yiwei Road, China (Shanghai) pilot Free Trade Zone, Pudong New Area, Shanghai

Applicant before: YINGLI DUFU INFORMATION SYSTEM (SHANGHAI) CO.,LTD.

TA01 Transfer of patent application right
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20200512

WD01 Invention patent application deemed withdrawn after publication