WO2021083281A1 - Load balancing method and apparatus, and medium and device - Google Patents

Load balancing method and apparatus, and medium and device Download PDF

Info

Publication number
WO2021083281A1
WO2021083281A1 PCT/CN2020/124872 CN2020124872W WO2021083281A1 WO 2021083281 A1 WO2021083281 A1 WO 2021083281A1 CN 2020124872 W CN2020124872 W CN 2020124872W WO 2021083281 A1 WO2021083281 A1 WO 2021083281A1
Authority
WO
WIPO (PCT)
Prior art keywords
client
request message
load balancing
service server
load balancer
Prior art date
Application number
PCT/CN2020/124872
Other languages
French (fr)
Chinese (zh)
Inventor
李逸骏
Original Assignee
贵州白山云科技股份有限公司
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 贵州白山云科技股份有限公司 filed Critical 贵州白山云科技股份有限公司
Publication of WO2021083281A1 publication Critical patent/WO2021083281A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications
    • 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/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Definitions

  • This article relates to the field of network communication technology, in particular to load balancing methods, devices, media, and equipment.
  • the existing 7-layer load balancing schemes all require the load balancer to provide a forwarding function, which causes the load balancer to have a higher load and consume more resources.
  • the load balancer and business server are deployed in a mixed manner, it will cause additional bandwidth consumption for the network card.
  • this article provides a load balancing method, device, medium and equipment.
  • a load balancing method including:
  • the load balancing method further includes:
  • the request message is parsed based on the set Load balancing rules determine the business server.
  • the extended information includes:
  • Load balancing methods are applied to business servers, including:
  • the load balancing method further includes:
  • the load balancing method is applied to the first load balancer and includes:
  • a load balancing device which is applied to a second load balancer and includes:
  • the second receiving module is configured to receive the request message of the client forwarded by the first load balancer
  • connection module is used to establish a connection with the client and generate extended information
  • the balance module is used to parse the request message of the client, and determine the service server based on the set load balancing rule;
  • the second forwarding module is used to forward the request message and connection information of the terminal to the determined service server.
  • the second sending module is further configured to:
  • the request message is parsed based on the set Load balancing rules determine the business server.
  • the extended information includes:
  • the load balancing device is applied to the business server, including:
  • the third receiving module is used to obtain the client's request message and extended information
  • the response module is configured to process the request message based on the connection information, and generate a response message; and send the response message to the client.
  • the load balancing device When the service server and the second load balancer are respectively deployed on different servers, the load balancing device further includes:
  • the sending module is used to send the migration notification information to the first load balancer.
  • the load balancing device is applied to the first load balancer and includes:
  • the first receiving module is used to receive a request message from the client
  • the first forwarding module is configured to forward the request message to the second load balancer
  • the migration notification receiving module is used to receive the business migration notification sent by the business server;
  • the migration module is used to forward the request message of the client to the service server.
  • a computer-readable storage medium with a computer program stored thereon, which implements the steps of the load balancing method when the computer program is executed.
  • a computer device including a processor, a memory, and a computer program stored on the memory, and the processor implements the steps of the load balancing method when the computer program is executed by the processor.
  • this article can realize that the second load balancer consumes less bandwidth resources, and can achieve fine load scheduling, which is more convenient for the mixed deployment of load balancers and business servers, and reduces Hybrid deployment consumes the bandwidth of the network card, and at the same time, the service server sends the response message directly to the client, reducing the burden of the load balancer.
  • Fig. 1 is a flow chart showing a load balancing method according to an exemplary embodiment.
  • Fig. 2 is a flow chart showing a load balancing method according to an exemplary embodiment.
  • Fig. 3 is a flow chart showing a load balancing method according to an exemplary embodiment.
  • Fig. 4 is a schematic diagram showing a load balancing according to an exemplary embodiment.
  • Fig. 5 is a block diagram showing a load balancing device according to an exemplary embodiment.
  • Fig. 6 is a block diagram showing a load balancing device according to an exemplary embodiment.
  • Fig. 7 is a block diagram showing a load balancing device according to an exemplary embodiment.
  • Fig. 8 is a block diagram showing a load balancing device according to an exemplary embodiment.
  • Fig. 9 is a block diagram showing a computer device according to an exemplary embodiment.
  • the first load balancer is set to receive client requests, and according to certain load balancing rules, such as the address location of the second load balancer, the load level of the second load balancer, and the client request Forward to the second load balancer.
  • the first load balancer can be a 4-layer load balancer, which can meet the usage requirements. You can also choose other types of load balancers, but do not balance the content.
  • the specific type of load balancer is not limited in this article.
  • the second load balancer parses the client's request, determines the result of load balancing according to the content of the business message or other factors, determines the specific business server, and implements fine load scheduling. The determined business server performs the client's request response.
  • Fig. 1 is a flow chart showing a load balancing method according to an exemplary embodiment.
  • the load balancing method applied to the second load balancer includes:
  • Step S11 receiving the request message of the client forwarded by the first load balancer
  • Step S12 establishing a connection with the client to generate extended information
  • Step S13 parse the request message of the client, and determine the service server based on the set load balancing rule
  • Step S14 Send the client's request message and extended information to the determined service server.
  • the second load balancer after receiving the request message of the client forwarded by the first load balancer, the second load balancer first establishes a connection with the client, and generates extension information related to the connection. Analyze the client’s request message, integrate the client’s IP, service server load, the resource distribution and type of the service request, and the configuration of the load balancer to determine the service server used to respond to the client’s request message. The request message and extended information are sent to the determined service server.
  • the second load balancer sends the client's request message, it will also organize the message content, such as deleting duplicate messages, deleting useless messages in the handshake process with the client, and only parses the business server and responds to the client
  • the requested message is sent to the service server to reduce resource consumption as much as possible.
  • the business balancer can be deployed with the business server, that is, the business balancer and the business server are the same server.
  • the business balancer uses ordinary HTTP proxy forwarding or TCP proxy Forwarding, shared memory, etc., forward the client request to the local business server for processing.
  • the load balancing method further includes: sending the client's request message and the extended information to a certain After the business server, clean up the relevant data information when connecting with the client.
  • the operating environment where the load balancer and the business server are located are not the same, for example, they run on different cores, or run in an isolated environment. Due to different operating environments, the data related to the client connection cannot be shared. Therefore, after sending the client's request message and extended information to the determined service server, the load balancer needs to clean up the related data information when connecting with the client.
  • the service server can parse and respond to the client request according to the extended information, and send the response message directly to the client, and the response message It is no longer forwarded by the second load balancer, and at the same time, the service server will send a service migration notification to the first load balancer, and subsequent request packets of the client will no longer be processed by the second load balancer. Therefore, in this embodiment, the second load balancer cleans up related data generated when connecting with the client in time, so as to improve the performance of the second load balancer.
  • the request message is parsed based on the set Load balancing rules determine the business server.
  • the second load balancer establishes a connection with the client, there may be multiple request packets in the same connection at the same time.
  • the second load balancer determines that the local server responds according to the client's request packet and receives the same When connecting subsequent messages, it does not directly forward all other request messages in the connection to the local server for processing. Instead, it re-determines the service server according to the content of each message, so that the same client is the same
  • the request messages with different contents in the connection are sent to different service servers, and the suitable service server processes the different requests of the client to improve the quality of service.
  • the extended information includes: relevant information included in the protocol used for the connection with the client, and the information required by the service server to parse and respond to the request message.
  • the relevant information contained in the protocol used for the connection with the client can be the parameters negotiated when the load balancer establishes a connection with the client, the configuration information of the load balancer, and the connection status between the load balancer and the client; when the client's request message is HTTPS
  • the message also includes one or more of the status information of the TLS encrypted tunnel established between the load balancer and the client. Of course, in special circumstances, it may also include other information.
  • the information required by the service server to parse and respond to the request message may be client address information and first load balancer address information in order to send a migration notification to the first load balancer and send a response message to the client. In the load balancing method of this article, the above information is some of the necessary information for the business server, but not all of them.
  • the second load balancer establishes a connection with the client.
  • the second load balancer needs to send relevant information when establishing a connection with the client to the service server.
  • the business server parses the client's request message according to the parameters negotiated when the second load balancer establishes a connection with the client, responds to the client's request, and sends the response message to the client according to the client's address information. If the client's request message is an HTTPS message, the load balancer establishes a TLS encrypted tunnel with the client. Therefore, the extended information will also include the state information of the encrypted tunnel, such as the encryption key.
  • the business server uses the encryption key.
  • the address information of the client and the address information of the first load balancer should also be sent to the service server, so that the service server can send a service migration notification to the first load balancer and send a response message to the client.
  • Fig. 2 is a flow chart showing a load balancing method according to an exemplary embodiment.
  • the load balancing method is applied to the business server, including:
  • Step S21 Obtain the client's request message and extended information
  • Step S22 processing the request message based on the extended information, and generating a response message
  • Step S23 Send a response message to the client.
  • the service server obtains the client's request message and extended information.
  • the extended information is connection-related information generated when the second load balancer establishes a connection with the client, and is used to parse the client request.
  • the service server processes the request message, and the generated corresponding message is no longer sent to the second load balancer, nor does it need to be sent to the first load balancer, but directly sent to the client to reduce the second load balancer and the first load The resource consumption of the equalizer.
  • the load balancing method further includes:
  • the service server After the service server completes a set of interactions, it can disconnect from the client and notify the first load balancer, or send the connection back to the first load balancer.
  • the request message is sent to the second load balancer, and the second load balancer determines the specific service server to provide services according to the parsed content.
  • Fig. 3 is a flow chart showing a load balancing method according to an exemplary embodiment.
  • the load balancing method applied to the first load balancer includes:
  • Step S31 receiving a request message from the client
  • Step S32 forward the request message to the second load balancer
  • Step S33 receiving a service migration notification sent by the service server
  • Step S34 forward the request message of the client to the service server.
  • the first load balancer is responsible for receiving client requests, forwarding the client requests to the second load balancer, and does not parse the client requests, and is not responsible for further load balancing for content.
  • the second load balancer determines the business server according to the balance result, if the business server and the second load balancer are deployed on different servers, the business server will send a business migration notification to the first load balancer, and the first load balancer will receive After the service migration notification, the client's request message will be directly forwarded to the service server instead of being sent to the second load balancer, reducing resource consumption in the system.
  • Fig. 4 is a schematic diagram showing a load balancing according to an exemplary embodiment.
  • the first load balancer is set up, and after receiving the client's request message, it is forwarded to the second load balancer, and the second load balancer establishes a connection with the client, and parses the content of the client's request message , And according to the message content and preset load balancing rules, determine the business server, and send the client's request message and connection-related extended information to the business server.
  • the service server After receiving the request message and extended information of the client, the service server sends a service migration notification to the first load balancer to notify the first load balancer to forward the client's subsequent request message to the service server.
  • the business server responds to the client's request based on the extended information, and sends the response information directly to the client.
  • the response message is sent directly to the client by the business server, and the second load balancer consumes less bandwidth resources, which can achieve fine load scheduling, which is more convenient for the load balancer and
  • the hybrid deployment of business servers reduces the loss of network card bandwidth caused by hybrid deployment.
  • Fig. 5 is a block diagram showing a load balancing device according to an exemplary embodiment.
  • the load balancing device is applied to the second load balancer, and includes a second receiving module 501, a connecting module 502, a balancing module 503, and a second forwarding module 504.
  • the second receiving module 501 is configured to receive the request message of the client forwarded by the first load balancer.
  • the connection module 502 is configured to establish a connection with the client and generate extended information.
  • the balancing module 503 is configured to parse the request message of the client, and determine the service server based on the set load balancing rule.
  • the second forwarding module 504 is configured to forward the request message and connection information of the terminal to a determined service server.
  • the second forwarding module 504 is also used to clean up related data information when connecting with the client after sending the client's request message and extended information to the determined service server.
  • the determined business server is the local server, and when the client's request message forwarded by the first load balancer is received as a different request message in the same connection, the request message is parsed, and the business is determined based on the set load balancing rules. server.
  • the extended information includes:
  • Fig. 6 is a block diagram showing a load balancing device according to an exemplary embodiment.
  • the load balancing device is applied to a service server, and includes a third receiving module 601 and a response module 602.
  • the third receiving module 601 is configured to obtain the request message and extended information of the client.
  • the response module 602 is configured to process the request message based on the connection information, generate a response message, and send the response message to the client.
  • Fig. 7 is a block diagram showing a load balancing device according to an exemplary embodiment.
  • the load balancing apparatus when the service server and the second load balancer are respectively deployed on different servers, the load balancing apparatus further includes a sending module 701.
  • the sending module 701 is configured to send migration notification information to the first load balancer.
  • Fig. 8 is a block diagram showing a load balancing device according to an exemplary embodiment.
  • the load balancing device is applied to the first load balancer, and includes a first receiving module 801, a first forwarding module 802, a migration notification receiving module 803, and a migration module 804.
  • the first receiving module 801 is configured to receive a request message from the client.
  • the first forwarding module 802 is configured to forward the request message to the second load balancer.
  • the migration notification receiving module 803 is configured to receive the service migration notification sent by the service server.
  • the migration module 804 is configured to forward the request message of the client to the service server.
  • Fig. 9 is a block diagram showing a computer device 900 according to an exemplary embodiment.
  • the computer device 900 may be provided as a server. 9, the computer device 900 includes a processor 901, and the number of processors can be set to one or more as required.
  • the computer device 900 further includes a memory 902 for storing instructions executable by the processor 901, such as application programs. The number of memories can be set to one or more as required.
  • the stored application program can be one or more.
  • the processor 901 is configured to execute instructions to perform the load balancing method.
  • Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data) , Including but not limited to RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridge, magnetic tape, magnetic disk storage or other magnetic storage device, or can be used for Any other medium that stores desired information and can be accessed by a computer.
  • communication media usually contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as carrier waves or other transmission mechanisms, and may include any information delivery media. .
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • the embodiment of the present invention provides a method and device for load balancing.
  • the second load balancer receives the client's request message forwarded by the first load balancer; establishes a connection with the client and generates extended information; parses the client's request message, and determines the service based on the set load balancing rules Server; sending the client's request message and extended information to the determined service server. Consuming less bandwidth resources, you can achieve fine load scheduling, which is more convenient for the hybrid deployment of load balancers and business servers, and reduces the loss of network card bandwidth due to hybrid deployment.

