Request processing method and device of load balancer, electronic equipment and readable medium

By configuring the backend traffic director on the backend server, the problem of forwarding and responsive load balancers requiring special routing configuration in NAT mode is solved, and flexible deployment and horizontal scaling of the load balancer is achieved.

CN119814789AActive Publication Date: 2025-04-11CHINA TELECOM CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411773099.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-04-11
Estimated Expiration
2044-12-04

AI Technical Summary

Technical Problem

Forwarding and reply load balancers In NAT mode, special routing configurations are required to ensure that the backend server can send responses to the load balancer.

Method used

By configuring a backend traffic director on the backend server, intercepting the request and establishing a connection status item, determining whether the response corresponds to the connection status item. If it corresponds, modify the target address of the response to be the media access control address of the load balancer, and sending the response to the load balancer.

Benefits of technology

It solves the problem that there is no need to configure the backend server in NAT mode, making the deployment of the load balancer more flexible, avoiding the problem of the client's source IP address being modified, and supports horizontal expansion through routing methods such as ECMP.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814789A_ABST
    Figure CN119814789A_ABST
Patent Text Reader

Abstract

The invention provides a request processing method and device for a load balancer, electronic equipment and a readable medium, and the method comprises the steps: receiving a request sent by a client through the load balancer, and configuring a media access control address for the load balancer; forwarding the request to a back-end server by using a load balancer; the client and the back-end server are located in the same subnet; in the process of forwarding the request to a back-end server, intercepting the request by using a back-end flow director, and establishing a connection state item based on the request; sending the request to a back-end server by using a back-end traffic orientator, and intercepting a response sent by the back-end server for the request; judging whether the response corresponds to the connection state item or not by using a rear-end flow orientator; if so, modifying the target address of the response to be a media access control address by using a back-end flow orientator, and sending the response to a load balancer; and the response is sent to the client by using the load balancer, so that the deployment of the forwarding reply type load balancer is more flexible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a request processing method for a load balancer, a request processing device for a load balancer, an electronic device and a computer-readable medium. Background Art

[0002] In the related art, a forward-reply type load balancer is usually used in conjunction with a backend server. After receiving a client request, the forward-reply type load balancer forwards the request to the backend server, and the response of the backend server is sent to the load balancer, which then sends it to the client.

[0003] A forward-reply load balancer usually has a NAT (Network Address Translation) mode, in which it uses DNAT (Destination Network Address Translation) to forward client requests. Specifically, when a client's request reaches the load balancer, the load balancer modifies the destination IP (Internet Protocol) address of the request to the IP address of the backend server, and then forwards the request to the backend server. However, when a client's request reaches the load balancer, a forward-reply load balancer does not modify the source IP address of the request from the client to the load balancer. In this case, if the client and the backend server are in the same subnet, the backend server will send the response directly to the client's IP address instead of to the load balancer's IP address. Therefore, special routing configuration is required for the backend server to ensure that the backend server can send the response to the load balancer. Summary of the invention

[0004] An embodiment of the present invention provides a request processing method, device, electronic device and computer-readable storage medium for a load balancer to solve the problem that a forwarding-reply type load balancer in NAT mode requires special routing configuration for the back-end server to ensure that the back-end server can send a response to the load balancer.

[0005] An embodiment of the present invention discloses a method for processing a request of a load balancer, the method comprising:

[0006] Using a preset load balancer to receive a request sent by a preset client, and configuring a preset media access control address for the load balancer;

[0007] The request is forwarded to a preset backend server by using the load balancer; the backend server is configured with a backend traffic director; the client and the backend server are located in the same subnet;

[0008] In the process of forwarding the request to the backend server, intercepting the request by the backend traffic director, and establishing a connection state item based on the request;

[0009] Using the backend traffic director to send the request to the backend server, and intercepting the response sent by the backend server to the request;

[0010] Determining, using the backend traffic director, whether the response corresponds to the connection status item;

[0011] If it corresponds, modify the target address of the response to the media access control address using the backend traffic director, and send the response to the load balancer;

[0012] The response is sent to the client using the load balancer.

[0013] Optionally, in the process of forwarding the request to the backend server, the request includes a first source Internet Protocol address and a first target Internet Protocol address; and establishing a connection state item based on the request includes:

[0014] establishing a first connection state item based on the first source Internet Protocol address and the first target Internet Protocol address;

[0015] using the first source Internet Protocol address as a second destination Internet Protocol address and using the first destination Internet Protocol address as a second source Internet Protocol address;

[0016] A second connection state entry is established based on the second source Internet Protocol address and the second target Internet Protocol address.

