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

By introducing a backend traffic director into the forwarding-response load balancer, the special routing configuration problem of sending responses to the backend server in NAT mode is solved, enabling flexible deployment and horizontal scaling of the load balancer and avoiding modification of the client's source IP address.

CN119814789BActive Publication Date: 2025-11-04CHINA 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
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-11-04
Estimated Expiration
2044-12-04

AI Technical Summary

Technical Problem

In NAT mode, a forwarding-response load balancer requires special routing configuration for the backend servers to ensure that responses are sent to the load balancer.

Method used

By introducing a backend traffic director between the load balancer and the backend servers, requests are intercepted and connection status entries are established. The target address of the response is modified to the media access control address, ensuring that the response is sent to the load balancer.

Benefits of technology

No special routing configuration is required for the backend server. It supports horizontal scaling using routing methods such as ECMP, avoids modification of the client's source IP address, and meets user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814789B_ABST
    Figure CN119814789B_ABST
Patent Text Reader

Abstract

The application provides a request processing method and device of a load balancer, electronic equipment and a readable medium. The load balancer receives a request sent by a client, and a media access control address is configured for the load balancer. The load balancer forwards the request to a backend server. 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 intercepts the request, and a connection state item is established based on the request. The backend traffic director sends the request to the backend server, and intercepts a response sent by the backend server to the request. The backend traffic director judges whether the response corresponds to the connection state item. If the response corresponds to the connection state item, the backend traffic director modifies a target address of the response to the media access control address, and sends the response to the load balancer. The load balancer sends the response to the client, 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] This invention relates to the field of communication technology, and in particular to a request processing method for a load balancer, a request processing apparatus for a load balancer, an electronic device, and a computer-readable medium. Background Technology

[0002] In related technologies, forward-response load balancers are typically used in conjunction with backend servers. Upon receiving a client request, the forward-response load balancer forwards the request to the backend server, and the backend server's response is sent to the load balancer, which then forwards it to the client.

[0003] Forward-response load balancers typically operate in NAT (Network Address Translation) mode. In NAT mode, they use DNAT (Destination Network Address Translation) to forward client requests. Specifically, when a client request reaches the load balancer, it modifies the destination IP address of the request to the IP address of the backend server and then forwards the request to that server. However, when a client request reaches the load balancer, the forward-response load balancer does not modify the source IP address of the request from the client's IP address to the load balancer's. In this case, if the client and the backend server are on the same subnet, the backend server will directly send the response to the client's IP address, not the load balancer's IP address. Therefore, special routing configurations are required for the backend server to ensure that it sends the response to the load balancer. Summary of the Invention

[0004] This invention provides a request processing method, apparatus, electronic device, and computer-readable storage medium for a load balancer, to solve the problem that a forwarding-response load balancer in NAT mode requires special routing configuration for the backend server to ensure that the backend server can send the response to the load balancer.

[0005] This invention discloses a request processing method for a load balancer, the method comprising:

[0006] The system uses a preset load balancer to receive requests sent by a preset client and configures a preset media access control address for the load balancer.

[0007] The load balancer forwards 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.

[0008] During the process of the request being forwarded to the backend server, the backend traffic director intercepts the request and establishes a connection state entry based on the request;

[0009] The backend traffic redirector is used to send the request to the backend server and to intercept the response sent by the backend server in response to the request.

[0010] The backend traffic director is used to determine whether the response corresponds to the connection status item;

[0011] If they correspond, 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.

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

[0013] Optionally, during 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; establishing a connection state item based on the request includes:

[0014] A first connection status entry is established based on the first source Internet Protocol address and the first target Internet Protocol address;

[0015] Use the first source Internet Protocol address as the second target Internet Protocol address, and use the first target Internet Protocol address as the second source Internet Protocol address;

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

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

[0018] Based on the source Internet Protocol address and the destination Internet Protocol address of the response, determine whether the response corresponds to the second connection status item.

[0019] Optionally, the method includes:

[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 status item has an aging time; the method includes:

[0022] Based on the current time and the aging time, the backend traffic direction finder determines whether the first connection status item is invalid.

[0023] When the backend traffic directional device intercepts a request to be processed, it uses the source Internet Protocol address, destination Internet Protocol address, the first source Internet Protocol address, and the first destination Internet Protocol address of the request to be processed to determine whether the request to be processed and the request contain the same data packets.

[0024] If the pending request and the request contain the same data packets, then the aging time of the first connection status item is updated using the backend traffic director.

[0025] Optionally, the method includes:

[0026] If the pending request and the request contain the same data packets, then the backend traffic direction finder is used to determine whether the pending request contains a termination flag;

[0027] If the pending request includes the termination flag, then the first connection status item is set to an invalid state using the backend traffic director.

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

[0029] This invention also discloses a request processing apparatus for a load balancer, the apparatus comprising:

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

[0031] A request forwarding module 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;

[0032] The request interception module is used to intercept the request using the backend traffic director during the process of the request being forwarded to the backend server, and to establish a connection status item based on the request;

[0033] The response interception module is used to send the request to the backend server using the backend traffic redirector, and to intercept the response sent by the backend server in response to the request.

[0034] The judgment module is used to determine whether the response corresponds to the connection status item using the backend traffic orienter;

[0035] The address modification module is used to modify the target address of the response to the media access control address if there is a correspondence, and then send the response to the load balancer.

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

[0037] Optionally, during 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 request interception module includes:

[0038] The first connection status item establishment submodule is used to establish a first connection status item based on the first source Internet Protocol address and the first target Internet Protocol address;

[0039] As a submodule, it is used to use the first source Internet Protocol address as the second target Internet Protocol address, and the first target Internet Protocol address as the second source Internet Protocol address;

[0040] The second connection status item establishment submodule is used to establish a second connection status item based on the second source Internet Protocol address and the second destination Internet Protocol address.

[0041] Optionally, the determination module includes:

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

[0043] Optionally, the device includes:

[0044] The second response sending module is used to send the response to the client 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; the device includes:

[0046] The failure determination module is used to determine whether the first connection status item is invalid based on the current time and the aging time using the backend traffic direction finder;

[0047] The data packet judgment module is used to determine, when the backend traffic direction finds a pending request, whether the pending request and the request contain the same data packets based on the source Internet Protocol address, the destination Internet Protocol address, the first source Internet Protocol address, and the first destination Internet Protocol address of the pending request.

[0048] An update 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 contain the same data packets.

[0049] Optionally, the device includes:

[0050] The termination flag determination module is used to determine whether the request to be processed contains a termination flag if the request to be processed and the request contain the same data packets.

[0051] The status is set in the module to place the first connection status item in an invalid state using the backend traffic director if the pending request includes the termination flag.

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

[0053] This invention also discloses an electronic device, including 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;

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

[0055] When the processor executes a program stored in the memory, it implements the method described in the embodiments of the present invention.

[0056] This invention also discloses one or more computer-readable media storing instructions that, when executed by one or more processors, cause the processors to perform the methods described in this invention.

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

[0058] In this embodiment of the invention, a preset load balancer is used to receive requests sent by a preset client, and a preset media access control address is configured for the load balancer. The load balancer forwards the requests to a preset backend server; the backend server is configured with a backend traffic directive; the client and the backend server are located in the same subnet. During the forwarding of the request to the backend server, the backend traffic directive intercepts the request and establishes a connection state entry based on the request. The backend traffic directive then sends the request to the backend server and intercepts the response sent by the backend server in response to the request. By using a backend traffic locator to determine if the response matches the connection status entry, and if so, modifying the response's destination address to the Media Access Control (MAC) address using the backend traffic locator, the response is sent to the load balancer. The load balancer then forwards the response to the client. This solves the problem of forward-response load balancers in NAT mode, where special routing configurations are required for the backend server if the client and backend server are on the same subnet to ensure the backend server can send responses to the load balancer. This makes the deployment of forward-response load balancers more flexible, eliminating the need for special routing configurations for the backend server or using the load balancer as a gateway for the backend server. This better meets user needs and supports horizontal scaling via routing methods such as ECMP (Equal-Cost Multi-Path). Furthermore, by ensuring the backend server can send responses to the load balancer, it avoids the problem of the client's source IP address being modified, enabling services that require processing based on the client's source IP address. Attached Figure Description

[0059] Figure 1 This is a flowchart of the steps of a request processing method for a load balancer provided in an embodiment of the present invention;

[0060] Figure 2 This is a flowchart illustrating a request processing method for a load balancer provided in an embodiment of the present invention.

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

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

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

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

[0065] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

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

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

[0068] In related technologies, Layer 4 load balancers include direct-response load balancers and forward-response load balancers. Direct-response load balancers can directly reply to the client after receiving a request; while forward-response load balancers, upon receiving a client request, forward the request to the backend server, and the backend server's response is sent to the load balancer, which then forwards it to the client. Although direct-response load balancers outperform forward-response load balancers, they require specific configuration of the backend server or must be on the same subnet as the backend server when used together. Forward-response load balancers do not have this limitation. It should be noted that the requests sent by the client are also referred to as access traffic.

[0069] Forward-response load balancers typically have NAT (Network Address Translation) mode and FULLNAT (Full Network Address Translation) mode.

[0070] In NAT mode, forwarding-response load balancers use DNAT (Destination Network Address Translation) to forward client requests. Specifically, when a client request arrives at the load balancer, the load balancer modifies the destination IP (Internet Protocol) address of the request, changing it to the IP address of the backend server, and then forwards the request to the backend server.

[0071] In FULLNAT mode, a forwarding-response load balancer performs not only DNAT processing but also SNAT (Source Network Address Translation). Specifically, before forwarding a request to the backend server, the load balancer modifies both the destination IP address and the source IP address, typically changing the source IP address to the load balancer's IP address. When the backend server processes the request and returns a response, the load balancer performs address translation again, changing the source IP address of the response to the load balancer's IP address and the destination IP address to the client's IP address.

[0072] In NAT mode, because forward-response load balancers do not perform SNAT processing on requests sent by clients, load balancers in NAT mode have at least the following problems:

[0073] If the client and the backend server are on the same subnet, the backend server will send the response directly to the client's IP address, instead of the load balancer's IP address. Therefore, special routing configuration is required for the backend server to ensure that it sends 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, to ensure that the backend server can send the response to the load balancer, special routing configurations are needed for the backend server, or the load balancer needs to be used as the gateway for the backend server.

[0075] While a forwarding-response load balancer in FULLNAT mode does not require special routing configurations for backend servers compared to NAT mode, in FULLNAT mode, the backend servers cannot obtain the client's source IP address. Therefore, in FULLNAT mode, the backend servers cannot handle services that require processing based on the client's source IP address.

[0076] Reference Figure 1 The diagram illustrates a flowchart of a request processing method for a load balancer provided in an embodiment of the present invention, which may specifically include the following steps:

[0077] Step 101: Receive requests sent by preset clients using a preset load balancer, and configure a preset media access control address for the load balancer.

[0078] In this embodiment of the invention, the load balancer is a forward-response load balancer. The load balancer can receive requests sent by clients. Requests can also be referred to as forward traffic.

[0079] When the load balancer receives a request from a client, a MAC (Media Access Control) address can be configured for it. It should be noted that the forwarding-response load balancer in this embodiment of the invention is in NAT mode.

[0080] Step 102: 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;

[0081] In this embodiment of the invention, since the forwarding-response load balancer is in NAT mode, when a client's request reaches the load balancer, the load balancer modifies the destination IP address of the request, changing it from the load balancer's IP address to the backend server's IP address, but does not modify the source IP address of the request; the source IP address remains the client's. Then, the forwarding-response load balancer can forward the client's request to the backend server. It should be noted that the backend server is configured with a backend traffic redirector, and the client and the backend server are located in the same subnet. The backend traffic redirector is located on the backend server's network interface and can intercept, modify, and redirect inbound and outbound network traffic to the backend server. The forwarding-response load balancer can operate at the network layer, performing request forwarding. The network layer is the third layer in the OSI (Open Systems Interconnection) model.

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

[0083] In this embodiment of the invention, the backend traffic redirector can be a network interface card driver or an eBPF (Extended Packet Filter) program, and is unaware of the backend service. The backend server does not need to know the existence of the backend traffic redirector or its operational details. The backend server only needs to process the received requests, without needing to know how the requests are redirected to it.

[0084] Step 103: During the process of the request being forwarded to the backend server, the backend traffic director is used to intercept the request, and a connection status entry is established based on the request;

[0085] In this embodiment of the invention, during 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 status entry based on the request.

[0086] In some embodiments of the present invention, during 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; establishing a connection status item based on the request includes:

[0087] A first connection status entry is established based on the first source Internet Protocol address and the first target Internet Protocol address;

[0088] Use the first source Internet Protocol address as the second target Internet Protocol address, and use the first target Internet Protocol address as the second source Internet Protocol address;

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

[0090] In this embodiment of the invention, during the process of requesting to be forwarded from the load balancer to the backend server, the request includes an IP packet. The IP packet includes a first source IP address, a first destination IP address, a first source port, a first destination port, and a protocol type.

[0091] When a client's request reaches the load balancer, the load balancer modifies the destination IP address of the request, changing it from the load balancer's IP address to the backend server's IP address. However, it does not modify the source IP address of the request, which remains the client's IP address. Therefore, the first source IP address is the client, and the first destination IP address is the backend server.

[0092] In this embodiment of the invention, when a request is forwarded from the load balancer to the backend server, the request is intercepted by a backend traffic directive, and it is determined 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 destination IP address, a first source port, a first destination port, and a protocol type. This five-tuple information is for a forward flow.

[0093] The reverse flow 5-tuple information can be obtained from the forward flow 5-tuple information. Specifically, the first source IP address is used as the second destination IP address, the first destination IP address as the second source IP address, the first source port as the second destination port, and the first destination port as the second source port. The second source IP address, second destination IP address, second source port, second destination port, and protocol type can form the reverse flow 5-tuple information.

[0094] In this embodiment of the invention, when the load balancer is configured with a MAC address, a first connection state entry can be established using the forward flow 5-tuple information as an index, and a second connection state entry can be established using the reverse flow 5-tuple information as an index.

[0095] Step 104: Use the backend traffic redirector to send the request to the backend server and intercept the response sent by the backend server in response to the request;

[0096] In this embodiment of the invention, the backend traffic redirector can send requests to a backend server. The backend server can then send a response to the request. The response, also known as reverse traffic, includes IP packets. The source IP address in the IP packets is a second source IP address, the destination IP address is a second destination IP address, the source port is a second source port, and the destination port is a second destination port. Therefore, the source IP address in the response packets is the backend server, and the destination IP address is the client. In this case, the destination address of the response, determined based on the second destination IP address, is the client's MAC address.

[0097] In this embodiment of the invention, the backend traffic redirector can intercept the response sent by the backend server in response to a request. This response is sent to the client.

[0098] Step 105: Use the backend traffic orienter to determine whether the response corresponds to the connection status item;

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

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

[0101] Based on the source Internet Protocol address and the destination Internet Protocol address of the response, determine whether the response corresponds to the second connection status item.

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

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

[0104] Step 106: If they correspond, 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.

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

[0106] If the response corresponds to the second connection status entry, that is, if there is a connection status entry corresponding to the response in the backend traffic direction setter, then the backend traffic direction setter is used to change 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 this embodiment of the invention, after the load balancer receives the response, the load balancer can send the response to the client.

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

[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 this embodiment of the invention, if the response does not correspond to the second connection status item, and there is no other connection status item corresponding to the response in the backend traffic directional device, then the response is sent to the client.

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

[0113] Based on the current time and the aging time, the backend traffic direction finder determines whether the first connection status item is invalid.

[0114] When the backend traffic directional device intercepts a request to be processed, it uses the source Internet Protocol address, destination Internet Protocol address, the first source Internet Protocol address, and the first destination Internet Protocol address of the request to be processed to determine whether the request to be processed and the request contain the same data packets.

[0115] If the pending request and the request contain the same data packets, then the aging time of the first connection status item is updated using the backend traffic director.

[0116] In this embodiment of the invention, the requested connection status item has an aging time. Based on the current time and the aging time, a backend traffic direction finder determines whether the first connection status item has expired. Specifically, the first connection status item expires when the current time reaches the aging time.

[0117] When the backend traffic locator intercepts a request to be processed, it uses the five-tuple information (source Internet Protocol address, destination Internet Protocol address, source port, destination port, and protocol type) in the IP packet of the request to be processed, along with the five-tuple information corresponding to the first connection state entry, to determine whether the request to be processed and the request contain the same IP packet. If the request to be processed and the request contain the same IP packet, then the request to be processed and the request belong to the same request, and the backend traffic locator can update the aging time of the first connection state entry. That is, when the backend traffic locator receives IP packets for the same request, it uses the five-tuple in the IP packet to index the connection state entry corresponding to that IP packet and updates the aging time of the connection state entry corresponding to that IP packet.

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

[0119] If the pending request and the request contain the same data packets, then the backend traffic direction finder is used to determine whether the pending request contains a termination flag;

[0120] If the pending request includes the termination flag, then the first connection status item is set to an invalid state using the backend traffic director.

[0121] In this embodiment of the invention, if the request to be processed and the request contain the same data packet, then the request to be processed and the request belong to the same request. The backend traffic locator is used to determine whether the request to be processed contains a termination flag. If the request to be processed contains a termination flag, the backend traffic locator places the first connection status item in an invalid state. That is, when the backend traffic locator detects an IP data packet containing a termination flag in the traffic, it uses the five-tuple information in the IP data packet to index the corresponding connection status item in the traffic and invalidates that connection status item. The invalidation flags include the RST (Reset) flag and the FIN (Finish) flag.

[0122] In this embodiment of the invention, a preset load balancer is used to receive requests sent by a preset client, and a preset media access control address is configured for the load balancer. The load balancer forwards the requests to a preset backend server; the backend server is configured with a backend traffic directive; the client and the backend server are located in the same subnet. During the forwarding of the request to the backend server, the backend traffic directive intercepts the request and establishes a connection state entry based on the request. The backend traffic directive then sends the request to the backend server and intercepts the response sent by the backend server in response to the request. By using a backend traffic locator to determine if the response matches the connection status entry, and if so, modifying the response's destination address to the Media Access Control (MAC) address using the backend traffic locator, the response is sent to the load balancer. The load balancer then forwards the response to the client. This solves the problem of forward-response load balancers in NAT mode, where special routing configurations are required for the backend server if the client and backend server are on the same subnet to ensure the backend server can send responses to the load balancer. This makes the deployment of forward-response load balancers more flexible, eliminating the need for special routing configurations for the backend server or using the load balancer as a gateway for the backend server. This better meets user needs and supports horizontal scaling via routing methods such as ECMP (Equal-Cost Multi-Path). Furthermore, by ensuring the backend server can send responses to the load balancer, it avoids the problem of the client's source IP address being modified, enabling services that require processing based on the client's source IP address.

[0123] Reference Figure 2 This diagram illustrates a request processing method for a load balancer according to 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 from the client, configures a preset Media Access Control (MAC) address for itself, and performs DNAT processing on the request. The load balancer forwards the request to a preset backend server through the user's 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] During the forwarding of the request to the backend server, the backend traffic locator intercepts the request and establishes a connection state entry based on the request. Then, the backend traffic locator sends the request to the backend server and intercepts the response sent by the backend server in response to the request. The backend traffic locator determines whether the response corresponds to the connection state entry. If they correspond, the backend traffic locator modifies the destination address of the response to the media access control address and sends the response to the load balancer. The load balancer then sends the response to the client.

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

[0126] Step 301, Begin.

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

[0128] Step 303: Determine whether the traffic received by the backend traffic redirector is positive traffic. If yes, proceed to step 306; otherwise, proceed to step 304.

[0129] Step 304: Determine if a connection status entry exists in the backend traffic direction finder. If yes, proceed to step 305. If no, proceed to step 311.

[0130] Step 305: Modify the target MAC address.

[0131] Step 306: Determine if a connection status entry exists. If yes, proceed to step 307; otherwise, proceed to step 310.

[0132] Step 307: Determine whether an end-of-line marker exists in the data packets of the forward traffic. If yes, proceed to step 308; otherwise, proceed to step 309.

[0133] Step 308: End connection.

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

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

[0136] Step 311: Use the backend traffic director to allow 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 all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0139] Reference Figure 4 The diagram illustrates a structural block diagram of a request processing device for 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 requests sent by a preset client using a preset load balancer, and to 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] The request interception module 403 is used to intercept the request using the backend traffic director during the process of the request being forwarded to the backend server, and to establish a connection status item based on the request;