Abstract

Disclosed are a load balancing method and apparatus, and a medium and a device. The load balancing method comprises: a second load balancer receiving a request message of a client that is forwarded by a first load balancer; establishing a connection with the client, and generating extended information; parsing the request message of the client, and determining a service server on the basis of a set load balancing rule; and sending the request message of the client and the extended information to the determined service server. By means of the method of the present application, a second load balancer can realize fine load scheduling by means of consuming fewer bandwidth resources, which is more convenient for the mixed deployment of a load balancer and a service server, thereby reducing the loss of a network card bandwidth caused by the mixed deployment.

Description

一种负载均衡方法、装置、介质和设备Load balancing method, device, medium and equipment
本申请要求在2019年10月31日提交中国专利局、申请号为201911050205.X、发明名称为“负载均衡方法、装置、介质及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 201911050205.X, and the invention title is "load balancing method, device, medium and equipment" on October 31, 2019, the entire content of which is incorporated by reference In this application.
技术领域Technical field
本文涉及网络通信技术领域,尤其涉及负载均衡方法、装置、介质及设备。This article relates to the field of network communication technology, in particular to load balancing methods, devices, media, and equipment.
背景技术Background technique
相关技术中,现有的7层负载均衡方案,都需要负载均衡器提供转发功能,导致负载均衡器有较高的负载,消耗较多的资源。同时如果负载均衡器和业务服务器混合部署,会导致网卡有额外的带宽消耗。In related technologies, the existing 7-layer load balancing schemes all require the load balancer to provide a forwarding function, which causes the load balancer to have a higher load and consume more resources. At the same time, if the load balancer and business server are deployed in a mixed manner, it will cause additional bandwidth consumption for the network card.
发明内容Summary of the invention
为克服相关技术中存在的问题,本文提供一种负载均衡方法、装置、介质及设备。In order to overcome the problems in related technologies, this article provides a load balancing method, device, medium and equipment.
根据本文的第一方面,提供一种负载均衡方法,包括:According to the first aspect of this article, a load balancing method is provided, including:
接收第一负载均衡器转发的客户端的请求报文;Receiving the request message of the client forwarded by the first load balancer;
与客户端建立连接,并生成扩展信息;Establish a connection with the client and generate extended information;
解析所述客户端的请求报文,基于设定的负载均衡规则,确定业务服务器;Parse the request message of the client, and determine the service server based on the set load balancing rule;
发送所述客户端的请求报文及扩展信息至确定的业务服务器。Send the client's request message and extended information to the determined service server.
当所确定的业务服务器与所述第二负载均衡器分别部署在不同服务器上时,所述负载均衡方法还包括:When the determined service server and the second load balancer are separately deployed on different servers, the load balancing method further includes:
所述发送客户端的请求报文及扩展信息至确定的业务服务器后,清理与客户端连接时的相关数据信息。After the request message and extended information of the client are sent to the determined service server, the related data information when connecting with the client is cleared.
如所述确定的业务服务器为本机服务器,所述接收第一负载均衡器转发的 客户端的请求报文为同一个连接内的不同请求报文时,解析所述请求报文,基于设定的负载均衡规则,确定业务服务器。If the determined service server is the local server, and when the request message of the client forwarded by the first load balancer is different request messages in the same connection, the request message is parsed based on the set Load balancing rules determine the business server.
所述扩展信息包括:The extended information includes:
与所述客户端的连接所用协议包含的相关信息,业务服务器解析并响应所述请求报文所需的信息。The relevant information contained in the protocol used for the connection with the client, and the information required by the service server to parse and respond to the request message.
负载均衡方法应用于业务服务器,包括:Load balancing methods are applied to business servers, including:
获取客户端的请求报文及扩展信息;Obtain the client's request message and extended information;
基于所述扩展信息,处理所述请求报文,生成响应报文,并发送所述响应报文至所述客户端。Based on the extended information, process the request message, generate a response message, and send the response message to the client.
当所述业务服务器与所述第二负载均衡器分别部署在不同服务器上时,所述负载均衡方法还包括:When the service server and the second load balancer are separately deployed on different servers, the load balancing method further includes:
发送迁移通知信息至第一负载均衡器;Sending the migration notification information to the first load balancer;
接收第一负载均衡器发送的客户端的请求报文。Receive the client's request message sent by the first load balancer.
负载均衡方法应用于第一负载均衡器,包括:The load balancing method is applied to the first load balancer and includes:
接收客户端的请求报文;Receive the client's request message;
转发所述请求报文至第二负载均衡器;Forward the request message to the second load balancer;
接收业务服务器发送的业务迁移通知;Receive the service migration notification sent by the service server;
转发所述客户端的请求报文至所述业务服务器。Forward the request message of the client to the service server.
根据本文的另一方面,提供一种负载均衡装置,应用于第二负载均衡器包括:According to another aspect of this article, a load balancing device is provided, which is applied to a second load balancer and includes:
第二接收模块,用于接收第一负载均衡器转发的客户端的请求报文;The second receiving module is configured to receive the request message of the client forwarded by the first load balancer;
连接模块,用于与客户端建立连接,并生成扩展信息;The connection module is used to establish a connection with the client and generate extended information;
均衡模块,用于解析所述客户端的请求报文,基于设定的负载均衡规则,确定业务服务器;The balance module is used to parse the request message of the client, and determine the service server based on the set load balancing rule;
第二转发模块,用于转发所述端的请求报文及连接信息至确定的业务服务器。The second forwarding module is used to forward the request message and connection information of the terminal to the determined service server.
当所确定的业务服务器与所述第二负载均衡器分别部署在不同服务器上时,所述第二发送模块还用于:When the determined service server and the second load balancer are respectively deployed on different servers, the second sending module is further configured to:
在发送客户端的请求报文及扩展信息至确定的业务服务器后,清理与客户端连接时的相关数据信息。After sending the client's request message and extended information to the determined service server, the related data information when connecting with the client is cleaned up.
如所述确定的业务服务器为本机服务器,所述接收第一负载均衡器转发的客户端的请求报文为同一个连接内的不同请求报文时,解析所述请求报文,基于设定的负载均衡规则,确定业务服务器。If the determined service server is the local server, and when the request message of the client forwarded by the first load balancer is different request messages in the same connection, the request message is parsed based on the set Load balancing rules determine the business server.
所述扩展信息包括:The extended information includes:
与所述客户端的连接所用协议包含的相关信息,业务服务器解析并响应所述请求报文所需的信息。The relevant information contained in the protocol used for the connection with the client, and the information required by the service server to parse and respond to the request message.
负载均衡装置应用于业务服务器,包括:The load balancing device is applied to the business server, including:
第三接收模块,用于获取客户端的请求报文及扩展信息;The third receiving module is used to obtain the client's request message and extended information;
响应模块,用于基于连接信息,处理所述请求报文,生成响应报文;发送响应报文至所述客户端。The response module is configured to process the request message based on the connection information, and generate a response message; and send the response message to the client.
当所述业务服务器与所述第二负载均衡器分别部署在不同服务器上时,所述负载均衡装置还包括:When the service server and the second load balancer are respectively deployed on different servers, the load balancing device further includes:
发送模块,用于发送迁移通知信息至第一负载均衡器。The sending module is used to send the migration notification information to the first load balancer.
负载均衡装置应用于第一负载均衡器,包括:The load balancing device is applied to the first load balancer and includes:
第一接收模块,用于接收客户端的请求报文;The first receiving module is used to receive a request message from the client;
第一转发模块,用于转发所述请求报文至第二负载均衡器;The first forwarding module is configured to forward the request message to the second load balancer;
迁移通知接收模块,用于接收业务服务器发送的业务迁移通知;The migration notification receiving module is used to receive the business migration notification sent by the business server;
迁移模块,用于转发所述客户端的请求报文至所述业务服务器。The migration module is used to forward the request message of the client to the service server.
根据本文的另一方面,提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被执行时实现负载均衡方法的步骤。According to another aspect of this document, there is provided a computer-readable storage medium with a computer program stored thereon, which implements the steps of the load balancing method when the computer program is executed.
根据本文的另一方面,提供一种计算机设备,包括处理器、存储器和存储于所述存储器上的计算机程序,所述处理器执行所述计算机程序时实现负载均衡方法的步骤。According to another aspect of this document, a computer device is provided, including a processor, a memory, and a computer program stored on the memory, and the processor implements the steps of the load balancing method when the computer program is executed by the processor.
本文通过设置第一负载均衡器,第二负载均衡器,可以实现第二负载均衡器消耗较少的带宽资源,即可实现精细的负载调度,更便于负载均衡器和业务服务器的混合部署,减少混合部署对网卡带宽的损耗,同时由业务服务器将响应报文直接发送给客户端,减轻负载均衡器的负担。By setting the first load balancer and the second load balancer, this article can realize that the second load balancer consumes less bandwidth resources, and can achieve fine load scheduling, which is more convenient for the mixed deployment of load balancers and business servers, and reduces Hybrid deployment consumes the bandwidth of the network card, and at the same time, the service server sends the response message directly to the client, reducing the burden of the load balancer.
附图说明Description of the drawings
此处所说明的附图用来提供对本发明实施例的进一步理解,构成本申请的一部分,本发明实施例的示意性实施例及其说明用于解释本发明实施例,并不构成对本发明实施例的不当限定。在附图中:The drawings described here are used to provide a further understanding of the embodiments of the present invention and constitute a part of this application. The schematic embodiments of the embodiments of the present invention and their descriptions are used to explain the embodiments of the present invention, and do not constitute an example of the embodiments of the present invention. Improper qualification. In the attached picture:
图1是根据一示例性实施例示出的一种负载均衡方法的流程图。Fig. 1 is a flow chart showing a load balancing method according to an exemplary embodiment.
图2是根据一示例性实施例示出的一种负载均衡方法的流程图。Fig. 2 is a flow chart showing a load balancing method according to an exemplary embodiment.
图3是根据一示例性实施例示出的一种负载均衡方法的流程图。Fig. 3 is a flow chart showing a load balancing method according to an exemplary embodiment.
图4是根据一示例性实施例示出的一种负载均衡示意图。Fig. 4 is a schematic diagram showing a load balancing according to an exemplary embodiment.
图5是根据一示例性实施例示出的一种负载均衡装置的框图。Fig. 5 is a block diagram showing a load balancing device according to an exemplary embodiment.
图6是根据一示例性实施例示出的一种负载均衡装置的框图。Fig. 6 is a block diagram showing a load balancing device according to an exemplary embodiment.
图7是根据一示例性实施例示出的一种负载均衡装置的框图。Fig. 7 is a block diagram showing a load balancing device according to an exemplary embodiment.
图8是根据一示例性实施例示出的一种负载均衡装置的框图。Fig. 8 is a block diagram showing a load balancing device according to an exemplary embodiment.
图9是根据一示例性实施例示出的一种计算机设备的框图。Fig. 9 is a block diagram showing a computer device according to an exemplary embodiment.
具体实施方式Detailed ways
现结合附图和具体实施方式对本发明实施例进一步说明。The embodiments of the present invention will now be further described with reference to the drawings and specific implementations.
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明的一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互任意组合。In order to make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments They are a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention. It should be noted that the embodiments in this application and the features in the embodiments can be combined with each other arbitrarily if there is no conflict.
本文中的负载均衡方法中,设置第一负载均衡器,接收客户端的请求,根据一定的负载均衡规则,例如第二负载均衡器的地址位置,第二负载均衡器的负载程度,将客户端的请求转发至第二负载均衡器。本文中,第一负载均衡器,可以为4层负载均衡器,即可满足使用要求。也可以选择其他类型的负载均衡器,只是不进行针对内容的均衡。具体负载均衡器的类型,本文不做限制。由第二负载均衡器对客户端的请求进行解析,根据业务报文的内容或其他因素决定负载均衡的结果,确定具体的业务服务器,实现精细的负载调度,由确定的业务服务器对客户端的请求进行响应。In the load balancing method in this article, the first load balancer is set to receive client requests, and according to certain load balancing rules, such as the address location of the second load balancer, the load level of the second load balancer, and the client request Forward to the second load balancer. In this article, the first load balancer can be a 4-layer load balancer, which can meet the usage requirements. You can also choose other types of load balancers, but do not balance the content. The specific type of load balancer is not limited in this article. The second load balancer parses the client's request, determines the result of load balancing according to the content of the business message or other factors, determines the specific business server, and implements fine load scheduling. The determined business server performs the client's request response.
图1是根据一示例性实施例示出的一种负载均衡方法的流程图。参考图1,负载均衡方法应用于第二负载均衡器,包括:Fig. 1 is a flow chart showing a load balancing method according to an exemplary embodiment. Referring to Figure 1, the load balancing method applied to the second load balancer includes:
步骤S11,接收第一负载均衡器转发的客户端的请求报文;Step S11, receiving the request message of the client forwarded by the first load balancer;
步骤S12,与客户端建立连接,生成扩展信息;Step S12, establishing a connection with the client to generate extended information;
步骤S13,解析所述客户端的请求报文,基于设定的负载均衡规则,确定业务服务器;Step S13, parse the request message of the client, and determine the service server based on the set load balancing rule;
步骤S14,发送所述客户端的请求报文及扩展信息至确定的业务服务器。Step S14: Send the client's request message and extended information to the determined service server.
本实施例中,第二负载均衡器接收到第一负载均衡器转发的客户端的请求报文后,先与客户端建立连接,并生成和连接相关的扩展信息。解析客户端的请求报文,综合客户端IP、业务服务器负载、业务请求的资源分布和类型等特征、负载均衡器的配置等信息确定用于响应该客户端请求报文的业务服务器,将客户端请求报文和扩展信息发送给确定的业务服务器。在第二负载均衡器发送客户端的请求报文时,也会对报文内容进行整理,如删除重复报文,删除与客户端握手过程中的无用报文,仅将业务服务器解析并响应客户端请求的报文发送到业务服务器,尽可能地减少对资源的消耗。In this embodiment, after receiving the request message of the client forwarded by the first load balancer, the second load balancer first establishes a connection with the client, and generates extension information related to the connection. Analyze the client’s request message, integrate the client’s IP, service server load, the resource distribution and type of the service request, and the configuration of the load balancer to determine the service server used to respond to the client’s request message. The request message and extended information are sent to the determined service server. When the second load balancer sends the client's request message, it will also organize the message content, such as deleting duplicate messages, deleting useless messages in the handshake process with the client, and only parses the business server and responds to the client The requested message is sent to the service server to reduce resource consumption as much as possible.
为了提高负载均衡效果,业务均衡器可与业务服务器混合部署,即业务均衡器和业务服务器为同一服务器,在业务均衡器和业务服务器混合部署时,业务均衡器使用普通的HTTP代理转发或TCP代理转发、共享内存等方式,将客户端请求转发给本机的业务服务器处理。In order to improve the load balancing effect, the business balancer can be deployed with the business server, that is, the business balancer and the business server are the same server. When the business balancer and the business server are deployed together, the business balancer uses ordinary HTTP proxy forwarding or TCP proxy Forwarding, shared memory, etc., forward the client request to the local business server for processing.
在一实施例中,如果业务均衡器和业务服务器分开部署,即业务均衡器和业务服务器分别部署在不同服务器上时,负载均衡方法还包括:在发送客户端的请求报文及扩展信息至确定的业务服务器后,清理与客户端连接时的相关数 据信息。在本实施例中,负载均衡器和业务服务器所在的运行环境不是相同的,例如运行在不同的内核上,或者运行在相互隔离的环境中。由于运行环境不同,导致客户端连接的相关数据不能共享,所以在将客户端的请求报文及扩展信息发送给确定的业务服务器后,负载均衡器需要清理与客户端连接时的相关数据信息。当第二负载均衡器将客户端的请求报文及扩展信息发送至确定的业务服务器后,业务服务器可以根据扩展信息解析并响应客户端请求,并将响应报文直接发送给客户端,响应报文不再经第二负载均衡器转发,同时,业务服务器会发送业务迁移通知给第一负载均衡器,该客户端的后续的请求报文也不再通过第二负载均衡器处理。因此本实施例中,第二负载均衡器及时清理与客户端连接时产生的相关数据,提升第二负载均衡器的性能。In an embodiment, if the service balancer and the service server are separately deployed, that is, when the service balancer and the service server are separately deployed on different servers, the load balancing method further includes: sending the client's request message and the extended information to a certain After the business server, clean up the relevant data information when connecting with the client. In this embodiment, the operating environment where the load balancer and the business server are located are not the same, for example, they run on different cores, or run in an isolated environment. Due to different operating environments, the data related to the client connection cannot be shared. Therefore, after sending the client's request message and extended information to the determined service server, the load balancer needs to clean up the related data information when connecting with the client. After the second load balancer sends the client's request message and extended information to the determined service server, the service server can parse and respond to the client request according to the extended information, and send the response message directly to the client, and the response message It is no longer forwarded by the second load balancer, and at the same time, the service server will send a service migration notification to the first load balancer, and subsequent request packets of the client will no longer be processed by the second load balancer. Therefore, in this embodiment, the second load balancer cleans up related data generated when connecting with the client in time, so as to improve the performance of the second load balancer.
在一实施例中,如确定的业务服务器为本机服务器,接收第一负载均衡器转发的客户端的请求报文为同一个连接内的不同请求报文时,解析请求报文,基于设定的负载均衡规则,确定业务服务器。在第二负载均衡器与客户端建立连接后,同一连接中可能会同时有多个请求报文,第二负载均衡器根据客户端的请求报文确定由本机服务器进行响应后,在收到同一连接的后续报文时,并不直接将该连接中的其他请求报文都转发到本机服务器进行处理,而是会根据每一报文的内容,重新确定业务服务器,从而将同一客户端同一连接内的不同内容的请求报文发送至不同的业务服务器,由适合的业务服务器来处理客户端的不同请求,提高服务质量。In an embodiment, if the determined service server is the local server, and the request message from the client forwarded by the first load balancer is received as different request messages in the same connection, the request message is parsed based on the set Load balancing rules determine the business server. After the second load balancer establishes a connection with the client, there may be multiple request packets in the same connection at the same time. The second load balancer determines that the local server responds according to the client's request packet and receives the same When connecting subsequent messages, it does not directly forward all other request messages in the connection to the local server for processing. Instead, it re-determines the service server according to the content of each message, so that the same client is the same The request messages with different contents in the connection are sent to different service servers, and the suitable service server processes the different requests of the client to improve the quality of service.
在一实施例中,扩展信息包括:与所述客户端的连接所用协议包含的相关信息,业务服务器解析并响应所述请求报文所需的信息。In an embodiment, the extended information includes: relevant information included in the protocol used for the connection with the client, and the information required by the service server to parse and respond to the request message.
与客户端的连接所用协议包含的相关信息,可以为负载均衡器与客户端建立连接时协商的参数,负载均衡器的配置信息,负载均衡器与客户端的连接状态;当客户端的请求报文为HTTPS报文时,还包括负载均衡器与客户端建立的TLS加密隧道的状态信息中的一种或者多种,当然,在特殊情况下,还可能包括其他信息。业务服务器解析并响应请求报文所需的信息可以为客户端地址信息,第一负载均衡器地址信息,以便发送迁移通知给第一负载均衡器,发送响应报文至客户端。在本文的负载均衡方法中,上述信息为业务服务器必须的信息中的几种,并非全部。在本文负载均衡方法中,第二负载均衡器与客户端建立连接,为了使业务服务器能够响应客户端的请求,第二负载均衡器需要将与客户 端建立连接时的相关信息发送给业务服务器。业务服务器根据第二负载均衡器与客户端建立连接时协商的参数,解析客户端的请求报文,响应客户端的请求,并根据客户端的地址信息,将响应报文发送给客户端。如果客户端的请求报文为HTTPS报文,负载均衡器与客户端建立TLS的加密隧道,因此在扩展信息中还会包括加密隧道的状态信息,如加密秘钥等,业务服务器使用加密秘钥,就可以解析客户端的加密请求了。同时,也要将客户端的地址信息,第一负载均衡器的地址信息发送给业务服务器,以便业务服务器可以发送业务迁移通知至第一负载均衡器,发送响应报文至客户端。The relevant information contained in the protocol used for the connection with the client can be the parameters negotiated when the load balancer establishes a connection with the client, the configuration information of the load balancer, and the connection status between the load balancer and the client; when the client's request message is HTTPS The message also includes one or more of the status information of the TLS encrypted tunnel established between the load balancer and the client. Of course, in special circumstances, it may also include other information. The information required by the service server to parse and respond to the request message may be client address information and first load balancer address information in order to send a migration notification to the first load balancer and send a response message to the client. In the load balancing method of this article, the above information is some of the necessary information for the business server, but not all of them. In the load balancing method herein, the second load balancer establishes a connection with the client. In order to enable the service server to respond to the client's request, the second load balancer needs to send relevant information when establishing a connection with the client to the service server. The business server parses the client's request message according to the parameters negotiated when the second load balancer establishes a connection with the client, responds to the client's request, and sends the response message to the client according to the client's address information. If the client's request message is an HTTPS message, the load balancer establishes a TLS encrypted tunnel with the client. Therefore, the extended information will also include the state information of the encrypted tunnel, such as the encryption key. The business server uses the encryption key. You can parse the client's encrypted request. At the same time, the address information of the client and the address information of the first load balancer should also be sent to the service server, so that the service server can send a service migration notification to the first load balancer and send a response message to the client.
图2是根据一示例性实施例示出的一种负载均衡方法的流程图。参考图2,负载均衡方法应用于业务服务器,包括:Fig. 2 is a flow chart showing a load balancing method according to an exemplary embodiment. Referring to Figure 2, the load balancing method is applied to the business server, including:
步骤S21,获取客户端的请求报文及扩展信息;Step S21: Obtain the client's request message and extended information;
步骤S22,基于扩展信息,处理请求报文,生成响应报文;Step S22, processing the request message based on the extended information, and generating a response message;
步骤S23,发送响应报文至客户端。Step S23: Send a response message to the client.
在本实施例中,业务服务器获取客户端的请求报文及扩展信息。扩展信息是第二负载均衡器和客户端建立连接时生成的和连接相关的信息,用于解析客户端请求。业务服务器处理请求报文,生成的相应报文不再发送给第二负载均衡器,也不必发送给第一负载均衡器,而是直接发送给客户端,减轻第二负载均衡器和第一负载均衡器的资源消耗。In this embodiment, the service server obtains the client's request message and extended information. The extended information is connection-related information generated when the second load balancer establishes a connection with the client, and is used to parse the client request. The service server processes the request message, and the generated corresponding message is no longer sent to the second load balancer, nor does it need to be sent to the first load balancer, but directly sent to the client to reduce the second load balancer and the first load The resource consumption of the equalizer.
在一实施例中,如果业务服务器和第二负载均衡器分别部署在不同服务器上,负载均衡方法还包括:In an embodiment, if the service server and the second load balancer are deployed on different servers, the load balancing method further includes:
发送迁移通知信息至第一负载均衡器;接收第一负载均衡器发送的客户端的请求报文。通知第一负载均衡器,已经根据负载均衡规则确定了业务服务器,该客户端的请求不必再发往第二负载均衡器,可直接发送到业务服务器,由业务服务器来响应客户端的请求。进一步降低第二负载均衡器的资源消耗。Send the migration notification information to the first load balancer; receive the client's request message sent by the first load balancer. Notify the first load balancer that the service server has been determined according to the load balancing rules, and the client's request does not need to be sent to the second load balancer, but can be sent directly to the service server, and the service server responds to the client's request. Further reduce the resource consumption of the second load balancer.
当业务服务器完成一组交互后,可以断开与客户端的连接,并通知第一负载均衡器,或者,将连接发送回第一负载均衡器,当该连接再有客户端请求报文到来时,按上述步骤,将请求报文发送到第二负载均衡器,由第二负载均衡器在根据解析内容确定具体地业务服务器提供服务。After the service server completes a set of interactions, it can disconnect from the client and notify the first load balancer, or send the connection back to the first load balancer. When another client request message arrives for the connection, According to the above steps, the request message is sent to the second load balancer, and the second load balancer determines the specific service server to provide services according to the parsed content.
图3是根据一示例性实施例示出的一种负载均衡方法的流程图。参考图3, 负载均衡方法应用于第一负载均衡器,包括:Fig. 3 is a flow chart showing a load balancing method according to an exemplary embodiment. Referring to FIG. 3, the load balancing method applied to the first load balancer includes:
步骤S31,接收客户端的请求报文;Step S31, receiving a request message from the client;
步骤S32,转发请求报文至第二负载均衡器;Step S32, forward the request message to the second load balancer;
步骤S33,接收业务服务器发送的业务迁移通知;Step S33, receiving a service migration notification sent by the service server;
步骤S34,转发客户端的请求报文至业务服务器。Step S34, forward the request message of the client to the service server.
在本实施例中,第一负载均衡器负责接收客户端请求,将客户端请求转发至第二负载均衡器,并不对客户端的请求进行解析,不负责进一步的针对内容的负载均衡。In this embodiment, the first load balancer is responsible for receiving client requests, forwarding the client requests to the second load balancer, and does not parse the client requests, and is not responsible for further load balancing for content.
当第二负载均衡器根据均衡结果确定了业务服务器,如果业务服务器和第二负载均衡器分别部署在不同服务器上,业务服务器会发送业务迁移通知至第一负载均衡器,第一负载均衡器接收到业务迁移通知后,会将客户端的请求报文直接转发至业务服务器,而不再发送到第二负载均衡器,减少系统内的资源消耗。When the second load balancer determines the business server according to the balance result, if the business server and the second load balancer are deployed on different servers, the business server will send a business migration notification to the first load balancer, and the first load balancer will receive After the service migration notification, the client's request message will be directly forwarded to the service server instead of being sent to the second load balancer, reducing resource consumption in the system.
为更好地理解本文中的负载均衡方法,举例说明:In order to better understand the load balancing method in this article, give an example:
具体实施例,图4是根据一示例性实施例示出的一种负载均衡示意图。如图4所示,设置第一负载均衡器,接收客户端的请求报文后,转发到第二负载均衡器,由第二负载均衡器与客户端建立连接,并解析客户端的请求报文的内容,并根据报文内容和预设的负载均衡规则,确定业务服务器,将客户端的请求报文和连接有关的扩展信息发送到业务服务器。业务服务器接收到客户端的请求报文和扩展信息后,发送业务迁移通知给第一负载均衡器,通知第一负载均衡器将该客户端后续的请求报文转发送到业务服务器。业务服务器基于扩展信息来响应客户端的请求,并将响应信息直接发送给客户端。Specific embodiments, Fig. 4 is a schematic diagram showing a load balancing according to an exemplary embodiment. As shown in Figure 4, the first load balancer is set up, and after receiving the client's request message, it is forwarded to the second load balancer, and the second load balancer establishes a connection with the client, and parses the content of the client's request message , And according to the message content and preset load balancing rules, determine the business server, and send the client's request message and connection-related extended information to the business server. After receiving the request message and extended information of the client, the service server sends a service migration notification to the first load balancer to notify the first load balancer to forward the client's subsequent request message to the service server. The business server responds to the client's request based on the extended information, and sends the response information directly to the client.
综上所述,通过本文的负载均衡方法,响应报文由业务服务器直接发送给客户端,第二负载均衡器消耗较少的带宽资源,即可实现精细的负载调度,更便于负载均衡器和业务服务器的混合部署,减少混合部署对网卡带宽的损耗。To sum up, through the load balancing method in this article, the response message is sent directly to the client by the business server, and the second load balancer consumes less bandwidth resources, which can achieve fine load scheduling, which is more convenient for the load balancer and The hybrid deployment of business servers reduces the loss of network card bandwidth caused by hybrid deployment.
图5是根据一示例性实施例示出的一种负载均衡装置的框图。参考图5,负载均衡装置应用于第二负载均衡器,包括,第二接收模块501,连接模块502,均衡模块503,第二转发模块504。Fig. 5 is a block diagram showing a load balancing device according to an exemplary embodiment. Referring to FIG. 5, the load balancing device is applied to the second load balancer, and includes a second receiving module 501, a connecting module 502, a balancing module 503, and a second forwarding module 504.
该第二接收模块501被配置为用于接收第一负载均衡器转发的客户端的请 求报文。The second receiving module 501 is configured to receive the request message of the client forwarded by the first load balancer.
该连接模块502被配置为用于与客户端建立连接,并生成扩展信息。The connection module 502 is configured to establish a connection with the client and generate extended information.
该均衡模块503被配置为用于解析所述客户端的请求报文,基于设定的负载均衡规则,确定业务服务器。The balancing module 503 is configured to parse the request message of the client, and determine the service server based on the set load balancing rule.
该第二转发模块504被配置为用于转发所述端的请求报文及连接信息至确定的业务服务器。The second forwarding module 504 is configured to forward the request message and connection information of the terminal to a determined service server.
该第二转发模块504还用于在发送客户端的请求报文及扩展信息至确定的业务服务器后,清理与客户端连接时的相关数据信息。The second forwarding module 504 is also used to clean up related data information when connecting with the client after sending the client's request message and extended information to the determined service server.
如确定的业务服务器为本机服务器,接收第一负载均衡器转发的客户端的请求报文为同一个连接内的不同请求报文时,解析请求报文,基于设定的负载均衡规则,确定业务服务器。For example, the determined business server is the local server, and when the client's request message forwarded by the first load balancer is received as a different request message in the same connection, the request message is parsed, and the business is determined based on the set load balancing rules. server.
扩展信息包括:The extended information includes:
与所述客户端的连接所用协议包含的相关信息,业务服务器解析并响应所述请求报文所需的信息。The relevant information contained in the protocol used for the connection with the client, and the information required by the service server to parse and respond to the request message.
图6是根据一示例性实施例示出的一种负载均衡装置的框图。参考图6,负载均衡装置应用于业务服务器,包括第三接收模块601,响应模块602。Fig. 6 is a block diagram showing a load balancing device according to an exemplary embodiment. Referring to FIG. 6, the load balancing device is applied to a service server, and includes a third receiving module 601 and a response module 602.
该第三接收模块601被配置为用于获取客户端的请求报文及扩展信息。The third receiving module 601 is configured to obtain the request message and extended information of the client.
该响应模块602被配置为用于基于连接信息,处理所述请求报文,生成响应报文;发送响应报文至所述客户端。The response module 602 is configured to process the request message based on the connection information, generate a response message, and send the response message to the client.
图7是根据一示例性实施例示出的一种负载均衡装置的框图。参考图7,当业务服务器与第二负载均衡器分别部署在不同服务器上时,负载均衡装置还包括发送模块701。Fig. 7 is a block diagram showing a load balancing device according to an exemplary embodiment. Referring to FIG. 7, when the service server and the second load balancer are respectively deployed on different servers, the load balancing apparatus further includes a sending module 701.
该发送模块701被配置为用于发送迁移通知信息至第一负载均衡器。The sending module 701 is configured to send migration notification information to the first load balancer.
图8是根据一示例性实施例示出的一种负载均衡装置的框图。参考图8,负载均衡装置应用于第一负载均衡器,包括第一接收模块801,第一转发模块802,迁移通知接收模块803,迁移模块804。Fig. 8 is a block diagram showing a load balancing device according to an exemplary embodiment. Referring to FIG. 8, the load balancing device is applied to the first load balancer, and includes a first receiving module 801, a first forwarding module 802, a migration notification receiving module 803, and a migration module 804.
该第一接收模块801被配置为用于接收客户端的请求报文。The first receiving module 801 is configured to receive a request message from the client.
该第一转发模块802被配置为用于转发请求报文至第二负载均衡器。The first forwarding module 802 is configured to forward the request message to the second load balancer.
该迁移通知接收模块803被配置为用于接收业务服务器发送的业务迁移通知。The migration notification receiving module 803 is configured to receive the service migration notification sent by the service server.
该迁移模块804被配置为用于转发所述客户端的请求报文至所述业务服务器。The migration module 804 is configured to forward the request message of the client to the service server.
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the device in the foregoing embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and detailed description will not be given here.
图9是根据一示例性实施例示出的一种计算机设备900的框图。例如,计算机设备900可以被提供为一服务器。参照图9,计算机设备900包括处理器901,处理器的个数可以根据需要设置为一个或者多个。计算机设备900还包括存储器902,用于存储可由处理器901的执行的指令,例如应用程序。存储器的个数可以根据需要设置一个或者多个。其存储的应用程序可以为一个或者多个。处理器901被配置为执行指令,以执行负载均衡方法。Fig. 9 is a block diagram showing a computer device 900 according to an exemplary embodiment. For example, the computer device 900 may be provided as a server. 9, the computer device 900 includes a processor 901, and the number of processors can be set to one or more as required. The computer device 900 further includes a memory 902 for storing instructions executable by the processor 901, such as application programs. The number of memories can be set to one or more as required. The stored application program can be one or more. The processor 901 is configured to execute instructions to perform the load balancing method.
本领域技术人员应明白,本文的实施例可提供为方法、装置(设备)、或计算机程序产品。因此,本文可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本文可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质上实施的计算机程序产品的形式。计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质,包括但不限于RAM、ROM、EEPROM、闪存或其他存储器技术、CD-ROM、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质等。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。Those skilled in the art should understand that the embodiments herein can be provided as a method, an apparatus (equipment), or a computer program product. Therefore, this specification may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this document may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program codes. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data) , Including but not limited to RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridge, magnetic tape, magnetic disk storage or other magnetic storage device, or can be used for Any other medium that stores desired information and can be accessed by a computer. In addition, as is well known to those of ordinary skill in the art, communication media usually contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as carrier waves or other transmission mechanisms, and may include any information delivery media. .
本文是参照根据本文实施例的方法、装置(设备)和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个 流程和/或方框图一个方框或多个方框中指定的功能的装置。This document is described with reference to flowcharts and/or block diagrams of methods, apparatuses (equipment) and computer program products according to the embodiments of this document. It should be understood that each process and/or block in the flowchart and/or block diagram, and the combination of processes and/or blocks in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device. The device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. The instructions provide steps for implementing the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括……”限定的要素,并不排除在包括所述要素的物品或者设备中还存在另外的相同要素。In this article, the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that an article or device that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed. Elements, or also include elements inherent to such items or equipment. If there are no more restrictions, the element defined by the sentence "including..." does not exclude the existence of another same element in the article or equipment that includes the element.
尽管已描述了本文的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本文范围的所有变更和修改。Although the preferred embodiments herein have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of this document.
显然,本领域的技术人员可以对本文进行各种改动和变型而不脱离本文的精神和范围。这样,倘若本文的这些修改和变型属于本文权利要求及其等同技术的范围之内,则本文的意图也包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to this article without departing from the spirit and scope of this article. In this way, if these modifications and variations of this article fall within the scope of the claims of this article and their equivalent technologies, the intent of this article also includes these modifications and variations.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制。尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例的技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention, but not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or equivalently replace some of the technical features; and these Modification or replacement does not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
工业实用性Industrial applicability
本发明的实施例提供了一种负载均衡的方法、装置。由第二负载均衡器接收第一负载均衡器转发的客户端的请求报文;与客户端建立连接,并生成扩展 信息;解析所述客户端的请求报文,基于设定的负载均衡规则,确定业务服务器;发送所述客户端的请求报文及扩展信息至确定的业务服务器。消耗较少的带宽资源,即可实现精细的负载调度,更便于负载均衡器和业务服务器的混合部署,减少混合部署对网卡带宽的损耗。The embodiment of the present invention provides a method and device for load balancing. The second load balancer receives the client's request message forwarded by the first load balancer; establishes a connection with the client and generates extended information; parses the client's request message, and determines the service based on the set load balancing rules Server; sending the client's request message and extended information to the determined service server. Consuming less bandwidth resources, you can achieve fine load scheduling, which is more convenient for the hybrid deployment of load balancers and business servers, and reduces the loss of network card bandwidth due to hybrid deployment.