[0017] Optionally, the determining whether the response corresponds to the connection status item includes:

[0018] Based on the source Internet Protocol address and the target Internet Protocol address of the response, it is determined whether the response corresponds to the second connection state item.

[0019] Optionally, the method comprises:

[0020] If the response does not correspond to the second connection status item, the response is sent to the client using the backend traffic director.

[0021] Optionally, the first connection state item has an aging time; and the method includes:

[0022] Based on the current time and the aging time, using the backend traffic director to determine whether the first connection status item is invalid;

[0023] When the backend traffic director intercepts a pending request, based on the source Internet Protocol address and the destination Internet Protocol address of the pending request and the first source Internet Protocol address and the first destination Internet Protocol address, the backend traffic director is used to determine whether the pending request and the request include the same data packet;

[0024] If the pending request and the request include the same data packet, the backend traffic director is used to update the aging time of the first connection status item.

[0025] Optionally, the method comprises:

[0026] If the pending request and the request include the same data packet, using the backend traffic director to determine whether the pending request includes a termination mark;

[0027] If the pending request includes the termination mark, the first connection status item is placed in an invalid state using the backend traffic director.

[0028] Optionally, the backend traffic director is a network card driver and / or an extended packet filter program.

[0029] The embodiment of the present invention further discloses a request processing device of a load balancer, the device comprising:

[0030] A request receiving module, used to receive a request sent by a preset client using a preset load balancer, and configure a preset media access control address for the load balancer;

[0031] A request forwarding module, used to forward the request to a preset backend server using the load balancer; the backend server is configured with a backend traffic director; the client and the backend server are located in the same subnet;

[0032] A request interception module, used for intercepting the request by using the backend traffic director when the request is forwarded to the backend server, and establishing a connection status item based on the request;

[0033] A response interception module, used to send the request to the backend server using the backend traffic director, and intercept the response sent by the backend server to the request;

[0034] A determination module, configured to determine, using the backend traffic director, whether the response corresponds to the connection status item;

[0035] An address modification module, for modifying the target address of the response to the media access control address by using the backend traffic director if corresponding, and sending the response to the load balancer;

[0036] The first response sending module is used to send the response to the client by using the load balancer.

[0037] Optionally, in the process of forwarding the request to the backend server, the request includes a first source Internet Protocol address and a first target Internet Protocol address; the request interception module includes:

[0038] A first connection state item establishment submodule, configured to establish a first connection state item based on the first source Internet Protocol address and the first target Internet Protocol address;

[0039] as a submodule, for using the first source Internet Protocol address as a second target Internet Protocol address, and using the first target Internet Protocol address as a second source Internet Protocol address;

[0040] The second connection state item establishing submodule is used to establish a second connection state item based on the second source Internet Protocol address and the second target Internet Protocol address.

[0041] Optionally, the judging module includes:

[0042] A judgment submodule is used to judge whether the response corresponds to the second connection status item based on the source Internet Protocol address and the target Internet Protocol address of the response.

[0043] Optionally, the device comprises:

[0044] The second response sending module is used to send the response to the client by using the backend traffic director if the response does not correspond to the second connection status item.

[0045] Optionally, the first connection status item has an aging time; and the device includes:

[0046] An invalidation judgment module, configured to judge whether the first connection status item is invalid by using the back-end traffic director based on the current time and the aging time;

[0047] a data packet determination module, configured to determine, when the backend traffic director intercepts a pending request, whether the pending request and the request include the same data packet based on the source Internet Protocol address, the target Internet Protocol address, the first source Internet Protocol address, and the first target Internet Protocol address of the pending request using the backend traffic director;

[0048] An updating module is used to update the aging time of the first connection status item using the backend traffic director if the pending request and the request include the same data packet.

[0049] Optionally, the device comprises:

[0050] A termination mark judgment module, used for judging whether the request to be processed includes a termination mark by using the back-end traffic director if the request to be processed and the request include the same data packet;

[0051] The status setting module is used to use the backend traffic director to put the first connection status item into an invalid state if the pending request includes the termination mark.

[0052] Optionally, the backend traffic director is a network card driver and / or an extended packet filter program.

[0053] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0054] The memory is used to store computer programs;

[0055] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.

[0056] The embodiment of the present invention further discloses one or more computer-readable media on which instructions are stored. When executed by one or more processors, the processors are enabled to execute the method described in the embodiment of the present invention.

[0057] The embodiments of the present invention include the following advantages:

[0058] In an embodiment of the present invention, a preset load balancer is used to receive a request sent by a preset client, and a preset media access control address is configured for the load balancer. The load balancer is used to forward the request to a preset backend server; the backend server is configured with a backend traffic director; the client and the backend server are located in the same subnet. In the process of forwarding the request to the backend server, the backend traffic director is used to intercept the request, and based on the request, a connection state item is established. The backend traffic director is used to send the request to the backend server, and the response sent by the backend server to the request is intercepted. The backend traffic director is used to determine whether the response corresponds to the connection status item. If it corresponds, the backend traffic director is used to modify the target address of the response to the media access control address, and the response is sent to the load balancer. The load balancer is used to send the response to the client, which solves the problem of the forwarding reply type load balancer in NAT mode. If the client and the backend server are in the same subnet, the backend server needs to be specially configured for routing to ensure that the backend server can send the response to the load balancer. This makes the deployment of the forwarding reply type load balancer more flexible, and no longer requires special routing configuration for the backend server, or the load balancer is used as the gateway of the backend server, so as to meet user needs more friendly, and can also support horizontal expansion through ECMP (Equal-Cost Multi-Path) and other routing methods. In addition, while ensuring that the backend server can send the response to the load balancer, the problem of the client's source IP address being modified is avoided, and services that need to be processed according to the client's source IP address can be handled. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 It is a flow chart of the steps of a request processing method of a load balancer provided in an embodiment of the present invention;

[0060] Figure 2 It is a flowchart of a request processing method of a load balancer provided in an embodiment of the present invention;

[0061] Figure 3 is a flowchart of the steps of another method for processing a request of a load balancer provided in an embodiment of the present invention;

[0062] Figure 4 is a structural block diagram of a request processing device of a load balancer provided in an embodiment of the present invention;

[0063] Figure 5 is a block diagram of an electronic device provided in an embodiment of the present invention;

[0064] Figure 6 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0065] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0066] To facilitate understanding of the technical solutions and technical effects of the embodiments of the present invention, the prior art of the present invention is briefly described below.

[0067] With the rapid development of cloud computing, network data access has increased dramatically. In order to meet the needs of large enterprises and data centers for high-bandwidth and high-stability networks, load balancers have been widely used. Load balancers are usually used in conjunction with backend servers. Load balancers can distribute incoming network traffic to multiple backend servers to optimize resource usage, maximize throughput, reduce response time, and prevent overload of any single server.

[0068] In the related art, the four-layer load balancer includes a direct reply type load balancer and a forward reply type load balancer. After receiving a client request, the direct reply type load balancer can directly reply to the client; while after receiving a client request, the forward reply type load balancer will forward the request to the backend server, and the response of the backend server will be sent to the load balancer, and then sent to the client by the load balancer. Although the performance of the direct reply type load balancer is better than that of the forward reply type load balancer, when the direct reply type load balancer is used in conjunction with the backend server, specific configuration of the backend server is required, or the direct reply type load balancer and the backend server are required to be in the same subnet. There is no such limitation when the forward reply type load balancer is used in conjunction with the backend server. It should be noted that the request sent by the client can also be called access traffic.

[0069] Forward-reply type load balancers usually have NAT (Network Address Translation) mode and FULLNAT (Full Network Address Translation) mode.

[0070] In NAT mode, the forward-reply load balancer uses DNAT (Destination Network Address Translation) to forward client requests. Specifically, when the client's request reaches the load balancer, the load balancer modifies the destination IP (Internet Protocol) address of the request, changes it to the IP address of the backend server, and then forwards the request to the backend server.

[0071] In FULLNAT mode, the forward-reply load balancer not only performs DNAT processing, but also SNAT (Source Network Address Translation). Specifically, before forwarding the request to the backend server, the load balancer will not only modify the destination IP address of the request, but also modify the source IP address of the request, usually changing the source IP address to the IP address of the load balancer. When the backend server processes the request and returns a response, the load balancer will perform address translation again, modifying the source IP address of the response to the IP address of the load balancer, and modifying the target IP address of the response to the IP address of the client.

[0072] In NAT mode, since the forwarding-reply load balancer does not perform SNAT processing on the requests sent by the client, the load balancer in NAT mode has at least the following problems:

[0073] If the client and the backend server are in the same subnet, the backend server will send the response directly to the client's IP address instead of to the load balancer's IP address. Therefore, special routing configuration is required for the backend server to ensure that the backend server can send the response to the load balancer.

[0074] If the client and the backend server are in different subnets, the backend server will send the response to the default gateway. Therefore, in order to ensure that the backend server can send the response to the load balancer, special routing configuration is required for the backend server, or the load balancer is used as the gateway of the backend server.