[0143] The response interception module 404 is used to send the request to the backend server using the backend traffic director and to intercept the response sent by the backend server in response to the request.

[0144] The judgment module 405 is used to determine whether the response corresponds to the connection status item using the backend traffic orienter;

[0145] Address modification module 406 is used to modify the target address of the response to the media access control address using the backend traffic director if there is a correspondence, and send the response to the load balancer.

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

[0147] In an optional embodiment of the present invention, during 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 request interception module includes:

[0148] The first connection status item establishment submodule is used to establish a first connection status item based on the first source Internet Protocol address and the first target Internet Protocol address;

[0149] As a submodule, it is used to use the first source Internet Protocol address as the second target Internet Protocol address, and the first target Internet Protocol address as the second source Internet Protocol address;

[0150] The second connection status item establishment submodule is used to establish a second connection status item based on the second source Internet Protocol address and the second destination Internet Protocol address.

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

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

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

[0154] The second response sending module is used to send the response to the client 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; the device includes:

[0156] The failure determination module is used to determine whether the first connection status item is invalid based on the current time and the aging time using the backend traffic direction finder;

[0157] The data packet judgment module is used to determine, when the backend traffic direction finds a pending request, whether the pending request and the request contain the same data packets based on the source Internet Protocol address, the destination Internet Protocol address, the first source Internet Protocol address, and the first destination Internet Protocol address of the pending request.