Claims (16)

  1. 一种负载均衡方法,应用于第二负载均衡器,其特征在于,包括:A load balancing method applied to a second load balancer, characterized in that it includes:
    接收第一负载均衡器转发的客户端的请求报文;Receiving the request message of the client forwarded by the first load balancer;
    与所述客户端建立连接,并生成扩展信息;Establish a connection with the client and generate extended information;
    解析所述客户端的请求报文,基于设定的负载均衡规则,确定业务服务器;Parse the request message of the client, and determine the service server based on the set load balancing rule;
    发送所述客户端的请求报文及扩展信息至确定的业务服务器。Send the client's request message and extended information to the determined service server.
  2. 如权利要求1所述的负载均衡方法,其特征在于,当所述确定的业务服务器与所述第二负载均衡器分别部署在不同服务器上时,所述负载均衡方法还包括:The load balancing method according to claim 1, wherein when the determined service server and the second load balancer are deployed on different servers, the load balancing method further comprises:
    发送所述客户端的请求报文及扩展信息至确定的业务服务器后,清理与所述客户端连接时的相关数据信息。After sending the request message and extended information of the client to the determined service server, the related data information when connecting with the client is cleared.
  3. 如权利要求1所述的负载均衡方法,其特征在于,The load balancing method of claim 1, wherein:
    如所述确定的业务服务器为本机服务器,所述接收第一负载均衡器转发的客户端的请求报文为同一个连接内的不同请求报文时,解析所述请求报文,基于设定的负载均衡规则,确定业务服务器。If the determined service server is the local server, and when the request message of the client forwarded by the first load balancer is different request messages in the same connection, the request message is parsed based on the set Load balancing rules determine the business server.
  4. 如权利要求1-3任一所述的负载均衡方法,其特征在于,所述扩展信息包括:与所述客户端的连接所用协议包含的相关信息,业务服务器解析并响应所述请求报文所需的信息。The load balancing method according to any one of claims 1-3, wherein the extended information includes: related information contained in the protocol used for the connection with the client, and the service server needs to analyze and respond to the request Information.
  5. 一种负载均衡方法,应用于业务服务器,其特征在于,包括:A load balancing method applied to a business server, which is characterized in that it includes:
    获取客户端的请求报文及扩展信息;Obtain the client's request message and extended information;
    基于所述扩展信息,处理所述请求报文,生成响应报文,并发送所述响应报文至所述客户端。Based on the extended information, process the request message, generate a response message, and send the response message to the client.
  6. 如权利要求5所述的负载均衡方法,其特征在于,当所述业务服务器与所述第二负载均衡器分别部署在不同服务器上时,所述负载均衡方法还包括:5. The load balancing method of claim 5, wherein when the service server and the second load balancer are deployed on different servers, the load balancing method further comprises:
    发送迁移通知信息至第一负载均衡器;Sending the migration notification information to the first load balancer;
    接收所述第一负载均衡器发送的客户端的请求报文。Receiving a client request message sent by the first load balancer.
  7. 一种负载均衡方法,应用于第一负载均衡器,其特征在于,包括:A load balancing method applied to a first load balancer, characterized in that it includes:
    接收客户端的请求报文;Receive the client's request message;
    转发所述请求报文至第二负载均衡器;Forward the request message to the second load balancer;
    接收业务服务器发送的业务迁移通知;Receive the service migration notification sent by the service server;
    转发所述客户端的请求报文至所述业务服务器。Forward the request message of the client to the service server.
  8. 一种负载均衡装置,应用于第二负载均衡器,其特征在于,包括:A load balancing device applied to a second load balancer, characterized in that it comprises:
    第二接收模块,用于接收第一负载均衡器转发的客户端的请求报文;The second receiving module is configured to receive the request message of the client forwarded by the first load balancer;
    连接模块,用于与客户端建立连接,并生成扩展信息;The connection module is used to establish a connection with the client and generate extended information;
    均衡模块,用于解析所述客户端的请求报文,基于设定的负载均衡规则,确定业务服务器;The balance module is used to parse the request message of the client, and determine the service server based on the set load balancing rule;
    第二转发模块,用于转发所述端的请求报文及连接信息至确定的业务服务器。The second forwarding module is used to forward the request message and connection information of the terminal to the determined service server.
  9. 如权利要求8所述的负载均衡装置,其特征在于,当所述确定的业务服务器与所述第二负载均衡器分别部署在不同服务器上时,所述第二发送模块还用于:8. The load balancing device according to claim 8, wherein when the determined service server and the second load balancer are respectively deployed on different servers, the second sending module is further configured to:
    在发送所述客户端的请求报文及扩展信息至所述确定的业务服务器后,清理与所述客户端连接时的相关数据信息。After sending the request message and extended information of the client to the determined service server, the related data information when connecting with the client is cleared.
  10. 如权利要求8所述的负载均衡转置,其特征在于,如所述确定的业务服务器为本机服务器,所述接收所述第一负载均衡器转发的所述客户端的请求报文为同一个连接内的不同请求报文时,解析所述请求报文,基于设定的负载均衡规则,确定业务服务器。The load balancing transposition according to claim 8, wherein, if the determined service server is a local server, the client request packets forwarded by the first load balancer are the same When different request messages in the connection are connected, the request message is parsed, and the service server is determined based on the set load balancing rule.
  11. 如权利要求8-10任一所述的负载均衡装置,其特征在于,所述扩展信息包括:10. The load balancing device according to any one of claims 8-10, wherein the extended information comprises:
    与所述客户端的连接所用协议包含的相关信息,业务服务器解析并响应所述请求报文所需的信息。The relevant information contained in the protocol used for the connection with the client, and the information required by the service server to parse and respond to the request message.
  12. 一种负载均衡装置,应用于业务服务器,其特征在于,包括:A load balancing device applied to a business server, which is characterized in that it includes:
    第三接收模块,用于获取客户端的请求报文及扩展信息;The third receiving module is used to obtain the client's request message and extended information;
    响应模块,用于基于连接信息,处理所述请求报文,生成响应报文;发送响应报文至所述客户端。The response module is configured to process the request message based on the connection information, and generate a response message; and send the response message to the client.
  13. 如权利要求12所述的负载均衡装置,其特征在于,当所述业务服务器与所述第二负载均衡器分别部署在不同服务器上时,所述负载均衡装置还包括:11. The load balancing device of claim 12, wherein when the service server and the second load balancer are deployed on different servers, the load balancing device further comprises:
    发送模块,用于发送迁移通知信息至第一负载均衡器。The sending module is used to send the migration notification information to the first load balancer.
  14. 一种负载均衡装置,应用于第一负载均衡器,其特征在于,包括:A load balancing device applied to a first load balancer, characterized in that it comprises:
    第一接收模块,用于接收客户端的请求报文;The first receiving module is used to receive a request message from the client;
    第一转发模块,用于转发所述请求报文至第二负载均衡器;The first forwarding module is configured to forward the request message to the second load balancer;
    迁移通知接收模块,用于接收业务服务器发送的业务迁移通知;The migration notification receiving module is used to receive the business migration notification sent by the business server;
    迁移模块,用于转发所述客户端的请求报文至所述业务服务器。The migration module is used to forward the request message of the client to the service server.
  15. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被执行时实现如权利要求1-7中任意一项所述方法的步骤。A computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the method according to any one of claims 1-7 when the computer program is executed.
  16. 一种计算机设备,包括处理器、存储器和存储于所述存储器上的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1-7中任意一项所述方法的步骤。A computer device, comprising a processor, a memory, and a computer program stored on the memory, wherein the processor implements the method according to any one of claims 1-7 when the processor executes the computer program step.