[0075] Compared with NAT mode, the forward-reply load balancer in FULLNAT mode does not require special routing configuration for the backend server. However, in FULLNAT mode, the backend server cannot obtain the source IP address of the client. Therefore, in FULLNAT mode, the backend server cannot handle services that need to be processed based on the source IP address of the client.

[0076] Reference Figure 1 , shows a flow chart of a request processing method of a load balancer provided in an embodiment of the present invention, which may specifically include the following steps:

[0077] Step 101, using a preset load balancer to receive a request sent by a preset client, and configuring a preset media access control address for the load balancer;

[0078] In the embodiment of the present invention, the load balancer is a forward-reply type load balancer. The load balancer can receive requests sent by the client. The request can also be called forward traffic.

[0079] When the load balancer receives the request sent by the client, a MAC (Media Access Control) address may be configured for the load balancer. It should be noted that the forward-reply type load balancer in the embodiment of the present invention is in NAT mode.

[0080] Step 102, using the load balancer to forward the request to a preset backend server; the backend server is configured with a backend traffic director; the client and the backend server are located in the same subnet;

[0081] In an embodiment of the present invention, since the forward-reply type load balancer is in NAT mode, when the client's request reaches the load balancer, the load balancer will modify the destination IP address of the request, changing it from the IP address of the load balancer to the IP address of the back-end server, but will not modify the source IP address of the request, and the source IP address is still the client. Then, the forward-reply type load balancer can forward the request sent by the client to the back-end server. It should be noted that the back-end server is configured with a back-end traffic director, and the client and the back-end server are located in the same subnet. The back-end traffic director is located on the network interface of the back-end server and can intercept, modify and redirect the inbound and outbound network traffic of the back-end server. The forward-reply type load balancer can operate on the network layer to perform request forwarding. The network layer is the third layer in the OSI (Open Systems Interconnection, Open Systems Interconnection Communication Reference) model.

[0082] In some embodiments of the present invention, the backend traffic director is a network card driver and / or an extended packet filter program.

[0083] In an embodiment of the present invention, the backend traffic director can be a network card driver or an eBPF program (Extended Packet Filter Program), which is unaware of the backend service. The backend server does not need to know the existence of the backend traffic director or its operation details. The backend server only needs to process the received request without caring about how the request is directed to it.

[0084] Step 103, in the process of forwarding the request to the backend server, intercepting the request by using the backend traffic director, and establishing a connection state item based on the request;

[0085] In the embodiment of the present invention, in the process of a request being sent from the load balancer to the backend server, the backend traffic director can be used to intercept the request and establish a connection state item based on the request.

[0086] In some embodiments of the present invention, in the process of forwarding the request to the backend server, the request includes a first source Internet Protocol address and a first target Internet Protocol address; and establishing a connection state item based on the request includes:

[0087] establishing a first connection state item based on the first source Internet Protocol address and the first target Internet Protocol address;

[0088] using the first source Internet Protocol address as a second destination Internet Protocol address and using the first destination Internet Protocol address as a second source Internet Protocol address;

[0089] A second connection state entry is established based on the second source Internet Protocol address and the second target Internet Protocol address.

[0090] In the embodiment of the present invention, when a request is forwarded from the load balancer to the backend server, the request includes an IP data packet, which includes a first source IP address, a first target IP address, a first source port, a first target port, and a protocol type.

[0091] When the client's request reaches the load balancer, the load balancer will modify the destination IP address of the request from the load balancer's IP address to the backend server's IP address, but will not modify the source IP address of the request, which is still the client. Therefore, the first source IP address is the client and the first target IP address is the backend server.

[0092] In an embodiment of the present invention, when a request is forwarded from a load balancer to a backend server, the backend traffic director is used to intercept the request and determine whether the load balancer is configured with a MAC address. If the load balancer is configured with a MAC address, the five-tuple information is extracted from the requested IP data packet. The five-tuple information includes a first source IP address, a first target IP address, a first source port, a first target port, and a protocol type. The five-tuple information is a forward flow five-tuple information.

[0093] The reverse flow five-tuple information can be obtained according to the forward flow five-tuple information. Specifically, the first source IP address is used as the second target IP address, the first target IP address is used as the second source IP address, the first source port is used as the second target port, and the first target port is used as the second source port. The second source IP address, the second target IP address, the second source port, the second target port and the protocol type can constitute the reverse flow five-tuple information.

[0094] In the embodiment of the present invention, when the load balancer is configured with a MAC address, a first connection state item may be established using the forward flow quintuple information as an index, and a second connection state item may be established using the reverse flow quintuple information as an index.