[0158] An update 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 contain the same data packets.

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

[0160] The termination flag determination module is used to determine whether the request to be processed contains a termination flag if the request to be processed and the request contain the same data packets.

[0161] The status is set in the module to place the first connection status item in an invalid state using the backend traffic director if the pending request includes the termination flag.

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

[0163] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0164] In addition, embodiments of the present invention also provide 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 is used to store computer programs;

[0166] When processor 501 executes the program stored in memory 503, it performs the following steps:

[0167] The system uses a preset load balancer to receive requests sent by a preset client and configures a preset media access control address for the load balancer.

[0168] The load balancer forwards 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.

[0169] During the process of the request being forwarded to the backend server, the backend traffic director intercepts the request and establishes a connection state entry based on the request;

[0170] The backend traffic redirector is used to send the request to the backend server and to intercept the response sent by the backend server in response to the request.

[0171] The backend traffic director is used to determine whether the response corresponds to the connection status item;

[0172] If they correspond, 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.

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

[0174] In an optional embodiment of the present invention, during 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 step of establishing a connection status item based on the request includes:

[0175] A first connection status entry is established based on the first source Internet Protocol address and the first target Internet Protocol address;

[0176] Use the first source Internet Protocol address as the second target Internet Protocol address, and use the first target Internet Protocol address as the second source Internet Protocol address;

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

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

