Load balancing methods, apparatus, computer equipment, and readable storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2026-08-14
AI Technical Summary
[0003]传统技术中,在进行负载均衡处理时,一般是通过额外增加硬件负载均衡设备,并利用硬件负载均衡设备,来实现数据中心内部负载均衡;但是,硬件负载均衡设备的成本较高,导致负载均衡实现成本较高
[0048]上述负载均衡方法、装置、计算机设备、计算机可读存储介质和计算机程序产品,通过交换机接收不同客户端发送的数据流,并获取每个客户端的数据流的五元组信息,接着根据每个客户端的数据流的五元组信息,确定每个客户端的数据流对应的目标负载均衡服务器,并将每个客户端的数据流转发至对应的目标负载均衡服务器;每个目标负载均衡服务器先确定接收到的数据流对应的目标应用服务器,再将接收到的数据流转发至对应的目标应用服务器进行处理。这样,在交换机和负载均衡服务器组成的网络架构下,通过交换机将每个客户端的数据流转发至对应的目标负载均衡服务器,以及通过每个目标负载均衡服务器将接收到的数据流转发至对应的目标应用服务器进行处理,即可实现数据流的负载均衡,无需额外增加硬件负载均衡设备,从而降低了负载均衡实现成本。
Smart Images

Figure CN119544714B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a load balancing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology
[0002] With the development of mobile internet, data center traffic has experienced explosive growth, and data centers are generally high-concurrency business scenarios, so load balancing is required within them.
[0003] In traditional technologies, load balancing is typically achieved by adding additional hardware load balancing equipment to balance the load within the data center. However, the high cost of hardware load balancing equipment leads to a high overall cost for load balancing implementation. Summary of the Invention
[0004] Therefore, it is necessary to provide a load balancing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can reduce the cost of implementing load balancing, in order to address the above-mentioned technical problems.
[0005] Firstly, this application provides a load balancing method applied to a switch, including:
[0006] Receive data streams sent by different clients;
[0007] Obtain the 5-tuple information of the data stream for each client;
[0008] Based on the five-tuple information of the data stream of each client, determine the target load balancing server corresponding to the data stream of each client;
[0009] The data stream from each client is forwarded to the corresponding target load balancer server; each target load balancer server is used to determine the target application server corresponding to the received data stream and forward the received data stream to the corresponding target application server for processing.
[0010] In one embodiment, determining the target load balancing server corresponding to the data stream of each client based on the five-tuple information of the data stream of each client includes:
[0011] Calculate the hash value of the data stream for each client based on the 5-tuple information of the data stream for each client;
[0012] From the list of load balancing servers, select the load balancing server associated with the hash value of the data stream of each client, and use it as the target load balancing server for the data stream of each client.
[0013] In one embodiment, the step of selecting the load balancing server associated with the hash value of each client's data stream from the list of load balancing servers, as the target load balancing server corresponding to each client's data stream, includes:
[0014] If the number of clients is detected to be greater than the number of load balancing servers in the load balancing server list, obtain the expanded load balancing server list.
[0015] From the expanded list of load balancing servers, select the load balancing server associated with the hash value of each client's data stream, and use it as the target load balancing server for each client's data stream.
[0016] In one embodiment, the method further includes:
[0017] If a communication failure is detected between the switch and the target load balancing server corresponding to the data flow of the target client, the target load balancing server corresponding to the data flow of the target client is re-determined; the target client is one of the different clients.
[0018] The data stream from the target client is forwarded to the newly identified target load balancer server.
[0019] In one embodiment, the step of re-determining the target load balancer server corresponding to the data stream of the target client includes:
[0020] Remove the target load balancer corresponding to the data stream of the target client from the load balancer list to obtain the updated load balancer list.
[0021] From the updated list of load balancing servers, select the load balancing server associated with the hash value of the target client's data stream, and use it as the newly determined target load balancing server.
[0022] In one embodiment, forwarding the data stream of each client to the corresponding target load balancer server includes:
[0023] The data stream from each client is forwarded to the corresponding target load balancer server. Each target load balancer server uses a pre-trained neural network model to determine the target application server corresponding to the received data stream and forwards the received data stream to the corresponding target application server for processing through the corresponding current gateway. If the current gateway fails, the received data stream is forwarded to the corresponding target application server for processing through the equivalent gateway of the current gateway.
[0024] In one embodiment, the load balancing server list corresponding to the switch includes multiple load balancing servers. The multiple load balancing servers are used to publish the same public IP address to the de-stacked switch. There are multiple equal-cost routes between the switch and the multiple load balancing servers.
[0025] The step of determining the target load balancing server corresponding to the data stream of each client based on the five-tuple information of the data stream of each client includes:
[0026] For each client's data flow, based on the border gateway protocol routing principle and the five-tuple information of each client's data flow, a target route is selected from the multiple equal-cost routes existing between the switch and the multiple load balancing servers;
[0027] The load balancing server associated with the target route selected for the data flow of each client is taken as the target load balancing server for the data flow of each client.
[0028] Secondly, this application also provides a load balancing device, comprising:
[0029] The data receiving module is used to receive data streams sent by different clients;
[0030] The information acquisition module is used to acquire the five-tuple information of the data stream from each client;
[0031] The device determination module is used to determine the target load balancing server corresponding to the data stream of each client based on the five-tuple information of the data stream of each client;
[0032] The data forwarding module is used to forward the data stream of each client to the corresponding target load balancer server; each target load balancer server is used to determine the target application server corresponding to the received data stream and forward the received data stream to the corresponding target application server for processing.
[0033] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0034] Receive data streams sent by different clients;
[0035] Obtain the 5-tuple information of the data stream for each client;
[0036] Based on the five-tuple information of the data stream of each client, determine the target load balancing server corresponding to the data stream of each client;
[0037] The data stream from each client is forwarded to the corresponding target load balancer server; each target load balancer server is used to determine the target application server corresponding to the received data stream and forward the received data stream to the corresponding target application server for processing.
[0038] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0039] Receive data streams sent by different clients;
[0040] Obtain the 5-tuple information of the data stream for each client;
[0041] Based on the five-tuple information of the data stream of each client, determine the target load balancing server corresponding to the data stream of each client;
[0042] The data stream from each client is forwarded to the corresponding target load balancer server; each target load balancer server is used to determine the target application server corresponding to the received data stream and forward the received data stream to the corresponding target application server for processing.
[0043] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0044] Receive data streams sent by different clients;
[0045] Obtain the 5-tuple information of the data stream for each client;
[0046] Based on the five-tuple information of the data stream of each client, determine the target load balancing server corresponding to the data stream of each client;
[0047] The data stream from each client is forwarded to the corresponding target load balancer server; each target load balancer server is used to determine the target application server corresponding to the received data stream and forward the received data stream to the corresponding target application server for processing.
[0048] The aforementioned load balancing method, apparatus, computer equipment, computer-readable storage medium, and computer program product receive data streams from different clients via a switch, obtain the five-tuple information of each client's data stream, then determine the target load balancing server corresponding to each client's data stream based on the five-tuple information, and forward each client's data stream to the corresponding target load balancing server. Each target load balancing server first determines the target application server corresponding to the received data stream, and then forwards the received data stream to the corresponding target application server for processing. Thus, in a network architecture composed of switches and load balancing servers, load balancing of data streams can be achieved by forwarding each client's data stream to the corresponding target load balancing server via the switch, and by forwarding the received data stream to the corresponding target application server via each target load balancing server, without the need for additional hardware load balancing equipment, thereby reducing the cost of load balancing implementation. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1 This is a diagram illustrating the application environment of a load balancing method in one embodiment.
[0051] Figure 2 This is a flowchart illustrating a load balancing method in one embodiment;
[0052] Figure 3 This is a flowchart illustrating the steps for determining the target load balancing server corresponding to the data stream of each client in one embodiment.
[0053] Figure 4 This is a flowchart illustrating the load balancing method in another embodiment;
[0054] Figure 5 This is a schematic diagram of a switch stacking architecture in one embodiment;
[0055] Figure 6This is a schematic diagram of a switch destabilization architecture in one embodiment;
[0056] Figure 7 This is a schematic diagram of downlink traffic load balancing in one embodiment;
[0057] Figure 8 This is a schematic diagram of uplink traffic load balancing in one embodiment;
[0058] Figure 9 This is a structural block diagram of a load balancing device in one embodiment;
[0059] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0061] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0062] With the development of mobile internet, especially the widespread adoption of short video applications, traditional IDCs (Internet Data Centers) are facing the challenge of explosive growth in north-south traffic. Correspondingly, this surge in north-south traffic has also introduced issues such as a sudden increase in east-west traffic within the IDC and data persistence. High traffic volume, high concurrency, massive data storage, and frequent access are severe challenges facing internet companies in this new environment, and the 24 / 7 continuity of service further complicates these challenges. To address these challenges, most internet companies adopt a distributed architecture, splitting and deploying business processes across a sufficient number of servers. This distributed architecture distributes requests and concurrency across multiple points, achieving multi-point redundancy and backup. Since a unified entry point is required for business operations, in the aforementioned distributed business deployment scenario, load balancing equipment needs to be added in front of the business cluster to provide a unified entry point to external users and distribute business requests to backend servers internally.
[0063] Load balancing within data centers is typically implemented using hardware load balancing devices or load balancing software (LVS, Nginx, HAProxy). Hardware load balancing is simple and offers good forwarding performance, but it suffers from high construction costs and poor scalability, limiting its use in large-scale clusters. Common software load balancing methods suffer from low forwarding performance, single points of failure, and poor horizontal scalability. While GSLB (Global Server Load Balancer) combined with software load balancing can address single points of failure, it suffers from GSLB scheduling and control latency, slow DNS (Domain Name System) cache updates during failures, poor load balancing server scalability, and the continued existence of logical single points of failure in stacked uplink switches. Currently, there is a lack of a load balancing technology that offers high reliability for both servers and network devices, a simple network architecture, efficient forwarding, and flexible horizontal scalability. Therefore, this application proposes a novel load balancing method.
[0064] The load balancing method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, switch 101 communicates with load balancer 102 via a network, and load balancer 102 communicates with application server 103 via a network. There are multiple switches 101, load balancer 102, and application servers 103. Specifically, refer to... Figure 1 For a single switch, switch 101 receives data streams sent by different clients and obtains the five-tuple information of each client's data stream. Based on this information, it determines the target load balancer 102 corresponding to each client's data stream and forwards it to the corresponding target load balancer 102. Each target load balancer 102 determines the target application server 103 corresponding to the received data stream and forwards it to that server for processing. Here, switch 101 refers to the device that performs information exchange in the communication system; load balancer 102 refers to the server that implements load balancing; and application server 103 refers to the server that processes the data streams sent by clients. Load balancer 102 and application server 103 can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing cloud computing services.
[0065] In addition, to more clearly illustrate the load balancing method provided in the embodiments of this application, the following are explanations of some terms:
[0066] Switch stacking: Connecting multiple switches that support stacking features together with stacking cables, logically virtualizing them into a single switching device, and having them participate in data forwarding as a whole.
[0067] BGP (Border Gateway Protocol): A routing protocol that runs between autonomous systems and is primarily responsible for switching routes between domains.
[0068] iBGP (Internel BGP): Internal Border Gateway Protocol. If two routers are located in the same Autonomous System (AS), their neighbor relationship is an iBGP neighbor relationship.
[0069] eBGP: External Border Gateway Protocol. If two routers are located in different Autonomous Systems (AS), their neighbor relationship is an eBGP neighbor relationship.
[0070] IGP (Interior Gateway Protocol): The main function of an interior gateway protocol is to discover and calculate routing information within an autonomous system, including RIP, OSPF, IS-IS, IGRP, etc.
[0071] In one exemplary embodiment, such as Figure 2 As shown, a load balancing method is provided, which can be applied to... Figure 1 Taking the switch in the example, the explanation includes the following steps S201 to S204. Wherein:
[0072] Step S201: Receive data streams sent by different clients.
[0073] Here, "client" can refer to any type of client, such as the business side.
[0074] The data stream sent by the client refers to the data stream that the client requests the application server to process, specifically the data stream within the same client session, such as the business data stream.
[0075] Each switch can receive data streams from multiple clients. IGP protocols exist between different switches, and the data streams received by different switches are balanced.
[0076] For example, when a client sends a data stream to an application server, it first sends the data stream to the corresponding switch; the switch can receive data streams sent by different clients.
[0077] Step S202: Obtain the quintuple information of the data stream for each client.
[0078] The 5-tuple information refers to the source IP (Internet Protocol) address, destination IP address, source port number, destination port number, and transport protocol.
[0079] In this case, the data streams of the same client session have the same 5-tuple information, meaning that data streams with the same 5-tuple information belong to the same session. This allows the data streams of the same client session to be consistently forwarded to the same load balancer server.
[0080] For example, the switch performs information extraction processing on the data stream of each client according to the five-tuple information extraction instruction to obtain the five-tuple information of the data stream of each client; or, the switch inputs the data stream of each client into a pre-trained information extraction model, and performs information extraction processing on the data stream of each client through the information extraction model to obtain the five-tuple information of the data stream of each client.
[0081] Step S203: Determine the target load balancing server corresponding to the data stream of each client based on the five-tuple information of the data stream of each client.
[0082] In this configuration, data streams from the same client session are consistently sent to the same target load balancer server. This means the same session will use the same forwarding path, while different sessions will use different paths, thus achieving load balancing of downlink traffic between the switch and the load balancer server. It's important to note that for a single client session's data stream, load balancing is not performed across multiple paths. The switch, based on BGP, defaults to selecting the best route. Therefore, a prerequisite for achieving load balancing is that the switch is configured with BGP load balancing.
[0083] Each client's data stream corresponds to the same target load balancer server. The specific target load balancer server selected is determined based on the five-tuple information of each client's data stream.
[0084] It should be noted that different load balancers advertise the same v-IP (i.e., public IP address, the IP address that provides services to users) to the outside world (such as different switches); there are multiple switches, and for each switch, there are multiple equal-cost routes between the switch and multiple load balancers; for a single TCP (Transmission Control Protocol) connection, it will be guaranteed to be sent to the same load balancer to ensure session continuity.
[0085] For example, the switch selects the load balancing server associated with the five-tuple information of each client's data flow from the list of load balancing servers based on the five-tuple information of each client's data flow, and uses it as the target load balancing server for each client's data flow.
[0086] For example, the switch uses a consistent hashing algorithm to determine the target load balancer for each client's data stream based on the five-tuple information of each client's data stream.
[0087] Step S204: Forward the data stream of each client to the corresponding target load balancer server; each target load balancer server is used to determine the target application server corresponding to the received data stream and forward the received data stream to the corresponding target application server for processing.
[0088] In this scenario, the data stream of the same session from the client is always sent to the same target application server. That is, the data streams from different clients will be processed by different target application servers, thereby achieving load balancing of the uplink traffic between the load balancer and the application server.
[0089] The target application server corresponding to each client's data stream is determined based on the Layer 4 / Layer 7 load balancing software (such as nginx, haproxy, etc.) of the target load balancing server that receives the client's data stream.
[0090] It should be noted that in the network architecture consisting of switches, load balancers, and application servers, each of these components can be expanded individually as needed. For example, if the number of ports or bandwidth of a switch is insufficient, switches can be expanded horizontally without any limit on the number. The newly added switches must be able to communicate with each load balancer. If the performance of a load balancer is insufficient, a separate load balancer can be added, and the new load balancer must be able to communicate with both the switches and the application servers. Similarly, if the performance of an application server is insufficient, a separate application server can be added, and the new application server must be able to communicate with the load balancer.
[0091] For example, the switch forwards the data stream from each client to the corresponding target load balancer server. After receiving the data stream from the client, each target load balancer server determines the target application server corresponding to the received data stream through its built-in Layer 4 / Layer 7 load balancing software, or by querying the correspondence between the data stream and the application server. Then, each target load balancer server forwards the received data stream to the corresponding target application server, which processes the received data stream and returns the processing result to the corresponding client.
[0092] For example, see reference. Figure 1 After receiving a client request, how does the switch forward the data stream to the load balancer? From the load balancer's perspective, this can be called downlink traffic. The load balancer is deployed with Layer 4 / Layer 7 load balancing software; here, we take a Layer 7 load balancer as an example. As the access point for HTTP / HTTPS services, it establishes a connection with the client and then forwards the request to the application server for processing. The traffic from the load balancer to the application server, from the load balancer's perspective, can be called uplink traffic. The load balancer and application server are often not on the same switch, but they are network reachable. The Layer 7 load balancing software supports various load balancing algorithms such as round-robin, consistent hashing, least connections, and weighted algorithms. The Layer 7 load balancing algorithm of the load balancer determines which application server to forward the data to. The data packets from the load balancer may be forwarded through multiple network devices before finally reaching the application server. Different business scenarios result in different network architectures; this application does not impose restrictions on this, focusing only on high availability and load balancing of the Layer 3 network from the load balancer to the switch. This application focuses on proposing a method for load balancing between a load balancing server and switches to achieve downlink traffic (i.e., north-south traffic in the data center) and uplink traffic (i.e., east-west traffic in the data center) after the switches are de-stacked.
[0093] In the above load balancing method, a switch receives data streams from different clients and obtains the five-tuple information of each client's data stream. Then, based on this information, the target load balancing server corresponding to each client's data stream is determined, and the data stream is forwarded to the corresponding target load balancing server. Each target load balancing server first determines the target application server corresponding to the received data stream and then forwards the received data stream to the corresponding target application server for processing. Thus, in a network architecture composed of switches and load balancing servers, load balancing of data streams is achieved by forwarding each client's data stream to the corresponding target load balancing server through the switch, and by forwarding the received data stream to the corresponding target application server through each target load balancing server. This eliminates the need for additional hardware load balancing equipment, thereby reducing the cost of implementing load balancing.
[0094] In one exemplary embodiment, such as Figure 3 As shown, step S203 above, which determines the target load balancing server corresponding to each client's data stream based on the five-tuple information of each client's data stream, includes the following steps S301 to S302. Wherein:
[0095] Step S301: Calculate the hash value of each client's data stream based on the quintuple information of each client's data stream.
[0096] Step S302: From the list of load balancing servers, select the load balancing server associated with the hash value of each client's data stream, and use it as the target load balancing server for each client's data stream.
[0097] The hash value of each client's data stream is calculated using a consistent hashing algorithm.
[0098] The list of load balancing servers includes several load balancing servers to choose from.
[0099] The load balancing server associated with the hash value of each client's data stream refers to the load balancing server that matches the hash value of each client's data stream.
[0100] It's important to note that typical hash load balancing algorithms achieve load balancing by taking the modulo between the data flow's five-tuple information and the number of reachable paths in the equal-cost route. This algorithm ensures that packets from the same session are forwarded to the same load balancer server. However, a downside is that if one path fails, the number of reachable paths decreases, changing the modulo result. This affects packets on all paths; packets on normally functioning paths will be recalculated, forwarded to a new load balancer, and then sent to a new application server for processing. If the service involves persistent, stateful connections (i.e., sessions), this can lead to the interruption of all sessions, including those on normally functioning paths. This application employs a consistent hashing algorithm, which guarantees that if a path fails, data packets from the failed path will only be re-forwarded to a new path and handled by a new load balancer (for example, if switch 1 originally forwards client 1's data stream to load balancer 1, and a communication failure occurs between switch 1 and load balancer 1, switch 1 will re-forward client 1's data stream to a new load balancer, such as load balancer 2). However, data packets from other normal paths will not be affected; only sessions on the failed path will be affected. This minimizes the impact of the failure. Applications typically have a retry mechanism, and data packets for re-establishing sessions will be scheduled to the new normal path, so the business will not be significantly affected.
[0101] It should be noted that when the consistent hashing algorithm is introduced, for a single switch, the target load balancer server corresponding to the data flow of each client is different.
[0102] For example, the switch calculates the hash value of each client's data stream based on the five-tuple information of each client's data stream using a consistent hashing algorithm; then, it selects the load balancing server associated with the hash value of each client's data stream from the load balancing server list, and uses it as the target load balancing server for each client's data stream; for example, it selects the load balancing server corresponding to the load balancing server identifier associated with the hash value of each client's data stream from the load balancing server list, and uses it as the target load balancing server for each client's data stream.
[0103] For example, when the hash value of each load balancer is mapped to a hash ring, the switch calculates the hash value of the client's data stream and determines the specific position of the client's data stream hash value on the hash ring. Then, starting from that position, it searches clockwise along the hash ring, and the first load balancer encountered is the target load balancer corresponding to the client's data stream. In this way, the target load balancer corresponding to each client's data stream can be determined.
[0104] In this embodiment, the switch determines the target load balancing server corresponding to each client's data stream based on the five-tuple information of each client's data stream. This helps to achieve load balancing of downlink traffic between the switch and the load balancing server without adding additional hardware load balancing equipment, thereby reducing the cost of implementing load balancing.
[0105] In an exemplary embodiment, step S302, which involves selecting the load balancing server associated with the hash value of each client's data stream from the load balancing server list as the target load balancing server for each client's data stream, specifically includes the following: if the number of clients is detected to be greater than the number of load balancing servers in the load balancing server list, obtaining an expanded load balancing server list; and selecting the load balancing server associated with the hash value of each client's data stream from the expanded load balancing server list as the target load balancing server for each client's data stream.
[0106] The expanded list of load balancers includes both the original load balancers and the expanded load balancers.
[0107] For example, if the number of clients is detected to be greater than the number of load balancing servers in the load balancing server list, the switch can request to expand the load balancing server list and filter out the load balancing server associated with the hash value of each client's data stream from the expanded load balancing server list, as the target load balancing server for each client's data stream; for example, from the expanded load balancing server list, filter out the load balancing server corresponding to the load balancing server identifier associated with the hash value of each client's data stream, as the target load balancing server for each client's data stream.
[0108] In this embodiment, when the number of clients is detected to be greater than the number of load balancing servers in the load balancing server list, the target load balancing server corresponding to the data flow of each client is determined from the expanded load balancing server list. This helps to further ensure the load balancing effect of the downlink traffic between the switch and the load balancing server, and avoids the defect of insufficient load balancing servers leading to excessive load on the load balancing server.
[0109] In an exemplary embodiment, the load balancing method provided in this application further includes the following: when communication failure is detected between the switch and the target load balancing server corresponding to the data flow of the target client, the target load balancing server corresponding to the data flow of the target client is re-determined; the target client is one of different clients; and the data flow of the target client is forwarded to the re-determined target load balancing server.
[0110] In this application, only the target load balancing server corresponding to the data flow of the target client is re-determined, and the target load balancing server corresponding to the data flow of other clients is not re-determined.
[0111] In particular, the target load balancer server corresponding to the data flow of the target client is also determined based on the consistent hashing algorithm.
[0112] It should be noted that when a path failure occurs, the switch will not send the data to the original load balancer. The switch will assume that the original load balancer is malfunctioning (the switch does not know whether it is a network failure or a load balancer failure). The original load balancer (e.g., load balancer 1) will be removed, and the data packet will be forwarded to other normal load balancers (e.g., load balancer 2).
[0113] For example, the switch monitors the communication between itself and the target load balancer server corresponding to the data flow of each client in real time. If the switch detects a communication failure between itself and the target load balancer server corresponding to the data flow of the target client (i.e., a client among different clients), it redetermines the target load balancer server corresponding to the data flow of the target client based on the consistent hashing algorithm, and forwards the data flow of the target client to the redetermined target load balancer server.
[0114] In this embodiment, if a communication failure is detected between the switch and the target load balancer server corresponding to the data stream of the target client, the target load balancer server corresponding to the data stream of the target client is re-determined, and the data stream of the target client is forwarded to the re-determined target load balancer server. This can ensure the normal forwarding of the data streams of other clients, thereby minimizing the impact of the fault.
[0115] In an exemplary embodiment, the target load balancing server corresponding to the data flow of the target client is re-determined, which specifically includes the following: deleting the target load balancing server corresponding to the data flow of the target client from the load balancing server list to obtain an updated load balancing server list; and selecting the load balancing server associated with the hash value of the data flow of the target client from the updated load balancing server list as the re-determined target load balancing server.
[0116] The updated list of load balancing servers does not include the target load balancing server corresponding to the data flow of the target client.
[0117] In this way, removing the target load balancer corresponding to the data stream of the target client from the load balancer list can ensure that the re-determined target load balancer is not the same as the original target load balancer.
[0118] For example, the switch first removes the target load balancer corresponding to the data flow of the target client from the load balancer list to obtain an updated load balancer list. Then, based on the consistent hashing algorithm, it selects the load balancer corresponding to the load balancer identifier associated with the hash value of the data flow of the target client from the updated load balancer list, and uses it as the re-determined target load balancer.
[0119] In this embodiment, the target load balancing server corresponding to the data stream of the target client is deleted from the load balancing server list to obtain an updated load balancing server list. Then, the load balancing server associated with the hash value of the data stream of the target client is selected from the load balancing server list as the re-determined target load balancing server. This ensures that the re-determined target load balancing server is different from the original load balancing server, thereby ensuring that the data stream of the target client can be forwarded and processed smoothly.
[0120] In an exemplary embodiment, step S204 above, forwarding the data stream of each client to the corresponding target load balancer server, specifically includes the following: forwarding the data stream of each client to the corresponding target load balancer server, so that each target load balancer server determines the target application server corresponding to the received data stream through a pre-trained neural network model, and forwards the received data stream to the corresponding target application server for processing through the corresponding current gateway; in the event of a failure of the current gateway, the received data stream is forwarded to the corresponding target application server for processing through the equivalent gateway of the current gateway.
[0121] Each target load balancing service determines the target application server corresponding to the received data stream based on its deployed Layer 4 / Layer 7 load balancing software (such as nginx, haproxy, etc.).
[0122] The pre-trained neural network model is a neural network model used to determine the target application server corresponding to the received data stream, and it is obtained through iterative training.
[0123] In this context, each target load balancer server is connected to its corresponding target application server through multiple equivalent gateways. For example, refer to... Figure 8 Gateway 1 and Gateway 3 are equivalent, and Gateway 2 and Gateway 4 are equivalent. An equivalent gateway is a load balancer that implements the first-hop path of the uplink traffic from the load balancer server to the application server, that is, load balancing of the uplink traffic from the load balancer server to the application server.
[0124] Here, the current gateway refers to the gateway currently used by the target load balancer server; the equivalent gateway of the current gateway refers to the gateway that is equivalent to the current gateway.
[0125] For example, the switch forwards the data stream from each client to the corresponding target load balancer server. After receiving the data stream, each target load balancer server determines the target application server corresponding to the received data stream using a pre-trained neural network model or internally deployed Layer 4 / Layer 7 load balancing software. For example, it determines the probability of each application server corresponding to the received data stream using a pre-trained neural network model and selects the application server with the highest probability as the target application server corresponding to the received data stream. Then, it forwards the received data stream to the corresponding target application server for processing through the corresponding current gateway (e.g., gateway 1). In the event of a failure of the current gateway, it determines the equivalent gateway of the current gateway (e.g., gateway 3) and forwards the received data stream to the corresponding target application server for processing through the equivalent gateway of the current gateway.
[0126] In this embodiment, each target load balancer server determines the target application server corresponding to the received data stream and forwards the received data stream to the corresponding target application server for processing through the corresponding current gateway. This facilitates load balancing of uplink traffic between the load balancer server and the application server without adding additional hardware load balancing equipment, thereby reducing the cost of load balancing implementation. Furthermore, in the event of a current gateway failure, forwarding the received data stream to the corresponding target application server through the equivalent gateway of the current gateway ensures smooth forwarding and processing of the data stream.
[0127] In one embodiment, the load balancing server list corresponding to the switch includes multiple load balancing servers. These multiple load balancing servers are used to advertise the same public IP address to the de-stacked switch, and there are multiple equal-cost routes between the switch and the multiple load balancing servers. Therefore, step S203, which determines the target load balancing server corresponding to each client's data flow based on the five-tuple information of each client's data flow, specifically includes the following: For each client's data flow, based on the border gateway protocol routing principles and the five-tuple information of each client's data flow, a target route is selected from the multiple equal-cost routes between the switch and the multiple load balancing servers; the load balancing server associated with the target route selected for each client's data flow is then used as the target load balancing server corresponding to each client's data flow.
[0128] Among them, reference Figure 6 Different switches are not stacked.
[0129] Each switch has a corresponding list of load balancing servers, which includes multiple load balancing servers to choose from.
[0130] In this context, a public IP address (i.e., a VPN) refers to the IP address used to provide services to customers. Different load balancer servers advertise the same public IP address to the de-stacked switches.
[0131] The phrase "multiple equal-cost routes exist between the switch and multiple load balancers" refers to the existence of multiple equal-cost paths between the switch and multiple load balancers. See [link / reference] for details. Figure 6 As indicated by the arrows; for example, the paths from switch 1 to load balancer 1, from switch 1 to load balancer 2, and from switch 1 to load balancer 3 are equivalent; the paths from switch 2 to load balancer 1, from switch 2 to load balancer 2, and from switch 2 to load balancer 3 are equivalent.
[0132] Among them, the Border Gateway Protocol routing principle refers to the BGP routing principle, which is used to select the best route by default, thereby achieving load balancing.
[0133] For a single switch, a destination route needs to be selected for each client's data flow. The destination route refers to the best route selected based on the routing principles of the Border Gateway Protocol. For example, for the data flow between switch 1 and client 1, the path from switch 1 to load balancer 1, the path from switch 1 to load balancer 2, and the path from switch 1 to load balancer 3 is selected as the best route for client 1's data flow.
[0134] The load balancing server associated with the target route selected for a client's data flow refers to the load balancing server involved in the target route selected for that client's data flow. For example, if the target route for client 1's data flow is the path from switch 1 to load balancing server 1, then the load balancing server associated with the target route is load balancing server 1.
[0135] For example, for each client's data flow, the switch selects the best route from multiple equal-cost routes between the switch and multiple load balancers based on the border gateway protocol routing principles and the five-tuple information of each client's data flow. This best route is then selected as the target route for each client's data flow. Next, the load balancer associated with the target route selected for each client's data flow is identified, and this load balancer is designated as the target load balancer for each client's data flow. Finally, each client's data flow is forwarded to the corresponding target load balancer via the selected target route.
[0136] For example, regarding switch 1, switch 1 receives data streams from client 1, client 2, and client 3. The paths from switch 1 to load balancer 1, to load balancer 2, to load balancer 3, to load balancer 4, and to load balancer 5 are equivalent. Then, based on BGP routing principles and the five-tuple information of client 1's, client 2's, and client 3's data streams, switch 1 selects the target route for client 1's data stream (e.g., the path from switch 1 to load balancer 1), client 2's data stream (e.g., the path from switch 1 to load balancer 2), and client 3's data stream (e.g., the path from switch 1 to load balancer 5) from these paths. The path from client 1 to load balancer 3 is selected. Then, switch 1 uses the load balancer involved in the target route corresponding to client 1's data flow (such as load balancer 1) as the target load balancer for client 1's data flow; the load balancer involved in the target route corresponding to client 2's data flow (such as load balancer 2) is selected as the target load balancer for client 2's data flow; the load balancer involved in the target route corresponding to client 3's data flow (such as load balancer 3) is selected as the target load balancer for client 3's data flow; finally, switch 1 forwards client 1's data flow to load balancer 1 through the corresponding selected target route (such as the path from switch 1 to load balancer 1); forwards client 2's data flow to load balancer 2 through the corresponding selected target route (such as the path from switch 1 to load balancer 2); and forwards client 3's data flow to load balancer 1 through the corresponding selected target route (such as the path from switch 1 to load balancer 3).
[0137] In this embodiment, for each client's data flow, a target route is selected from multiple equal-cost routes between the switch and multiple load balancing servers based on the border gateway protocol routing principle and the five-tuple information of each client's data flow. The load balancing server associated with the target route selected for each client's data flow is then used as the target load balancing server for each client's data flow. This helps to achieve load balancing of downlink traffic between the switch and the load balancing server without adding additional hardware load balancing equipment, thereby reducing the cost of implementing load balancing.
[0138] In one exemplary embodiment, such as Figure 4 As shown, another load balancing method is provided. Taking the application of this method to a switch as an example, the method includes the following steps S401 to S407. Wherein:
[0139] Step S401: Receive data streams sent by different clients.
[0140] Step S402: Obtain the quintuple information of the data stream for each client.
[0141] Step S403: Calculate the hash value of each client's data stream based on the 5-tuple information of each client's data stream.
[0142] Step S404: From the list of load balancing servers, select the load balancing server associated with the hash value of each client's data stream, and use it as the target load balancing server for each client's data stream.
[0143] The list of load balancing servers corresponding to the switch includes multiple load balancing servers. These multiple load balancing servers are used to publish the same public IP address to the de-stacked switches, and there are multiple equal-cost routes between the switches and the multiple load balancing servers.
[0144] Specifically, for each client's data flow, the switch selects a target route from multiple equal-cost routes between the switch and multiple load balancers based on the border gateway protocol routing principles and the five-tuple information of each client's data flow. The load balancer associated with the target route selected for each client's data flow is then used as the target load balancer for each client's data flow.
[0145] Step S405: Forward the data stream of each client to the corresponding target load balancer server.
[0146] Each target load balancer uses a pre-trained neural network model to determine the target application server corresponding to the received data stream, and forwards the received data stream to the corresponding target application server for processing through the corresponding current gateway. In the event of a failure of the current gateway, the received data stream is forwarded to the corresponding target application server for processing through the equivalent gateway of the current gateway.
[0147] Step S406: If communication failure is detected between the switch and the target load balancing server corresponding to the data flow of the target client, the target load balancing server corresponding to the data flow of the target client is re-determined; the target client is one of the different clients.
[0148] Step S407: Forward the data stream of the target client to the re-determined target load balancer server, so that the re-determined target load balancer server forwards the data stream of the target client to the corresponding target application server.
[0149] In the above load balancing method, under the network architecture composed of switches and load balancing servers, the data flow of each client is forwarded to the corresponding target load balancing server by the switch, and the received data flow is forwarded to the corresponding target application server for processing by each target load balancing server. This can achieve load balancing of the data flow without the need to add additional hardware load balancing equipment, thereby reducing the cost of load balancing implementation.
[0150] To more clearly illustrate the load balancing method provided in this application's embodiments, a specific embodiment is used to describe the load balancing method in detail below. In an exemplary embodiment, this application also proposes a high-performance, highly available load balancing implementation method (i.e., a load balancing implementation method under a highly available and easily scalable architecture within a data center). Specifically, it designs a traffic scheduling method that eliminates single points of failure, possesses high reliability, flexible scalability, and high forwarding efficiency, and can meet the needs of high-concurrency, high-traffic usage scenarios. The specific details are as follows:
[0151] Large-scale clusters within data centers typically employ software load balancing and link bonding. Two physical switches are merged and stacked into a single logical switch, which is then connected to a load balancing server / cluster. This server deploys load balancing software and performs link bonding uplink to the connected switch to achieve high availability and efficient traffic distribution. A specific network topology is shown below. Figure 5 As shown in the diagram, in this network topology, services rely entirely on stacked switches, which are opaque to the outside world and have a single logical point of failure. On the one hand, stacking is a "black box" technology from the equipment vendor, with a closed development environment, making it difficult for outsiders to make constructive improvements. On the other hand, although a stacked switch consists of two physical switches, it remains a single logical point of failure, and stacking does not support smooth upgrades. When there are upgrade changes or stack failures, all devices under the switch are disconnected from the network, severely impacting service continuity and availability. Regarding servers, load balancing servers / clusters typically use GSLB (Global Load Balancing) with globally scalable traffic to address the issues of a unified service entry point and high availability. However, this approach suffers from problems such as scheduling control latency, slow DNS cache updates during failures, complex networking, and high costs.
[0152] To address the shortcomings of the aforementioned load balancing methods, refer to Figure 6 This application proposes a novel load balancing implementation method for a high-availability architecture: a spine-leaf + virtual-IP architecture. (See reference...) Figure 6 (The application cluster server module is logically connected). The basic network architecture consists of two de-stacked switches (Spine) and a load balancer / cluster (Leaf). IGP (Interior Gateway Protocol) and iBGP (Interior Border Gateway Protocol) run between the spines, while EBGP (Exterior Border Gateway Protocol) and BFD (Bidirectional Forwarding Detection) run between the spines and leaves, enabling routing interoperability and fast convergence between different types of servers. The load balancer / cluster serves as a unified service entry point, deploying a virtual IP and a Layer 7 software load balancing process to provide external services. It establishes a BGP peer with the spine through an open-source routing daemon and uses ECMP (Equal-cost multi-path) to publish equivalent v-IPs (the same public IP address) to the spine. This architecture allows for standardized horizontal scaling through different POD modules (such as switch groups, load balancers, and application cluster servers).
[0153] The Spine network uses IGP+iBGP protocols to meet the communication needs of servers in different network segments. EBGP and BFD protocols run between Spine and the load balancer / cluster. BGP, as the external gateway protocol, selects the optimal route by default and adds it to the routing table to guide data forwarding. In this method, BGP load balancing is enabled on the Spine. After meeting the LB (load balancing) conditions in the BGP routing protocol's routing principles, a multi-hop equivalent route exists to the same destination v-IP, achieving the goal of load balancing traffic (e.g., ...). Figure 6 (As indicated by the arrow). The BGP protocol used by Spine and load balancer servers / clusters is local and does not introduce other routing information, avoiding the need for load balancer servers / clusters to maintain unnecessary routing tables. It also isolates fault domains and prevents network failures from causing route convergence. EBGP, in conjunction with the BFD protocol, can quickly detect and discover faults, solving the problem of the time-consuming fault detection mechanism of the BGP protocol itself.
[0154] In an ECMP scenario, data streams with identical 5-tuples belong to the same session. The hash algorithm selects all or several combinations of the data stream's 5-tuples as hash factors. After hash calculation, it selects the path that actually carries the data. Consistent 5-tuples within the same session ensure that data packets from the same session are consistently forwarded to the same load balancer, guaranteeing business continuity. Figure 7As shown. However, when a path fails, all current traffic (all traffic between the switch and multiple load balancers) will be re-hashed and redistributed to the normal path. This may cause the original hashed path to change, and packets from the same session may be sent to different servers, resulting in timeouts and reconnections or even interruptions for services requiring session persistence. In this method, ECMP load balancing consistency is enabled on the Spine to avoid the above problems.
[0155] After resolving the load balancing issue for external request and response packets, it's also necessary to consider the load balancer's outgoing packet transmission and its internal communication with the application server. This involves setting the uplink interface IPs of the load balancer to different spines as the default equivalent-cost gateway address (i.e., the equivalent-cost default route, such as...). Figure 8 As shown in gateways 1-4 (i.e., gateway 1 is equivalent to gateway 3, and gateway 2 is equivalent to gateway 4), the server's physical network card IP address is only used for interconnection with the switch interface address. The access layer server communicates with other internal application servers by deploying independent internal communication IP addresses as addresses for communication with internal application servers, and publishes these IP addresses to the spine via EBGP. Through this method, the load balancer server achieves equivalent upstream data flow to different spines and internal communication with application servers.
[0156] In addition, the implementation steps of the high-performance, high-availability load balancing method are as follows:
[0157] Step 1: The switch receives data streams from different clients and, based on the TCP 5-tuple information, uses a consistent hashing algorithm to forward them to a fixed load balancer. The client then establishes a session with the load balancer. If communication between switch 1 and load balancer 1 fails, switch 1 will remove load balancer 1 from its forwarding list and reselect a load balancer using the consistent hashing algorithm. Changing the forwarding path only affects the session on the path from switch 1 to load balancer 1; other sessions remain unaffected.
[0158] Step 2: After receiving a client request, the load balancer server uses Layer 4 / Layer 7 load balancing software (such as nginx, hapoxy, etc.) to determine the target application server (i.e., the application server's IP address) to forward the request. Different client requests will be processed by different application servers, achieving load balancing. All data packets within the same session will be sent to the same application server.
[0159] Step 3: There are multiple forwarding paths between Load Balancer Server 1 and Application Server 1. The first hop of these paths is to the Spine switch, such as... Figure 8As shown, load balancer server 1 (i.e., the leaf server in the lower left corner) has two equivalent gateways: gateway 1 and gateway 3. If gateway 1 fails, data packets are forwarded to application server 1 by gateway 3. In this scenario, the application layer is unaware of the failure; it is simply a Layer 3 network failover. If application server 1 fails, causing network unreachability, user requests will be resent to other application servers by the load balancing software.
[0160] The above embodiments can achieve the following technical effects: (1) Using the spine-leaf+virtual-IP architecture and ECMP, data center load balancing can be achieved in scenarios with high traffic and high concurrency; (2) The problems of high cost, single point of failure and poor horizontal scalability of hardware load balancing equipment are solved; (3) The problems of scheduling control delay, slow DNS cache update during failure, increased network complexity and high cost in the existing software load balancing architecture are solved; (4) The single point of failure of the uplink switch in the switch stacking architecture is solved, avoiding the risk of service interruption during the upgrade of stacked switches, and having fault detection and automatic switching capabilities, with high reliability; (5) The performance advantages of switch hardware forwarding are fully utilized, and with the cooperation of Layer 7 load balancing software, a high-performance and flexible service scheduling load balancing service can be provided.
[0161] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0162] Based on the same inventive concept, this application also provides a load balancing device for implementing the load balancing method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more load balancing device embodiments provided below can be found in the limitations of the load balancing method described above, and will not be repeated here.
[0163] In one exemplary embodiment, such as Figure 9As shown, a load balancing device is provided for use in a switch, including: a data receiving module 910, an information acquisition module 920, a device determination module 930, and a data forwarding module 940, wherein:
[0164] The data receiving module 910 is used to receive data streams sent by different clients.
[0165] The information acquisition module 920 is used to acquire the five-tuple information of the data stream of each client.
[0166] The device determination module 930 is used to determine the target load balancing server corresponding to the data stream of each client based on the five-tuple information of the data stream of each client.
[0167] The data forwarding module 940 is used to forward the data stream of each client to the corresponding target load balancer server; each target load balancer server is used to determine the target application server corresponding to the received data stream and forward the received data stream to the corresponding target application server for processing.
[0168] In an exemplary embodiment, the device determination module 930 is further configured to calculate the hash value of each client's data stream based on the five-tuple information of each client's data stream; and to filter out the load balancing server associated with the hash value of each client's data stream from the load balancing server list, as the target load balancing server corresponding to each client's data stream.
[0169] In an exemplary embodiment, the device determination module 930 is further configured to, when the number of clients detected is greater than the number of load balancing servers in the load balancing server list, obtain an expanded load balancing server list of the load balancing server list; and from the expanded load balancing server list, filter out the load balancing server associated with the hash value of each client's data stream as the target load balancing server corresponding to each client's data stream.
[0170] In an exemplary embodiment, the load balancing device further includes a re-determination module, configured to re-determine the target load balancing server corresponding to the target client's data flow when a communication failure is detected between the switch and the target load balancing server corresponding to the target client's data flow; the target client is one of different clients; and the data flow of the target client is forwarded to the re-determined target load balancing server.
[0171] In an exemplary embodiment, the re-determination module is further configured to delete the target load balancing server corresponding to the data stream of the target client from the load balancing server list to obtain an updated load balancing server list; and to filter out the load balancing server associated with the hash value of the data stream of the target client from the updated load balancing server list as the re-determined target load balancing server.
[0172] In an exemplary embodiment, the data forwarding module 940 is further configured to forward the data stream of each client to the corresponding target load balancer server, so that each target load balancer server determines the target application server corresponding to the received data stream through a pre-trained neural network model, and forwards the received data stream to the corresponding target application server for processing through the corresponding current gateway. In the event of a failure of the current gateway, the received data stream is forwarded to the corresponding target application server for processing through the equivalent gateway of the current gateway.
[0173] In one exemplary embodiment, the list of load balancing servers corresponding to the switch includes multiple load balancing servers. These multiple load balancing servers are used to publish the same public IP address to the de-stacked switch, and there are multiple equal-cost routes between the switch and the multiple load balancing servers.
[0174] The device determination module 930 is also used to select a target route from multiple equal-cost routes between the switch and multiple load balancing servers for each client's data flow, based on the border gateway protocol routing principle and the five-tuple information of each client's data flow; and to use the load balancing server associated with the target route selected for each client's data flow as the target load balancing server corresponding to each client's data flow.
[0175] The modules in the aforementioned load balancing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0176] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 10As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. The computer program, when executed by the processor, implements a load balancing method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0177] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0178] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0179] In one exemplary embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above-described method embodiments.
[0180] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0181] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0182] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0183] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A load balancing method, characterized in that, Applied to a switch, the method includes: Receive data streams sent by different clients; Obtain the 5-tuple information of the data stream for each client; Based on the five-tuple information of the data stream of each client, determine the target load balancing server corresponding to the data stream of each client; The data stream from each client is forwarded to the corresponding target load balancer server; each target load balancer server is used to determine the target application server corresponding to the received data stream, and forward the received data stream to the corresponding application server for processing; The step of determining the target load balancing server corresponding to the data stream of each client based on the five-tuple information of the data stream of each client includes: calculating the hash value of the data stream of each client based on the five-tuple information of the data stream of each client using a consistent hashing algorithm; if the number of clients is detected to be greater than the number of load balancing servers in the load balancing server list, obtaining an expanded load balancing server list; and selecting the load balancing server corresponding to the load balancing server identifier associated with the hash value of the data stream of each client from the expanded load balancing server list, as the target load balancing server corresponding to the data stream of each client. The method further includes: If a communication failure is detected between the switch and the target load balancer server corresponding to the data flow of the target client, the target load balancer server corresponding to the data flow of the target client is removed from the load balancer server list, resulting in an updated load balancer server list; the target client is one of the different clients. Based on the consistent hashing algorithm, the load balancing server corresponding to the load balancing server identifier associated with the hash value of the target client's data stream is selected from the updated load balancing server list and used as the newly determined target load balancing server. The data stream from the target client is forwarded to the newly identified target load balancer server.
2. The method according to claim 1, characterized in that, Forwarding the data stream from each client to the corresponding target load balancer server includes: The data stream from each client is forwarded to the corresponding target load balancer server. Each target load balancer server uses a pre-trained neural network model to determine the target application server corresponding to the received data stream and forwards the received data stream to the corresponding target application server for processing through the corresponding current gateway. If the current gateway fails, the received data stream is forwarded to the corresponding target application server for processing through the equivalent gateway of the current gateway.
3. The method according to claim 1, characterized in that, The list of load balancing servers corresponding to the switch includes multiple load balancing servers. These multiple load balancing servers are used to publish the same public IP address to the de-stacked switch. There are multiple equal-cost routes between the switch and the multiple load balancing servers. The step of determining the target load balancing server corresponding to the data stream of each client based on the five-tuple information of the data stream of each client includes: For each client's data flow, based on the border gateway protocol routing principle and the five-tuple information of each client's data flow, a target route is selected from the multiple equal-cost routes existing between the switch and the multiple load balancing servers; The load balancing server associated with the target route selected for the data flow of each client is taken as the target load balancing server for the data flow of each client.
4. The method according to claim 1, characterized in that, The list of load balancing servers includes multiple load balancing servers to choose from.
5. The method according to claim 1, characterized in that, The updated list of load balancing servers does not include the target load balancing server corresponding to the data stream of the target client.
6. A load balancing device, characterized in that, Applied to a switch, the device includes: The data receiving module is used to receive data streams sent by different clients; The information acquisition module is used to acquire the five-tuple information of the data stream from each client; The device determination module is used to determine the target load balancing server corresponding to the data stream of each client based on the five-tuple information of the data stream of each client; The data forwarding module is used to forward the data stream from each client to the corresponding target load balancer server; each target load balancer server is used to determine the target application server corresponding to the received data stream and forward the received data stream to the corresponding application server for processing; The device determination module is further configured to calculate the hash value of each client's data stream based on the five-tuple information of each client's data stream using a consistent hashing algorithm; if the number of clients is detected to be greater than the number of load balancing servers in the load balancing server list, obtain an expanded load balancing server list; and from the expanded load balancing server list, select the load balancing server corresponding to the load balancing server identifier associated with the hash value of each client's data stream as the target load balancing server for each client's data stream. The apparatus further includes a re-determination module, configured to, upon detecting a communication failure between the switch and the target load balancing server corresponding to the data flow of the target client, delete the target load balancing server corresponding to the data flow of the target client from the load balancing server list to obtain an updated load balancing server list; the target client is one of the different clients; based on the consistent hashing algorithm, the load balancing server corresponding to the load balancing server identifier associated with the hash value of the data flow of the target client is selected from the updated load balancing server list as the re-determined target load balancing server; and the data flow of the target client is forwarded to the re-determined target load balancing server.
7. The apparatus according to claim 6, characterized in that, The data forwarding module is further configured to forward the data stream of each client to the corresponding target load balancer server, so that each target load balancer server determines the target application server corresponding to the received data stream through a pre-trained neural network model, and forwards the received data stream to the corresponding target application server for processing through the corresponding current gateway. In the event of a failure of the current gateway, the received data stream is forwarded to the corresponding target application server for processing through the equivalent gateway of the current gateway.
8. The apparatus according to claim 7, characterized in that, The device determination module is further configured to select a target route from multiple equal-cost routes between the switch and the multiple load balancing servers for each client's data flow, based on the border gateway protocol routing principle and the five-tuple information of each client's data flow; The load balancing server associated with the target route selected for the data flow of each client is taken as the target load balancing server for the data flow of each client.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Load balancing clustered system and method for providing services by using load balancing clustered system
CN103166870A
Access request processing method and system in load balancing cluster and readable medium
CN110198226A
Load balancing method, server, load balancer, system and electronic equipment
CN118283705A
Load balancing method and system, computer storage medium, and electronic device
WO2023207189A1