[0095] Step 104, using the backend traffic director to send the request to the backend server, and intercepting the response sent by the backend server to the request;

[0096] In an embodiment of the present invention, the back-end traffic director may send a request to a back-end server. The back-end server may send a response to the request. The response may also be referred to as reverse traffic. The response includes an IP data packet, the source IP address in the IP data packet is the second source IP address, the destination IP address is the second destination IP address, the source port is the second source port, and the destination port is the second destination port. Therefore, the source IP address in the response data packet is the back-end server, and the destination IP address is the client. At this time, the destination address of the response determined according to the second destination IP address is the MAC address of the client.

[0097] In an embodiment of the present invention, the backend traffic director can intercept the response sent by the backend server to the request. The response is sent to the client.

[0098] Step 105, using the backend traffic director to determine whether the response corresponds to the connection status item;

[0099] In an embodiment of the present invention, the backend traffic director can intercept the response sent by the backend server to the request. Then, the backend traffic director is used to determine whether there is a connection status item corresponding to the response in the backend traffic director, including determining whether the response corresponds to any connection status item in the backend traffic director.

[0100] In some embodiments of the present invention, the determining whether the response corresponds to the connection status item includes:

[0101] Based on the source Internet Protocol address and the target Internet Protocol address of the response, it is determined whether the response corresponds to the second connection state item.

[0102] In an embodiment of the present invention, a backend traffic director is used to determine whether there is a connection status item corresponding to the response in the backend traffic director, including determining whether the response corresponds to the second connection status item in the backend traffic director.

[0103] If the source IP address, destination IP address, source port, destination port, protocol type and other information in the response IP data packet are the same as the five-tuple information corresponding to the second connection status item, it is determined that the response corresponds to the second connection status item.

[0104] Step 106, if it corresponds, modifying the target address of the response to the media access control address by using the backend traffic director, and sending the response to the load balancer;

[0105] In an embodiment of the present invention, if there is no connection status item corresponding to the response in the backend traffic director, since the client and the backend server are in the same subnet, the target IP address of the response is the client, and the backend server will directly send the request to the client.

[0106] If the response corresponds to the second connection status item, that is, there is a connection status item corresponding to the response in the backend traffic director, the backend traffic director is used to modify the target address of the response from the client's MAC address to the media access control address of the load balancer, and the response is sent to the load balancer.

[0107] Step 107: Use the load balancer to send the response to the client.

[0108] In the embodiment of the present invention, after the load balancer receives the response, the load balancer may send the response to the client.

[0109] In some embodiments of the invention, the method comprises:

[0110] If the response does not correspond to the second connection status item, the response is sent to the client using the backend traffic director.

[0111] In an embodiment of the present invention, if the response does not correspond to the second connection status item, and no other connection status item corresponding to the response exists in the backend traffic director, the response is sent to the client.

[0112] In some embodiments of the present invention, the first connection status item has an aging time; and the method comprises:

[0113] Based on the current time and the aging time, using the backend traffic director to determine whether the first connection status item is invalid;

[0114] When the backend traffic director intercepts a pending request, based on the source Internet Protocol address and the destination Internet Protocol address of the pending request and the first source Internet Protocol address and the first destination Internet Protocol address, the backend traffic director is used to determine whether the pending request and the request include the same data packet;

[0115] If the pending request and the request include the same data packet, the backend traffic director is used to update the aging time of the first connection status item.

[0116] In the embodiment of the present invention, the requested connection status item has an aging time, and based on the current time and the aging time, the backend traffic director is used to determine whether the first connection status item is invalid. Specifically, when the current time reaches the aging time, the first connection status item is invalid.

[0117] When the backend traffic director intercepts a pending request, based on the five-tuple information of the source Internet Protocol address, the target Internet Protocol address, the source port, the target port, and the protocol type in the IP data packet of the pending request and the five-tuple information corresponding to the first connection status item, the backend traffic director is used to determine whether the pending request and the request include the same IP data packet. If the pending request and the request include the same IP data packet, the pending request and the request belong to the same request, and the aging time of the first connection status item can be updated by the backend traffic director. That is, when the backend traffic director receives an IP data packet of the same request, the five-tuple in the IP data packet is used to index the connection status item corresponding to the IP data packet, and the aging time of the connection status item corresponding to the IP data packet is updated.

[0118] In some embodiments of the invention, the method comprises:

[0119] If the pending request and the request include the same data packet, using the backend traffic director to determine whether the pending request includes a termination mark;

[0120] If the pending request includes the termination mark, the first connection status item is placed in an invalid state using the backend traffic director.