[0179] Based on the source Internet Protocol address and the destination Internet Protocol address of the response, determine whether the response corresponds to the second connection status 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; the method includes:

[0183] Based on the current time and the aging time, the backend traffic direction finder determines whether the first connection status item is invalid.

[0184] When the backend traffic directional device intercepts a request to be processed, it uses the source Internet Protocol address, destination Internet Protocol address, the first source Internet Protocol address, and the first destination Internet Protocol address of the request to be processed to determine whether the request to be processed and the request contain the same data packets.

[0185] If the pending request and the request contain the same data packets, then the aging time of the first connection status item is updated using the backend traffic director.

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

[0187] If the pending request and the request contain the same data packets, then the backend traffic direction finder is used to determine whether the pending request contains a termination flag;

[0188] If the pending request includes the termination flag, then the first connection status item is set to an invalid state using the backend traffic director.

[0189] In an optional embodiment of the present invention, the backend traffic director is a network interface 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. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

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

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

[0193] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0194] like Figure 6 As shown, in another embodiment of the present invention, a computer-readable storage medium 601 is also provided, which stores instructions that, when executed on a computer, cause the computer to perform a request processing method for a load balancer as described in the above embodiment.

[0195] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute a request processing method for a load balancer as described in the above embodiments.

[0196] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as 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, all or part of the processes or functions described in the embodiments of the present invention are generated. 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. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. 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 integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0197] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0198] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0199] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A request processing method for a load balancer, characterized in that, The method includes: The system uses a preset load balancer to receive requests sent by a preset client and configures a preset media access control address for the load balancer. The load balancer forwards 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. During the process of the request being forwarded to the backend server, the backend traffic director intercepts the request and establishes a connection state entry based on the request; The backend traffic redirector is used to send the request to the backend server and to intercept the response sent by the backend server in response to the request. The backend traffic director is used to determine whether the response corresponds to the connection status item; If they correspond, 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 response is sent to the client using the load balancer.