PCT/CN2020/124872 2019-10-31 2020-10-29 Load balancing method and apparatus, and medium and device WO2021083281A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911050205.XA CN112751897B (en) 2019-10-31 2019-10-31 Load balancing method, device, medium and equipment
CN201911050205.X 2019-10-31

Publications (1)

Publication Number Publication Date
WO2021083281A1 true WO2021083281A1 (en) 2021-05-06

Family

ID=75641475

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/124872 WO2021083281A1 (en) 2019-10-31 2020-10-29 Load balancing method and apparatus, and medium and device

Country Status (2)

Country Link
CN (1) CN112751897B (en)
WO (1) WO2021083281A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113452778A (en) * 2021-06-25 2021-09-28 中国农业银行股份有限公司 Session keeping method, device, equipment, system and storage medium
CN113746933A (en) * 2021-09-14 2021-12-03 京东科技信息技术有限公司 Method and device for displaying information
CN114039981A (en) * 2021-11-11 2022-02-11 中国建设银行股份有限公司 Message processing method, device, server and storage medium
CN115134227A (en) * 2022-06-17 2022-09-30 京东科技信息技术有限公司 Method and apparatus for maintaining server
CN117692255A (en) * 2024-02-02 2024-03-12 北京首信科技股份有限公司 Method and device for dynamically expanding AAA service and electronic equipment
CN117692255B (en) * 2024-02-02 2024-04-30 北京首信科技股份有限公司 Method and device for dynamically expanding AAA service and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102436401A (en) * 2011-12-16 2012-05-02 北京邮电大学 Load balancing system and method
US20140258496A1 (en) * 2011-09-23 2014-09-11 Baidu Online Network Technology (Beijing) Co., Ltd Data centre system and method for a data centre to provide service
CN106230992A (en) * 2016-09-28 2016-12-14 中国银联股份有限公司 A kind of load-balancing method and load balancing node
CN106790675A (en) * 2017-01-23 2017-05-31 天地融科技股份有限公司 Load-balancing method, equipment and system in a kind of cluster
CN108536574A (en) * 2017-03-01 2018-09-14 北京嘀嘀无限科技发展有限公司 The method and device of application program debugging

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104202386B (en) * 2014-08-27 2018-09-14 四川长虹电器股份有限公司 A kind of high concurrent amount distributed file system and its secondary load equalization methods
CN105897827A (en) * 2015-11-27 2016-08-24 乐视云计算有限公司 Server node, local area network server cluster and realizing method thereof
US10237187B2 (en) * 2016-04-29 2019-03-19 Citrix Systems, Inc. System and method for service chain load balancing
CN109218355B (en) * 2017-06-30 2021-06-15 华为技术有限公司 Load balancing engine, client, distributed computing system and load balancing method
CN109040040B (en) * 2018-07-20 2021-07-27 网易(杭州)网络有限公司 Information sending method and device, storage medium and electronic device
CN110389839B (en) * 2019-07-24 2020-10-09 中南民族大学 Request-based hierarchical structure load balancing method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140258496A1 (en) * 2011-09-23 2014-09-11 Baidu Online Network Technology (Beijing) Co., Ltd Data centre system and method for a data centre to provide service
CN102436401A (en) * 2011-12-16 2012-05-02 北京邮电大学 Load balancing system and method
CN106230992A (en) * 2016-09-28 2016-12-14 中国银联股份有限公司 A kind of load-balancing method and load balancing node
CN106790675A (en) * 2017-01-23 2017-05-31 天地融科技股份有限公司 Load-balancing method, equipment and system in a kind of cluster
CN108536574A (en) * 2017-03-01 2018-09-14 北京嘀嘀无限科技发展有限公司 The method and device of application program debugging

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113452778A (en) * 2021-06-25 2021-09-28 中国农业银行股份有限公司 Session keeping method, device, equipment, system and storage medium
CN113452778B (en) * 2021-06-25 2023-10-13 中国农业银行股份有限公司 Session holding method, device, equipment, system and storage medium
CN113746933A (en) * 2021-09-14 2021-12-03 京东科技信息技术有限公司 Method and device for displaying information
CN114039981A (en) * 2021-11-11 2022-02-11 中国建设银行股份有限公司 Message processing method, device, server and storage medium
CN114039981B (en) * 2021-11-11 2024-04-02 中国建设银行股份有限公司 Message processing method, device, server and storage medium
CN115134227A (en) * 2022-06-17 2022-09-30 京东科技信息技术有限公司 Method and apparatus for maintaining server
CN117692255A (en) * 2024-02-02 2024-03-12 北京首信科技股份有限公司 Method and device for dynamically expanding AAA service and electronic equipment
CN117692255B (en) * 2024-02-02 2024-04-30 北京首信科技股份有限公司 Method and device for dynamically expanding AAA service and electronic equipment