[0121] In an embodiment of the present invention, if the pending request and the request include the same data packet, then the pending request and the request belong to the same request, and the back-end traffic director is used to determine whether the pending request includes a termination mark. If the pending request includes a termination mark, the back-end traffic director is used to put the first connection status item into an invalid state. That is, when the back-end traffic director detects an IP data packet containing a termination mark in the traffic, the five-tuple information in the IP data packet is used to index the connection status item corresponding to the traffic, and the connection status item is invalidated. The invalidation mark includes an RST (Reset) mark and a FIN (Finish) mark.

[0122] In an embodiment of the present invention, a preset load balancer is used to receive a request sent by a preset client, and a preset media access control address is configured for the load balancer. The load balancer is used to forward the request to a preset backend server; the backend server is configured with a backend traffic director; the client and the backend server are located in the same subnet. In the process of forwarding the request to the backend server, the backend traffic director is used to intercept the request, and based on the request, a connection state item is established. The backend traffic director is used to send the request to the backend server, and the response sent by the backend server to the request is intercepted. The backend traffic director is used to determine whether the response corresponds to the connection status item. If it corresponds, the backend traffic director is used to modify the target address of the response to the media access control address, and the response is sent to the load balancer. The load balancer is used to send the response to the client, which solves the problem of the forwarding reply type load balancer in NAT mode. If the client and the backend server are in the same subnet, the backend server needs to be specially configured for routing to ensure that the backend server can send the response to the load balancer. This makes the deployment of the forwarding reply type load balancer more flexible, and no longer requires special routing configuration for the backend server, or the load balancer is used as the gateway of the backend server, so as to meet user needs more friendly, and can also support horizontal expansion through ECMP (Equal-Cost Multi-Path) and other routing methods. In addition, while ensuring that the backend server can send the response to the load balancer, the problem of the client's source IP address being modified is avoided, and services that need to be processed according to the client's source IP address can be handled.

[0123] Reference Figure 2 , showing a flow chart of a request processing method of a load balancer provided in an embodiment of the present invention. The client sends a request to the load balancer through the cluster physical gateway, the load balancer receives the request sent by the client, and configures a preset media access control address for the load balancer, and performs DNAT processing on the request. The load balancer forwards the request to the preset backend server through the user virtual network. The backend server is configured with a backend traffic director. The client and the backend server are located in the same subnet.

[0124] When the request is forwarded to the backend server, the backend traffic director intercepts the request and establishes a connection status item based on the request. Then, the backend traffic director sends the request to the backend server and intercepts the response sent by the backend server to the request; the backend traffic director determines whether the response corresponds to the connection status item. If so, the backend traffic director modifies the target address of the response to the media access control address and sends the response to the load balancer, which sends the response to the client.

[0125] Reference Figure 3 , shows a flowchart of the steps of another method for processing a request of a load balancer provided in an embodiment of the present invention, which is applied to a backend traffic director and specifically includes the following steps:

[0126] Step 301, start.

[0127] Step 302, determine whether the load balancer is configured with a special MAC address. If yes, proceed to step 303; if not, proceed to step 311.

[0128] Step 303, determine whether the traffic received by the back-end traffic director is forward traffic. If yes, proceed to step 306; if not, proceed to step 304.

[0129] Step 304, determine whether there is a connection status item in the backend traffic director. If yes, proceed to step 305. If no, proceed to step 311.

[0130] Step 305, modify the target MAC address.

[0131] Step 306, determine whether there is a connection status item. If yes, proceed to step 307; if no, proceed to step 310.

[0132] Step 307, determine whether there is an end mark in the data packet of the forward traffic. If yes, proceed to step 308; if not, proceed to step 309.

[0133] Step 308, end the connection state.

[0134] Step 309: Update the connection status expiration time.

[0135] Step 310: Establish a new connection state.

[0136] Step 311, using the backend traffic director to release the data packets of the traffic.

[0137] Step 312, end.

[0138] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0139] Reference Figure 4 , shows a structural block diagram of a request processing device of a load balancer provided in an embodiment of the present invention, which may specifically include the following modules:

[0140] The request receiving module 401 is used to receive a request sent by a preset client using a preset load balancer, and configure a preset media access control address for the load balancer;

[0141] The request forwarding module 402 is used to forward the request to a preset backend server using the load balancer; the backend server is configured with a backend traffic director; the client and the backend server are located in the same subnet;

[0142] A request interception module 403, configured to intercept the request using the backend traffic director in the process of forwarding the request to the backend server, and to establish a connection status item based on the request;