2. The method according to claim 1, characterized in that, During 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 establishment of a connection status item based on the request includes: A first connection status entry is established based on the first source Internet Protocol address and the first target Internet Protocol address; Use the first source Internet Protocol address as the second target Internet Protocol address, and use the first target Internet Protocol address as the second source Internet Protocol address; A second connection status entry is established based on the second source Internet Protocol address and the second destination Internet Protocol address.

3. The method according to claim 2, characterized in that, The step of determining whether the response corresponds to the connection status item includes: Based on the source Internet Protocol address and the destination Internet Protocol address of the response, determine whether the response corresponds to the second connection status item.

4. The method according to claim 3, characterized in that, The method includes: 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; the method includes: Based on the current time and the aging time, the backend traffic direction finder determines whether the first connection status item is invalid. When the backend traffic directional device intercepts a request to be processed, it uses the source Internet Protocol address, destination Internet Protocol address, the first source Internet Protocol address, and the first destination Internet Protocol address of the request to be processed to determine whether the request to be processed and the request contain the same data packets. If the pending request and the request contain the same data packets, then the aging time of the first connection status item is updated using the backend traffic director.

6. The method according to claim 5, characterized in that, The method includes: If the pending request and the request contain the same data packets, then the backend traffic direction finder is used to determine whether the pending request contains a termination flag; If the pending request includes the termination flag, then the first connection status item is set to 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 extension packet filter program.

8. A request processing apparatus for a load balancer, characterized in that, The device includes: The request receiving module is used to receive requests sent by a preset client using a preset load balancer, and to configure a preset media access control address for the load balancer. A request forwarding module 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; The request interception module is used to intercept the request using the backend traffic director during the process of the request being forwarded to the backend server, and to establish a connection status item based on the request; The response interception module is used to send the request to the backend server using the backend traffic redirector, and to intercept the response sent by the backend server in response to the request. The judgment module is used to determine whether the response corresponds to the connection status item using the backend traffic orienter; The address modification module is used to modify the target address of the response to the media access control address using the backend traffic director if there is a correspondence, and then send the response to the load balancer. The first response sending module is used to send the response to the client 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; When the processor executes a program stored in the memory, it implements the method as described in any one of claims 1-7.

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

Citation Information

Patent Citations

  • Load balancing method and device thereof

    CN108449282A

  • Direct addressability and direct server return

    US20110225231A1