Also Published As

Publication number Publication date
CN112751897A (en) 2021-05-04
CN112751897B (en) 2022-08-26

Similar Documents

Publication Publication Date Title
WO2021083281A1 (en) Load balancing method and apparatus, and medium and device
US10341427B2 (en) Forwarding policies on a virtual service network
KR102519409B1 (en) Method and Apparatus for Multipath Media Delivery
US9215275B2 (en) System and method to balance servers based on server load status
WO2021083284A1 (en) Load balancing method and apparatus, medium and device
US20150333930A1 (en) Dynamic service function chaining
US10547647B2 (en) Intra-carrier and inter-carrier network security system
CN106254235B (en) Load sharing method and equipment
US20210297896A1 (en) Wireless communication system
US9917871B2 (en) Optimizing media bitrate with explicit network feedback on one client only
CN102916906B (en) One realizes the adaptive method of application performance, Apparatus and system
CN108124002A (en) A kind of data transmission method for uplink and device
CN116633934A (en) Load balancing method, device, node and storage medium
CN105897853A (en) Peer-to-peer network connection method and device
EP3016324A1 (en) Method and apparatus for establishing path on network
Caviglione et al. A deep analysis on future web technologies and protocols over broadband GEO satellite networks
US10623279B2 (en) Method and network entity for control of value added service (VAS)
US11671515B2 (en) Methods, network node and client device for acquisition and delivery of resources in a communications network
CN111866100A (en) Method, device and system for controlling data transmission rate
CN101599887A (en) The transmission method of data and equipment in the peer-to-peer network
CN112055083B (en) Request processing method and device, electronic equipment and medium
US20230379677A1 (en) Handling events in a network
CN103188167B (en) Quality of service support method, device and system
US11381648B2 (en) Method and apparatus for data interchange
CN107196984A (en) A kind of sharing method of metadata, metadata sources equipment and network intermediary device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20882735

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20882735

Country of ref document: EP

Kind code of ref document: A1