[0143] A response interception module 404, configured to send the request to the backend server using the backend traffic director, and intercept a response sent by the backend server to the request;

[0144] A determination module 405, configured to use the backend traffic director to determine whether the response corresponds to the connection status item;

[0145] An address modification module 406, configured to modify the target address of the response to the media access control address by using the backend traffic director if it corresponds, and send the response to the load balancer;

[0146] The first response sending module 407 is used to send the response to the client by using the load balancer.

[0147] In an optional embodiment of the present invention, in the process of forwarding the request to the backend server, the request includes a first source Internet Protocol address and a first target Internet Protocol address; the request interception module includes:

[0148] A first connection state item establishment submodule, configured to establish a first connection state item based on the first source Internet Protocol address and the first target Internet Protocol address;

[0149] as a submodule, for using the first source Internet Protocol address as a second target Internet Protocol address, and using the first target Internet Protocol address as a second source Internet Protocol address;

[0150] The second connection state item establishing submodule is used to establish a second connection state item based on the second source Internet Protocol address and the second target Internet Protocol address.

[0151] In an optional embodiment of the present invention, the judgment module includes:

[0152] A judgment submodule is used to judge whether the response corresponds to the second connection status item based on the source Internet Protocol address and the target Internet Protocol address of the response.

[0153] In an optional embodiment of the present invention, the device comprises:

[0154] The second response sending module is used to send the response to the client by using the backend traffic director if the response does not correspond to the second connection status item.

[0155] In an optional embodiment of the present invention, the first connection status item has an aging time; and the device includes:

[0156] An invalidation judgment module, configured to judge whether the first connection status item is invalid by using the backend traffic director based on the current time and the aging time;

[0157] a data packet determination module, configured to determine, when the backend traffic director intercepts a pending request, whether the pending request and the request include the same data packet based on the source Internet Protocol address, the target Internet Protocol address, the first source Internet Protocol address, and the first target Internet Protocol address of the pending request using the backend traffic director;

[0158] An updating module is used to update the aging time of the first connection status item using the backend traffic director if the pending request and the request include the same data packet.

[0159] In an optional embodiment of the present invention, the device comprises:

[0160] A termination mark judgment module, used for judging whether the request to be processed includes a termination mark by using the back-end traffic director if the request to be processed and the request include the same data packet;

[0161] A status setting module is used to use the backend traffic director to put the first connection status item into an invalid state if the pending request includes the termination mark.

[0162] In an optional embodiment of the present invention, the backend traffic director is a network card driver and / or an extended packet filter program.

[0163] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0164] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 5As shown, it includes a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.

[0165] Memory 503, used for storing computer programs;

[0166] The processor 501 is used to execute the program stored in the memory 503, and implements the following steps:

[0167] Using a preset load balancer to receive a request sent by a preset client, and configuring a preset media access control address for the load balancer;

[0168] The request is forwarded to a preset backend server by using the load balancer; the backend server is configured with a backend traffic director; the client and the backend server are located in the same subnet;

[0169] In the process of forwarding the request to the backend server, intercepting the request by the backend traffic director, and establishing a connection state item based on the request;

[0170] Using the backend traffic director to send the request to the backend server, and intercepting the response sent by the backend server to the request;

[0171] Determining, using the backend traffic director, whether the response corresponds to the connection status item;

[0172] If it corresponds, modify the target address of the response to the media access control address using the backend traffic director, and send the response to the load balancer;

[0173] The response is sent to the client using the load balancer.

[0174] In an optional embodiment of the present invention, in the process of forwarding the request to the backend server, the request includes a first source Internet Protocol address and a first target Internet Protocol address; and establishing a connection state item based on the request includes:

[0175] establishing a first connection state item based on the first source Internet Protocol address and the first target Internet Protocol address;

[0176] using the first source Internet Protocol address as a second destination Internet Protocol address and using the first destination Internet Protocol address as a second source Internet Protocol address;

[0177] A second connection state entry is established based on the second source Internet Protocol address and the second target Internet Protocol address.

[0178] In an optional embodiment of the present invention, the determining whether the response corresponds to the connection status item includes:

[0179] Based on the source Internet Protocol address and the target Internet Protocol address of the response, it is determined whether the response corresponds to the second connection state item.

[0180] In an optional embodiment of the present invention, the method includes:

[0181] If the response does not correspond to the second connection status item, the response is sent to the client using the backend traffic director.

[0182] In an optional embodiment of the present invention, the first connection status item has an aging time; and the method includes:

[0183] Based on the current time and the aging time, using the backend traffic director to determine whether the first connection status item is invalid;

