Communication method and device based on load balancing and computer program product
By allowing clients to communicate directly with the backend server in the load balancing server, the concurrency capability limitation and resource waste caused by the backend server waiting for forwarding requests in the prior art is solved, and more efficient processing and resource utilization are achieved.
Patent Information
- Application Number
- CN202411013234.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-11-22
AI Technical Summary
In the existing load balancing technology, the back-end server needs to wait for the load balancing server to forward the requests in turn, resulting in limited processing concurrency capabilities and waste of resources.
After the load balancing server forwards the handshake signal when the client establishes a communication connection with the backend server, it allows the client and the backend server to directly exchange data, reducing the load balancing server's participation in data forwarding.
Shorten the processing path, improve processing efficiency, allow multiple backend servers to communicate with clients at the same time, reduce resource waste, and improve concurrency capabilities.
Smart Images

Figure CN119011593A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer communication technology, and in particular to a communication method, device and computer program product based on load balancing. Background Art
[0002] Most cloud environment application systems use server cluster technology. Clusters deploy the same service on multiple servers to form a cluster that provides services to the outside world. These clusters can be Web application servers, database servers, or distributed cache server clusters, etc. There is always a load balancing server between server clusters. The task of the load balancing server is to serve as the entrance of server traffic and forward the client's request to the back-end server in the server cluster for processing, so as to achieve transparent forwarding from the client to the real back-end server. Load balancing servers are generally used to distribute traffic to back-end servers in order to improve the concurrent processing capability of services, increase throughput and service availability.
[0003] Load balancing can be divided into hardware load balancing and software load balancing. Hardware load balancing is relatively expensive. Commonly used software load balancing includes LVS, Nginx, and HAProxy. These existing load balancing software are usually based on the network kernel protocol stack framework function. For example, the load balancing implemented by iptables is the message processing performed when the traffic enters the deep layer of the protocol stack. The network kernel protocol stack framework functions of these load balancing software are all based on CPU processing, which requires a large amount of CPU resources to analyze the message or forward the traffic, resulting in low load balancing performance and it is difficult to meet the high-performance load requirements of the cloud environment.
[0004] Usually the load of the cluster is distributed based on the four-layer network scheduling technology, which can be distributed based on IP, port or content, among which the load balancing based on IP is the most efficient. The common load balancing modes based on IP are address translation (NAT), IP tunnel (TUN) and direct routing (DR).
[0005] Address Translation: Network Address Translation, referred to as NAT mode, is similar to the private network structure of a firewall. The load balancing scheduler of the load balancing server is the gateway of all backend servers, the access entrance of the client, and the access exit of each backend server to respond to the client. Figure 1AAs shown, in NAT mode, for example, if a client needs to access backend server 1, it first sends a corresponding access request to the load balancing scheduler, and the load balancing scheduler forwards the access request sent by the client to the backend server 1. After that, the backend server 1 sends the response information corresponding to the access request to the load balancing scheduler, and the load balancing scheduler forwards the response information to the client. Therefore, the bidirectional traffic in NAT mode passes through the load balancing scheduler.
[0006] IP Tunnel: IP Tunnel, referred to as TUN mode, adopts an open network structure, refer to Figure 1B As shown, the load balancing scheduler serves as the access entrance of the client and forwards the access request to the back-end server through the IP tunnel, while the back-end server directly returns the response information to the client without passing through the load balancing scheduler.
[0007] Direct Routing: Direct Routing, referred to as DR mode, uses a semi-open network structure. Figure 1B As shown, the load balancing scheduler serves as the access entrance of the client and forwards the access request to the back-end server through direct routing. The back-end server directly returns the response information to the client without passing through the load balancing scheduler.
[0008] In summary, based on the load balancing forwarding methods in various modes, the network communication between the client and the backend server needs to pass through the load balancing server and be forwarded by the load balancing server. Therefore, when the load balancing server receives multiple requests sent by the client, each backend server can only wait for the load balancing server to forward them in sequence, and the processing concurrency of multiple backend servers is limited, resulting in a waste of backend server resources.
[0009] Currently, no effective solution has been proposed for the technical problem that each backend server in the above-mentioned prior art waits for the load balancing server to forward requests in sequence, resulting in limited processing concurrency and waste of resources. Summary of the invention
[0010] The embodiments of the present application provide a communication method, device and computer program product based on load balancing, so as to at least solve the technical problem existing in the prior art that each back-end server waits for the load balancing server to forward requests in sequence, resulting in limited processing concurrency capacity and waste of resources.
[0011] According to one aspect of an embodiment of the present application, a communication method based on load balancing is provided, including: the load balancing server receives a first handshake signal sent by a client through a load balancing scheduler, wherein the first handshake signal is used to request to establish a communication connection with a back-end server; the load balancing server changes the destination address of the first handshake signal to the address of the back-end server through the load balancing scheduler, and sends the generated second handshake signal to the back-end server and the client respectively, wherein the destination address of the first handshake signal is the address of the load balancing server; the back-end server generates a corresponding response signal according to the second handshake signal, and sends the response signal to the client, wherein the response signal is used to indicate that the client's request to establish a communication connection is agreed; the client generates a confirmation signal according to the second handshake signal and the response signal, and sends the confirmation signal to the back-end server to establish a communication connection, wherein the confirmation signal is used to indicate that the response signal has been received; and the client directly communicates with the back-end server according to the communication connection established with the back-end server.
[0012] According to another aspect of the embodiment of the present application, a communication device based on load balancing is also provided, including: a signal receiving module, used for the load balancing server to receive a first handshake signal sent by a client through a load balancing scheduler, wherein the first handshake signal is used to request to establish a communication connection with a back-end server; an address changing module, used for the load balancing server to change the destination address of the first handshake signal to the address of the back-end server through the load balancing scheduler, and send the generated second handshake signal to the back-end server and the client respectively, wherein the destination address of the first handshake signal is the address of the load balancing server; a signal generating module, used for the back-end server to generate a corresponding response signal according to the second handshake signal, and send the response signal to the client, wherein the response signal is used to indicate that the client's request to establish a communication connection is agreed; a communication connection module, used for the client to generate a confirmation signal according to the second handshake signal and the response signal, and send the confirmation signal to the back-end server to establish a communication connection, wherein the confirmation signal is used to indicate that the response signal has been received; and a communication module, used for the client to directly communicate with the back-end server according to the communication connection established with the back-end server.
[0013] According to another aspect of an embodiment of the present application, a communication device based on load balancing is also provided, including: a processor; and a memory, connected to the processor, for providing the processor with instructions for processing the following processing steps: the load balancing server receives a first handshake signal sent by a client through a load balancing scheduler, wherein the first handshake signal is used to request to establish a communication connection with a back-end server; the load balancing server changes the destination address of the first handshake signal to the address of the back-end server through the load balancing scheduler, and sends the generated second handshake signal to the back-end server and the client respectively, wherein the destination address of the first handshake signal is the address of the load balancing server; the back-end server generates a corresponding response signal according to the second handshake signal, and sends the response signal to the client, wherein the response signal is used to indicate that the client's request to establish a communication connection is agreed; the client generates a confirmation signal according to the second handshake signal and the response signal, and sends the confirmation signal to the back-end server to establish a communication connection, wherein the confirmation signal is used to indicate that the response signal has been received; and the client directly communicates with the back-end server according to the communication connection established with the back-end server.
[0014] According to another aspect of the embodiments of the present application, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0015] In the embodiment of the present application, the load balancing server forwards the handshake signal for the client only when the client establishes a communication connection with the back-end server, and the data exchange thereafter is directly carried out between the client and the back-end server, thereby shortening the processing path and improving the processing efficiency. And after the client and the back-end server establish a communication connection, the load balancing server does not forward the data information, so that the client can communicate directly with the back-end server, and the back-end server does not need to wait for the load balancing server to forward the data information for it, so that multiple back-end servers can communicate with the client at the same time, reducing the limitations on the back-end servers, improving the concurrency of the back-end servers, and reducing the waste of resources of the back-end servers. This solves the technical problem of each back-end server waiting for the load balancing server to forward the request in turn, resulting in the limitation of the processing concurrency and waste of resources in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1A It is a schematic diagram of a client accessing a back-end server in NAT mode in the prior art;
[0018] Figure 1B It is a schematic diagram of a client accessing a backend server in TUN mode and DR mode in the prior art;
[0019] Figure 2 is a schematic diagram of a communication system based on load balancing according to Embodiment 1 of the present application;
[0020] Figure 3 It is a flow chart of a communication method based on load balancing according to the first aspect of Embodiment 1 of the present application;
[0021] Figure 4 is another flow chart of the communication method based on load balancing according to the first aspect of Embodiment 1 of the present application;
[0022] Figure 5 It is another flowchart of the communication method based on load balancing according to the first aspect of Embodiment 1 of the present application;
[0023] Figure 6 It is a schematic diagram of configuration information of a load balancing server according to the first aspect of Embodiment 1 of the present application;
[0024] Figure 7 is a schematic diagram of a communication device based on load balancing according to Embodiment 2 of the present application; and
[0025] Figure 8 This is a schematic diagram of a load balancing-based communication device according to Example 3 of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the technical solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0029] SYN signal: Synchronize Sequence Numbers. It is a handshake signal used when TCP / IP establishes a connection. When a normal TCP network connection is established between a client and a server, the client first sends a SYN message, and the server uses a SYN+ACK response to indicate that it has received the message. Finally, the client responds with an ACK message. In this way, a reliable TCP connection can be established between the client and the server, and data can be transmitted between the client and the server.
[0030] The Data Processing Unit (DPU) is a new type of programmable multi-core processor that is mainly responsible for processing data-related tasks such as network protocol processing, storage, virtualization, and security. The emergence of DPU is to reduce the burden of the CPU (central processing unit) and improve the efficiency and performance of the data center.
[0031] Example 1
[0032] According to this embodiment, a method embodiment of a communication method based on load balancing is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0033] Figure 2 is a schematic diagram of a load balancing-based communication system according to this embodiment. Figure 2 As shown, the system includes: a client 100, a load balancing server 200 and a plurality of backend servers 301-30n.
[0034] The load balancing server 200 is in communication connection with the client 100 and the backend servers 301 - 30n respectively.
[0035] The load balancing server 200 includes a load balancing scheduler and a load balancing manager, wherein the load balancing scheduler is used to forward requests sent by the client 100 to the backend servers 301-30n. The load balancing manager is used to set configuration information such as IP addresses and listening ports.
[0036] Backend servers 301-30n may be divided into members of multiple platforms. For example, backend servers 301-303 are members of platform 1 and are used to provide services for platform 1; backend servers 303-30n are members of platform 2 and are used to provide services for platform 2.
[0037] The client 100 and the backend servers 301-30n are pre-configured with a load balancing proxy, wherein the load balancing proxy is used for packet encapsulation and decapsulation.
[0038] In the above operating environment, according to the first aspect of this embodiment, a communication method based on load balancing is provided. The method comprises Figure 2 The communication system based on load balancing shown in is implemented. Figure 3 A schematic diagram showing the process of the method is shown in FIG. Figure 3 As shown, the method includes:
[0039] S302: The load balancing server receives a first handshake signal sent by the client through the load balancing scheduler, wherein the first handshake signal is used to request to establish a communication connection with the backend server;
[0040] S304: The load balancing server changes the destination address of the first handshake signal to the address of the backend server through the load balancing scheduler, and sends the generated second handshake signal to the backend server and the client respectively, wherein the destination address of the first handshake signal is the address of the load balancing server;
[0041] S306: The backend server generates a corresponding response signal according to the second handshake signal, and sends the response signal to the client, wherein the response signal is used to indicate approval of the client's request for establishing a communication connection;
[0042] S308: The client generates a confirmation signal according to the second handshake signal and the response signal, and sends the confirmation signal to the backend server to establish a communication connection, wherein the confirmation signal is used to indicate that the response signal has been received; and
[0043] S310: The client directly communicates with the backend server according to the communication connection established with the backend server.
[0044] Specifically, refer to Figure 4 As shown, the user enters the URL of the platform to be accessed in the browser of the client 100, for example, platform 1. Therefore, when the client 100 has not established a communication connection with platform 1 and the client 100 wants to access platform 1, first, the client 100 determines the address of the load balancing server 200 to be accessed according to the URL of platform 1, and then uses the address of the client 100 as the source address and the address of the load balancing server 200 as the destination address. The source address includes the source IP address and the source MAC address, and the destination address includes the destination IP address and the destination MAC address. After that, the client 100 generates a handshake signal (i.e., a first handshake signal) for requesting to establish a communication connection with the backend server of platform 1 according to the source address and the destination address, and sends the first handshake signal to the load balancing server 200 according to the destination address. The first handshake signal can be a SYN signal, and the SYN signal contains a random initial sequence number selected by the client 100. After that, the load balancing server 200 receives the first handshake signal sent by the client 100 (S302).
[0045] Further, the load balancing server 200 selects a backend server from the backend servers providing services for the platform 1 as the backend server for communication connection with the client 100 by using a preset load balancing algorithm through the load balancing scheduler. For example, the load balancing server 200 selects the backend server 301 from the backend servers 301 to 303 serving the platform 1 as the backend server for communication connection with the client 100. The load balancing algorithm may be, for example, a hash algorithm. Then, the load balancing server 200 determines the address of the backend server 301 through the load balancing scheduler, and changes the destination address of the first handshake signal, that is, the address of the load balancing server 200, to the address of the backend server 301, thereby generating a handshake signal (that is, a second handshake signal) whose destination address is the address of the backend server 301. Then, the load balancing server 200 sends the second handshake signal to the client 100 and the backend server 301 respectively through the load balancing scheduler (S304).
[0046] Further, after receiving the second handshake signal sent by the load balancing server 200, the backend server 301 generates a response signal according to the second handshake signal for agreeing to establish a communication connection with the client 100. The response signal may be a SYN+ACK signal, wherein SYN represents a random initial sequence number selected by the backend server, and ACK represents confirmation of the random initial sequence number of the client 100. The backend server 301 then directly sends the response signal to the client 100 (S306).
[0047] Further, after the client 100 receives the second handshake signal sent by the load balancing server 200 and the response signal sent by the back-end server 301, it determines based on the response signal that the back-end server 301 agrees to establish a communication connection with the client 100, thereby generating a confirmation signal based on the second handshake signal and the response signal. The confirmation signal may be an ACK signal. Afterwards, the client 100 directly sends the confirmation signal to the back-end server 301, indicating to the back-end server 301 that the response signal sent by the back-end server 301 has been received. At this point, the communication connection between the client 100 and the back-end server 301 is established, and then the client 100 and the back-end server 301 can start exchanging data (S308).
[0048] Further, refer to Figure 5 As shown, after the client 100 and the backend server 301 establish a communication connection, the user accesses the platform 1 through the client 100 according to the website of the platform 1, and the client 100 directly sends an access request to the backend server 301. The backend server 301 receives the access request sent by the client 100, and then returns a response message to the client 100 according to the access request, thereby realizing the communication between the client 100 and the backend server 301 (S310).
[0049] As described in the background technology, based on the load balancing forwarding method in various modes, the network communication between the client and the backend server needs to pass through the load balancing server and be forwarded by the load balancing server. Therefore, when the load balancing server receives multiple requests sent by the client, the processing concurrency capacity of multiple backend servers is limited, resulting in a waste of resources of the backend servers.
[0050] In view of the technical problems described above, through the technical solution of the embodiment of the present application, the load balancing server forwards the handshake signal for the client only when the client establishes a communication connection with the back-end server, and the data exchange thereafter is directly carried out between the client and the back-end server, thereby shortening the processing path and improving the processing efficiency. And after the client and the back-end server establish a communication connection, the load balancing server does not forward the data information, so that the client can communicate directly with the back-end server, and the back-end server does not need to wait for the load balancing server to forward the data information for it, so that multiple back-end servers can communicate with the client at the same time, reducing the limitations on the back-end servers, improving the concurrency of the back-end servers, and reducing the waste of resources of the back-end servers. This solves the technical problem of each back-end server waiting for the load balancing server to forward the request in turn, resulting in the limitation of the processing concurrency and waste of resources in the prior art.
[0051] In addition, although the process of establishing a communication connection between a client and a backend server is described here by taking platform 1 and backend server 301 as an example, the process is also applicable to other backend servers 302 to 30n, and will not be described in detail here.
[0052] Optionally, the operation of the load balancing server changing the destination address of the first handshake signal to the address of the back-end server through the load balancing scheduler includes: the load balancing server determines the address of the back-end server through the load balancing scheduler using a hash algorithm; the load balancing server parses the first handshake signal through the load balancing scheduler to determine the corresponding destination address and source address, wherein the destination address is the address of the load balancing server and the source address is the address of the client; and the load balancing server retains the source address of the first handshake signal through the load balancing scheduler, and changes the destination address to the address of the back-end server to generate a second handshake signal.
[0053] Specifically, after the load balancing server 200 receives the first handshake signal sent by the client 100 through the load balancing scheduler, it uses a hash algorithm to determine the address of the backend server 301. The hash algorithm may be, for example, a source address hash method.
[0054] The source address hash method is to calculate a value through a hash function based on the address of the request source, and use this value to perform a modulo operation on the size of the backend server list, and the result is the serial number of the backend server that the client 100 wants to access. When the source address hash method is used for load balancing, the request with the same source address will be mapped to the same backend server for access each time when the backend server list remains unchanged. Therefore, the load balancing server 200 uses the source address hash method to determine the serial number of the backend server 301 in the backend server list, and searches for the address of the backend server 301 according to the serial number.
[0055] Further, the load balancing server 200 parses the first handshake signal through the load balancing scheduler to determine the destination address and source address in the first handshake signal. The destination address includes the destination IP address and the destination MAC address, and the source address includes the source IP address and the source MAC address. Thus, the destination address of the first handshake signal determined by the load balancing server 200 through the load balancing scheduler is the IP address and MAC address of the load balancing server 200, and the source address of the first handshake signal is the IP address and MAC address of the client 100.
[0056] In addition, the first handshake signal also includes data information such as a sequence number, an ACK number, and a TCP flag in addition to the destination address and the source address. Thus, the load balancing server 200 obtains data information such as the source address and the sequence number in addition to the destination address in the first handshake signal through the load balancing scheduler, and generates a second handshake signal based on the above data information and the address of the back-end server 301 as the destination address. That is, the source address of the second handshake signal is the source address of the first handshake signal (that is, the address of the client 100), and the destination address is the address of the back-end server 301. Thus, the load balancing server retains the source address of the first handshake signal through the load balancing scheduler, and changes the destination address to the address of the back-end server to generate a second handshake signal.
[0057] Therefore, the technical solution retains the source address of the original handshake signal (ie, the first handshake signal) and only modifies the destination address, so that the handshake signal maintains the data information used for identity authentication in the original communication during the forwarding process, thereby increasing the security of the connection.
[0058] Optionally, the operation of the backend server sending the response signal to the client through the load balancing scheduler includes: the backend server obtains the source address of the second handshake signal through the load balancing scheduler, and sends the response signal to the client corresponding to the source address.
[0059] Specifically, the backend server 301 receives the second handshake signal sent by the load balancing server 200, and then unpacks the second handshake signal through the load balancing proxy to obtain data information such as the source address and destination address corresponding to the second handshake signal.
[0060] Afterwards, the backend server 301 determines to establish a communication connection with the client 100, and generates a response signal agreeing to establish a communication connection with the client 100 through the load balancing proxy according to the second handshake signal. The backend server 301 uses the source address of the second handshake signal as the destination address of the response signal, that is, the address of the client 100. Afterwards, the backend server 301 sends the response signal to the client 100 according to the address of the client 100.
[0061] Therefore, in this technical solution, when the back-end server returns a response signal to the client, it does not need to pass through the load balancing server, thereby reducing the workload of the load balancing server, reducing the number of nodes through which data flows, and improving data transmission efficiency.
[0062] Optionally, the operation of the client generating a confirmation signal based on the second handshake signal and the response signal includes: the client receiving the second handshake signal, and simulating the client sending the second handshake signal to the back-end server based on the source address and destination address of the second handshake signal; and the client receiving the response signal, and generating a confirmation signal based on the second handshake signal and the response signal.
[0063] Specifically, the client 100 receives the second handshake signal sent by the load balancing server 200, and unpacks the second handshake signal through the load balancing proxy to obtain the source address (i.e., the address of the client 100) and the destination address (the address of the back-end server 301) corresponding to the second handshake signal. The second handshake signal simulates the process of the client 100 sending the second handshake signal to the back-end server 301.
[0064] Furthermore, the client 100 receives a response signal sent by the backend server 301. Under normal circumstances, since the client 100 does not directly send a handshake signal to the backend server 301, when the client 100 receives the response signal sent by the backend server 301, the response signal should be discarded. However, since the load balancing server 200 sends a second handshake signal to the client 100, with the source address being the address of the client 200 and the target address being the address of the backend server 301, the process of the client 100 sending the second handshake signal to the backend server 301 is simulated, so that the client 100 does not discard the response signal, and then generates a confirmation signal according to the second handshake signal and the response signal.
[0065] Therefore, this technical solution simulates the process of the client sending a handshake signal to the back-end server through the load balancing server, so that even if the client does not actually directly initiate a request, it can successfully receive a response signal from the back-end server, thereby providing a seamless communication experience.
[0066] Optionally, the method also includes: the load balancing server creates a load balancing service through the load balancing manager, fills in the IP address of the load balancing server in the load balancing service, and establishes a listening port in the load balancing service through a listener; and the load balancing server associates the listening port with the back-end server through the load balancing manager through the load balancing scheduler, wherein the operation of the load balancing server receiving the first handshake signal sent by the client through the load balancing scheduler includes: the client sends the first handshake signal to the load balancing server according to the IP address and the listening port of the load balancing server; and the load balancing server receives the first handshake signal sent by the client through the load balancing scheduler.
[0067] Specifically, before the client 100 sends the first handshake signal to the load balancing server 200, the load balancing server 200 sets configuration information for the load balancing scheduler through the load balancing manager.
[0068] More specifically, first, the load balancing server 200 creates a load balancing service through the load balancing manager, and fills in the created load balancing service with the IP address of the load balancing server 200. Then, the load balancing server 200 creates a listener through the load balancing manager, and fills in the listening port in the created listener.
[0069] The load balancing server 200 then adds each backend server 301-30n to the listener through the load balancing manager and associates it with the listening port in the listener. There can be multiple listening ports, and each listening port can correspond to multiple backend servers. Figure 6 As shown, the multiple monitoring ports are, for example, listening ports 1 to m, for example, listening port 1 corresponds to backend servers 301 to 303. Afterwards, the load balancing server 200 sends the above configuration information to the load balancing scheduler through the load balancing manager, so that the load balancing scheduler can determine the corresponding backend server according to the IP address and the listening port, and thus forward the handshake signal to the backend server.
[0070] Therefore, after the configuration information is set, when the user accesses the platform 1 through the client 100 and the client 100 sends the first handshake signal to the load balancing server 200, the destination address includes the listening port in addition to the IP address and MAC address of the load balancing server 200. Therefore, the client 100 sends the first handshake signal to the load balancing server 200 according to the IP address, MAC address of the load balancing server 200 and the listening port corresponding to the backend server providing services for the platform 1. Thereafter, the load balancing server 200 receives the first handshake signal sent by the client 100.
[0071] Thus, the load balancing server in the technical solution can flexibly configure and adjust the load balancing service through the load balancing manager, including setting the IP address of the load balancing server, creating a listener and its listening port, and associating different back-end servers with these listening ports. Thus, by specifying a specific port for listening, the load balancing server can respond to the client's request more quickly, thereby improving the efficiency of network communication.
[0072] Optionally, the method further includes: a load balancing scheduler running on a preset data processor.
[0073] Specifically, the load balancing scheduler and the load balancing manager of the load balancing server 200 are both run in the data processor of the load balancing server 200. The load balancing proxy of the client 100 is run in the data processor of the client 100, and the load balancing proxy of the backend servers 301-30n is run in the data processor of the backend servers 301-30n.
[0074] Therefore, in this technical solution, the data processor is used to execute programs such as the load balancing scheduler, so that the CPU does not need to consume a large amount of CPU resources to analyze or forward the handshake signal, thereby reducing the CPU resource usage, releasing the CPU's computing power, and allowing the CPU to focus on the computing tasks of the upper-level applications, thereby improving the efficiency of the overall system.
[0075] Optionally, the method also includes: the load balancing scheduler is implemented based on eBPF technology.
[0076] Specifically, the load balancing scheduler of the load balancing server 200 is generated by using the eBPF technology, thereby realizing the load balancing scheduling of the load balancing server 200. In addition, the load balancing manager and the load balancing proxy are also generated by the eBPF technology.
[0077] Therefore, this technical solution applies eBPF to load balancing, so that load balancing can process the handshake signal before it reaches the data processor and enters the kernel protocol stack (i.e., CPU), shortening the processing path, improving processing efficiency, and enhancing performance.
[0078] The load balancing scheduler is written in eBPF technology, which is highly efficient. eBPF is a revolutionary technology that originated in the Linux kernel. It can run sandbox programs in a privileged context (such as the operating system kernel). It is used to safely and efficiently extend the functionality of the kernel without changing the kernel source code or loading kernel modules. By allowing sandbox programs to run in the operating system, application developers can run eBPF programs to add additional functionality to the operating system at runtime. Then, with the help of the JIT compiler and verification engine, the operating system ensures that it has the same security and execution efficiency as a locally compiled program.
[0079] In summary, reference Figure 4 As shown, the sequential steps of establishing a communication connection between the client 100 and the backend server 301 are as follows:
[0080] S401: The client 100 sends a first handshake signal for requesting a communication connection to the load balancing server 200;
[0081] S402: The load balancing server 200 receives the first handshake signal, and modifies the destination address of the first handshake signal to the address of the backend server 301, and generates a second handshake signal, thereby simulating the client 100 directly sending a handshake signal for requesting a communication connection to the backend server 301;
[0082] S403: The load balancing server 200 sends the second handshake signal to the backend server 301;
[0083] S404: The load balancing server 200 sends a second handshake signal to the client 100;
[0084] S405: the backend server 301 receives the second handshake signal, generates a response signal agreeing to establish a communication connection with the client 100 according to the second handshake signal, and sends the response signal to the client 100;
[0085] S406: After receiving the response signal sent by the backend server and the second handshake signal sent by the load balancing server 200, the client generates a confirmation signal for confirming that the response signal has been received according to the response signal and the second handshake signal, and sends the confirmation signal to the backend server 301, so that the client 100 successfully establishes a communication connection with the backend server 301;
[0086] S407: The client 100 communicates directly with the backend server 301.
[0087] In addition, according to a third aspect of this embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0088] Therefore, according to this embodiment, the load balancing server forwards the handshake signal for the client only when the client establishes a communication connection with the back-end server, and the data exchange thereafter is directly carried out between the client and the back-end server, thereby shortening the processing path and improving the processing efficiency. And after the client and the back-end server establish a communication connection, the load balancing server does not forward the data information, so that the client can communicate directly with the back-end server, and the back-end server does not need to wait for the load balancing server to forward the data information for it, so that multiple back-end servers can communicate with the client at the same time, reducing the limitations on the back-end servers, improving the concurrency of the back-end servers, and reducing the waste of resources of the back-end servers. This solves the technical problem of each back-end server waiting for the load balancing server to forward the request in turn, resulting in the limitation of the processing concurrency and waste of resources in the prior art.
[0089] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0090] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0091] Example 2
[0092] Figure 7 A load balancing-based communication device 700 according to this embodiment is shown, and the device 700 corresponds to the method according to the first aspect of embodiment 1. Figure 7 As shown, the device 700 includes: a signal receiving module 710, which is used for the load balancing server to receive a first handshake signal sent by a client through a load balancing scheduler, wherein the first handshake signal is used to request to establish a communication connection with a back-end server; an address changing module 720, which is used for the load balancing server to change the destination address of the first handshake signal to the address of the back-end server through the load balancing scheduler, and send the generated second handshake signal to the back-end server and the client respectively, wherein the destination address of the first handshake signal is the address of the load balancing server; a signal generating module 730, which is used for the back-end server to generate a corresponding response signal according to the second handshake signal, and send the response signal to the client, wherein the response signal is used to indicate that the client's request to establish a communication connection is approved; a communication connection module 740, which is used for the client to generate a confirmation signal according to the second handshake signal and the response signal, and send the confirmation signal to the back-end server to establish a communication connection, wherein the confirmation signal is used to indicate that the response signal has been received; and a communication module 750, which is used for the client to directly communicate with the back-end server according to the communication connection established with the back-end server.
[0093] Optionally, the address change module 720 includes: a first determination submodule, which is used for the load balancing server to determine the address of the back-end server through the load balancing scheduler using a hash algorithm; a second determination submodule, which is used for the load balancing server to parse the first handshake signal through the load balancing scheduler to determine the corresponding destination address and source address, wherein the destination address is the address of the load balancing server and the source address is the address of the client; and a first generation submodule, which is used for the load balancing server to retain the source address of the first handshake signal through the load balancing scheduler, and change the destination address to the address of the back-end server to generate a second handshake signal.
[0094] Optionally, the signal generating module 730 includes: a first sending submodule, which is used for the backend server to obtain the source address of the second handshake signal through the load balancing scheduler, and send a response signal to the client corresponding to the source address.
[0095] Optionally, the communication connection module 740 includes: a simulation submodule, which is used for the client to receive a second handshake signal, and simulates the client sending a second handshake signal to the back-end server according to the source address and destination address of the second handshake signal; and a second generation submodule, which is used for the client to receive a response signal and generate a confirmation signal according to the second handshake signal and the response signal.
[0096] Optionally, the device 700 also includes: a service creation module, which is used for the load balancing server to create a load balancing service through the load balancing manager, fill in the IP address of the load balancing server in the load balancing service, and establish a listening port in the load balancing service through the listener; and an association module, which is used for the load balancing server to associate the listening port with the back-end server through the load balancing manager, wherein the signal receiving module 710 includes: a second sending sub-module, which is used for the client to send a first handshake signal to the load balancing server according to the IP address and listening port of the load balancing server; and a first receiving sub-module, which is used for the load balancing server to receive the first handshake signal sent by the client through the load balancing scheduler.
[0097] Optionally, the device 700 further includes: an operation module, configured to cause the load balancing scheduler to run on a preset data processor.
[0098] Optionally, the device 700 further includes: an implementation module, for implementing the load balancing scheduler based on the eBPF technology.
[0099] Therefore, according to this embodiment, the load balancing server forwards the handshake signal for the client only when the client establishes a communication connection with the back-end server, and the data exchange thereafter is directly carried out between the client and the back-end server, thereby shortening the processing path and improving the processing efficiency. And after the client and the back-end server establish a communication connection, the load balancing server does not forward the data information, so that the client can communicate directly with the back-end server, and the back-end server does not need to wait for the load balancing server to forward the data information for it, so that multiple back-end servers can communicate with the client at the same time, reducing the limitations on the back-end servers, improving the concurrency of the back-end servers, and reducing the waste of resources of the back-end servers. This solves the technical problem of each back-end server waiting for the load balancing server to forward the request in turn, resulting in the limitation of the processing concurrency and waste of resources in the prior art.
[0100] Example 3
[0101] Figure 8 A load balancing-based communication device 800 according to this embodiment is shown, and the device 800 corresponds to the method according to the first aspect of embodiment 1. Figure 8 As shown, the device 800 includes: a processor 810; and a memory 820, which is connected to the processor 810 and is used to provide the processor 810 with instructions for processing the following processing steps: the load balancing server receives a first handshake signal sent by the client through the load balancing scheduler, wherein the first handshake signal is used to request to establish a communication connection with the back-end server; the load balancing server changes the destination address of the first handshake signal to the address of the back-end server through the load balancing scheduler, and sends the generated second handshake signal to the back-end server and the client respectively, wherein the destination address of the first handshake signal is the address of the load balancing server; the back-end server generates a corresponding response signal according to the second handshake signal, and sends the response signal to the client, wherein the response signal is used to indicate that the client's request to establish a communication connection is agreed; the client generates a confirmation signal according to the second handshake signal and the response signal, and sends the confirmation signal to the back-end server to establish a communication connection, wherein the confirmation signal is used to indicate that the response signal has been received; and the client directly communicates with the back-end server according to the communication connection established with the back-end server.
[0102] Optionally, the operation of the load balancing server changing the destination address of the first handshake signal to the address of the back-end server through the load balancing scheduler includes: the load balancing server determines the address of the back-end server through the load balancing scheduler using a hash algorithm; the load balancing server parses the first handshake signal through the load balancing scheduler to determine the corresponding destination address and source address, wherein the destination address is the address of the load balancing server and the source address is the address of the client; and the load balancing server retains the source address of the first handshake signal through the load balancing scheduler, and changes the destination address to the address of the back-end server to generate a second handshake signal.
[0103] Optionally, the operation of the backend server sending the response signal to the client through the load balancing scheduler includes: the backend server obtains the source address of the second handshake signal through the load balancing scheduler, and sends the response signal to the client corresponding to the source address.
[0104] Optionally, the operation of the client generating a confirmation signal based on the second handshake signal and the response signal includes: the client receiving the second handshake signal, and simulating the client sending the second handshake signal to the back-end server based on the source address and destination address of the second handshake signal; and the client receiving the response signal, and generating a confirmation signal based on the second handshake signal and the response signal.
[0105] Optionally, the memory 820 is also used to provide instructions for the processor 810 to process the following processing steps: the load balancing server creates a load balancing service through the load balancing manager, fills in the IP address of the load balancing server in the load balancing service, and establishes a listening port in the load balancing service through the listener; and the load balancing server associates the listening port with the back-end server through the load balancing manager, wherein the load balancing server receives the first handshake signal sent by the client through the load balancing scheduler, including: the client sends the first handshake signal to the load balancing server according to the IP address and the listening port of the load balancing server; and the load balancing server receives the first handshake signal sent by the client through the load balancing scheduler.
[0106] Optionally, the memory 820 is further configured to provide the processor 810 with instructions for processing the following processing steps: A load balancing scheduler runs on a preset data processor.
[0107] Optionally, the memory 820 is also used to provide the processor 810 with instructions for processing the following processing steps: The load balancing scheduler is implemented based on the eBPF technology.
[0108] Therefore, according to this embodiment, the load balancing server forwards the handshake signal for the client only when the client establishes a communication connection with the back-end server, and the data exchange thereafter is directly carried out between the client and the back-end server, thereby shortening the processing path and improving the processing efficiency. And after the client and the back-end server establish a communication connection, the load balancing server does not forward the data information, so that the client can communicate directly with the back-end server, and the back-end server does not need to wait for the load balancing server to forward the data information for it, so that multiple back-end servers can communicate with the client at the same time, reducing the limitations on the back-end servers, improving the concurrency of the back-end servers, and reducing the waste of resources of the back-end servers. This solves the technical problem of each back-end server waiting for the load balancing server to forward the request in turn, resulting in the limitation of the processing concurrency and waste of resources in the prior art.
[0109] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0110] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0111] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0112] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0113] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0114] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0115] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A communication method based on load balancing, characterized in that: include: The load balancing server receives a first handshake signal sent by the client through the load balancing scheduler, wherein the first handshake signal is used to request to establish a communication connection with the back-end server; The load balancing server changes the destination address of the first handshake signal to the address of the backend server through the load balancing scheduler, and sends the generated second handshake signal to the backend server and the client respectively, wherein the destination address of the first handshake signal is the address of the load balancing server; The back-end server generates a corresponding response signal according to the second handshake signal, and sends the response signal to the client, wherein the response signal is used to indicate approval of the client's request to establish a communication connection; The client generates a confirmation signal according to the second handshake signal and the response signal, and sends the confirmation signal to the backend server to establish a communication connection, wherein the confirmation signal is used to indicate that the response signal has been received; and The client directly communicates with the backend server according to the communication connection established with the backend server.
2. The method according to claim 1, characterized in that: The operation of the load balancing server changing the destination address of the first handshake signal to the address of the backend server through the load balancing scheduler includes: The load balancing server determines the address of the backend server by using a hash algorithm through a load balancing scheduler; The load balancing server parses the first handshake signal through the load balancing scheduler to determine a corresponding destination address and source address, wherein the destination address is the address of the load balancing server, and the source address is the address of the client; and The load balancing server reserves the source address of the first handshake signal through the load balancing scheduler, and changes the destination address to the address of the backend server to generate the second handshake signal.
3. The method according to claim 1, characterized in that: The operation of the backend server sending the response signal to the client through the load balancing scheduler includes: The backend server obtains the source address of the second handshake signal through the load balancing scheduler, and sends the response signal to the client corresponding to the source address.
4. The method according to claim 1, characterized in that: The operation of the client generating a confirmation signal according to the second handshake signal and the response signal includes: The client receives the second handshake signal, and according to the source address and the destination address of the second handshake signal, simulates the client sending the second handshake signal to the backend server; and The client receives the response signal and generates a confirmation signal according to the second handshake signal and the response signal.
5. The method according to claim 1, characterized in that Also includes: The load balancing server creates a load balancing service through a load balancing manager, fills in the IP address of the load balancing server in the load balancing service, and establishes a listening port in the load balancing service through a listener; as well as The load balancing server associates the listening port with the backend server through the load balancing manager, wherein The operation of the load balancing server receiving the first handshake signal sent by the client through the load balancing scheduler includes: The client sends the first handshake signal to the load balancing server according to the IP address and the listening port of the load balancing server; as well as The load balancing server receives the first handshake signal sent by the client through the load balancing scheduler.
6. The method according to claim 2, characterized in that Also includes: The load balancing scheduler runs on a preset data processor.
7. The method according to claim 6, characterized in that Also includes: The load balancing scheduler is implemented based on eBPF technology.
8. A communication device based on load balancing, characterized in that: include: A signal receiving module, used for the load balancing server to receive a first handshake signal sent by the client through the load balancing scheduler, wherein the first handshake signal is used to request to establish a communication connection with the back-end server; An address changing module, used for the load balancing server to change the destination address of the first handshake signal to the address of the backend server through the load balancing scheduler, and to send the generated second handshake signal to the backend server and the client respectively, wherein the destination address of the first handshake signal is the address of the load balancing server; a signal generating module, configured for the back-end server to generate a corresponding response signal according to the second handshake signal, and send the response signal to the client, wherein the response signal is used to indicate approval of the request of the client to establish a communication connection; a communication connection module, configured for the client to generate a confirmation signal according to the second handshake signal and the response signal, and send the confirmation signal to the back-end server to establish a communication connection, wherein the confirmation signal is used to indicate that the response signal has been received; as well as The communication module is used for the client to directly communicate with the back-end server according to the communication connection established with the back-end server.
9. A communication device based on load balancing, characterized in that: include: processor; as well as A memory, connected to the processor, configured to provide the processor with instructions for processing the following processing steps: The load balancing server receives a first handshake signal sent by the client through the load balancing scheduler, wherein the first handshake signal is used to request to establish a communication connection with the back-end server; The load balancing server changes the destination address of the first handshake signal to the address of the backend server through the load balancing scheduler, and sends the generated second handshake signal to the backend server and the client respectively, wherein the destination address of the first handshake signal is the address of the load balancing server; The back-end server generates a corresponding response signal according to the second handshake signal, and sends the response signal to the client, wherein the response signal is used to indicate approval of the client's request to establish a communication connection; The client generates a confirmation signal according to the second handshake signal and the response signal, and sends the confirmation signal to the backend server to establish a communication connection, wherein the confirmation signal is used to indicate that the response signal has been received; and The client directly communicates with the backend server according to the communication connection established with the backend server.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to claim 1 are implemented.
Citation Information
Cited By
Message transmission method, device and system
CN119603237A
A message transmission method, device and system
CN119603237B