[0184] When the backend traffic director intercepts a pending request, based on the source Internet Protocol address and the destination Internet Protocol address of the pending request and the first source Internet Protocol address and the first destination Internet Protocol address, the backend traffic director is used to determine whether the pending request and the request include the same data packet;

[0185] If the pending request and the request include the same data packet, the backend traffic director is used to update the aging time of the first connection status item.

[0186] In an optional embodiment of the present invention, the method includes:

[0187] If the pending request and the request include the same data packet, using the backend traffic director to determine whether the pending request includes a termination mark;

[0188] If the pending request includes the termination mark, the first connection status item is placed in an invalid state using the backend traffic director.

[0189] In an optional embodiment of the present invention, the backend traffic director is a network card driver and / or an extended packet filter program.

[0190] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0191] The communication interface is used for communication between the above terminal and other devices.

[0192] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0193] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0194] like Figure 6 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 601 is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes a request processing method for a load balancer described in the above embodiment.

[0195] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the request processing method of a load balancer described in the above embodiment.

[0196] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0197] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0198] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0199] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A method for processing a request of a load balancer, characterized in that: The method comprises: Using a preset load balancer to receive a request sent by a preset client, and configuring a preset media access control address for the load balancer; The request is forwarded to a preset backend server by using the load balancer; the backend server is configured with a backend traffic director; the client and the backend server are located in the same subnet; In the process of forwarding the request to the backend server, intercepting the request by the backend traffic director, and establishing a connection state item based on the request; Using the backend traffic director to send the request to the backend server, and intercepting the response sent by the backend server to the request; Determining, using the backend traffic director, whether the response corresponds to the connection status item; If it corresponds, modify the target address of the response to the media access control address using the backend traffic director, and send the response to the load balancer; The response is sent to the client using the load balancer.

2. The method according to claim 1, characterized in that In the process of forwarding the request to the backend server, the request includes a first source Internet Protocol address and a first destination Internet Protocol address; The establishing of a connection state item based on the request includes: establishing a first connection state item based on the first source Internet Protocol address and the first target Internet Protocol address; using the first source Internet Protocol address as a second destination Internet Protocol address and using the first destination Internet Protocol address as a second source Internet Protocol address; A second connection state entry is established based on the second source Internet Protocol address and the second target Internet Protocol address.

3. The method according to claim 2, characterized in that The determining whether the response corresponds to the connection status item includes: Based on the source Internet Protocol address and the target Internet Protocol address of the response, it is determined whether the response corresponds to the second connection state item.

4. The method according to claim 3, characterized in that The method comprises: If the response does not correspond to the second connection status item, the response is sent to the client using the backend traffic director.

5. The method according to claim 2, characterized in that: The first connection status item has an aging time; and the method comprises: Based on the current time and the aging time, using the backend traffic director to determine whether the first connection status item is invalid; When the backend traffic director intercepts a pending request, based on the source Internet Protocol address and the destination Internet Protocol address of the pending request and the first source Internet Protocol address and the first destination Internet Protocol address, the backend traffic director is used to determine whether the pending request and the request include the same data packet; If the pending request and the request include the same data packet, the backend traffic director is used to update the aging time of the first connection status item.

6. The method according to claim 5, characterized in that The method comprises: If the pending request and the request include the same data packet, using the backend traffic director to determine whether the pending request includes a termination mark; If the pending request includes the termination mark, the first connection status item is placed in an invalid state using the backend traffic director.

7. The method according to claim 1, characterized in that The backend traffic director is a network card driver and / or an extended packet filter program.

8. A request processing device for a load balancer, characterized in that: The device comprises: A request receiving module, used to receive a request sent by a preset client using a preset load balancer, and configure a preset media access control address for the load balancer; A request forwarding module, used to forward the request to a preset backend server using the load balancer; the backend server is configured with a backend traffic director; the client and the backend server are located in the same subnet; A request interception module, used for intercepting the request by using the backend traffic director when the request is forwarded to the backend server, and establishing a connection status item based on the request; A response interception module, used to send the request to the backend server using the backend traffic director, and intercept the response sent by the backend server to the request; A determination module, configured to determine, using the backend traffic director, whether the response corresponds to the connection status item; An address modification module, for modifying the target address of the response to the media access control address by using the backend traffic director if corresponding, and sending the response to the load balancer; The first response sending module is used to send the response to the client by using the load balancer.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 7 when executing the program stored in the memory.

10. One or more computer-readable media having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method of any one of claims 1-7.

Citation Information

Patent Citations

  • Load balancing method and device thereof

    CN108449282A

  • Direct addressability and direct server return

    US20110225231A1