A method for allocating weights for multi-active load balancing on a cloud platform
By flexibly configuring multi-path routing weights and load balancing cluster grouping, it solves the problems of low resource utilization and high network communication pressure of traditional multi-active load balancing nodes, and improves query per second qps performance and network availability.
Patent Information
- Application Number
- CN202211238168.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-11
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2042-10-11
AI Technical Summary
Traditional multi-active load balancing relies on equal-cost routing and cannot be flexibly adjusted according to the specific conditions of the load balancing node, resulting in low resource usage and high network communication pressure, which affects query per second (qps) performance.
By flexibly configuring the weight of multipath routing, grouping load balancing clusters, setting affinity groups and anti-affinity groups, and adjusting weights according to the positional relationship between load balancing nodes and back-end servers, reducing cross-host virtual machine communication and improving Queries per second (qps) performance.
It effectively reduces cross-host virtual machine communication, reduces physical network pressure, and improves the overall query per second (qps) performance of load balancing.
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud computing, and more particularly to a method for allocating weights for multi-active load balancing in a cloud platform. Background Technology
[0002] Cloud computing has become one of the hottest topics in the IT infrastructure field in recent years. Its virtualization and abstraction of various resources such as computing, networking, and storage provides users with extremely convenient ways to use resources and flexible resource expansion capabilities. At the same time, the rapid development of technologies such as computer communication networks has made network overload and overcapacity commonplace. To solve network load problems, load balancing technology is used to provide more flexible, convenient, fast, and efficient cloud computing services. Load balancing is built on the existing network structure, providing a cheap, effective, and transparent method to expand the bandwidth of network devices and servers, increase throughput, enhance network data processing capabilities, and improve network flexibility and availability.
[0003] Currently, there are many different load balancing technologies to meet different application needs, such as software / hardware load balancing, local / global load balancing, higher network layer load balancing, and link aggregation technology.
[0004] Current multi-active load balancing relies on equal-cost routing (implemented in Linux using multipath routing). Hash strategies are based on Layer 3 (source IP hash) and Layer 4 (source IP, destination IP, source port, destination port, and transport protocol hash). Each next hop in equal-cost routing is completely equal and cannot be flexibly adjusted according to the specific situation of each load balancing node.
[0005] Traditional multi-active load balancing using equal-cost routing can be horizontally scaled by increasing the number of virtual machines, but this also increases resource utilization exponentially. Furthermore, the random distribution of load balancing nodes and backend servers across physical machines increases network communication between virtual machines on many different physical machines, thus increasing the load and communication pressure on the physical network. Summary of the Invention
[0006] To address the aforementioned technical issues, this invention provides a method for allocating weights in a cloud platform for multi-active load balancing. By flexibly configuring the weights of multi-path routes, access traffic and the number of connections are allocated more rationally, thereby enhancing the queries per second (QPS) performance of multi-active load balancing that relies on multi-path routing.
[0007] The technical solution of this invention is:
[0008] A method for weight allocation in a multi-active load balancing system includes:
[0009] 1) Group the load balancing cluster;
[0010] 2) Flexibly configure the weight of each group.
[0011] Load balancing is grouped according to the physical location relationship with the backend servers, including affinity groups and anti-affinity groups.
[0012] The weights of each group can be flexibly configured. The weight of the affinity group is set to N (N>1), and the weight of the anti-affinity group is set to K (K>1). The number of connections is distributed according to the ratio of N to K. The weights can also be customized, but the weight of the affinity group should be greater than that of the anti-affinity group.
[0013] Furthermore,
[0014] First, by utilizing the multipath routing supported by the Linux system kernel, an equivalent route with the destination address as the load balancer VIP is sent on the virtual router (vrouter). This allows multiple links to be used simultaneously for the same destination address in this network environment, with the next hop being the business network IP address of each load balancer node.
[0015] Building upon this, when routing routes with the destination address of the load balancer VIP on the virtual router (vrouter), the weights are adjusted based on the affinity between the load balancer node and the backend server. If the affinity is high, the weight is set higher; conversely, if the affinity is low, the weight is set lower. This reduces cross-host virtual machine communication between the load balancer node and the backend server, effectively improving the overall query per second (QPS) performance of the load balancer.
[0016] Affinity groups are load balancing clusters located on the same physical machine as the backend servers, handling more than half of the network traffic and acting as a primary server; anti-affinity groups are load balancing clusters located on different physical machines from the backend servers, handling less than half of the network traffic and acting as a backup server.
[0017] Furthermore,
[0018] After configuring the load balancer node and the virtual router (vrouter), configure NAT for external network access.
[0019] First, the VIP needs to be bound to a floating IP. Then, on the egress firewall, NAT is configured using the public IP and the floating IP. Traffic accessing the public IP first reaches the egress firewall, where a DNAT operation is performed to translate the destination IP into the FIP bound to the VIP of the load balancer. Then, via the SNAT NS of the network node, it reaches the virtual router (vrouter). Based on the equivalent route with the destination IP as the VIP, the traffic is forwarded to the load balancer. The load balancer then forwards the traffic to the final application server according to the nginx configuration.
[0020] Furthermore,
[0021] To verify public network accessibility, use a public network client to access the public IP address. To verify internal network accessibility, use client1 and client2 on the internal network to access the VIP address. Also, test the number of new connections to see if the connection allocation matches the set ratio.
[0022] The beneficial effects of this invention are
[0023] 1) Reduced virtual machine communication across host machines, alleviating physical network pressure;
[0024] 2) Virtual routers (vrouters) distribute more connections and network traffic to load balancing nodes that are compatible with the backend servers, which can improve the overall query per second (QPS) performance of the load balancer. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] This invention provides a method for weight allocation in multi-active load balancing on cloud platforms. First, leveraging multi-path routing supported by the Linux kernel, an equivalent-cost route with the load balancer VIP as the destination address is sent to the virtual router (vrouter). This allows multiple links to be used simultaneously for the same destination address within the network environment, with the next hop being the business network IP address of each load balancer node. Furthermore, when sending routes with the load balancer VIP as the destination address to the vrouter, the weight is adjusted based on the affinity between the load balancer node and the backend server. Higher weights are assigned to nodes with higher affinity, and lower weights to nodes with lower affinity. This reduces cross-host virtual machine communication between the load balancer node and the backend server, effectively improving the overall queries per second (QPS) performance of the load balancer.
[0027] The load balancing cluster is divided into two groups: an affinity group and an anti-affinity group. The affinity group is a load balancing cluster located on the same physical machine as the backend servers, handling most of the network traffic and acting as a primary server. The anti-affinity group is a load balancing cluster located on a different physical machine from the backend servers, handling a smaller portion of the network traffic and acting as a backup server.
[0028] The specific environment setup process is as follows:
[0029] 1. Environment preparation: Two networks are required. The first is the service management network, through which the console configures the load balancer nodes, such as the load balancer configuration and the virtual machine system configuration of the load balancer nodes. It is mainly used for management purposes, and business traffic will not pass through this network card. The second is the tenant business network, which is the private virtual network where the backend servers are located. It is used to provide VIP services to the outside world and to communicate with the backend servers.
[0030] 2. There are two backend servers, server1 and server2. A simple web application is deployed on the server side to test the forwarding effect of load balancing.
[0031] 3. Apply for a VIP under the tenant's business network. Create two virtual machine groups on the load balancer node. One group serves as the affinity group, created on the same physical machine as the backend server, acting as the cluster to handle the main traffic. The other group serves as the anti-affinity group, created on a different physical machine than the backend server, acting as the backup server group to handle a smaller portion of the traffic. Configure the VIP and the load balancer on all load balancer nodes. Configure the VIP on the lo network interface using the command `ip addr add vip / 32dev lo`. In addition to configuring the load balancer, you also need to disable ARP replies for the VIP on the load balancer node using the following command:
[0032] echo 1> / proc / sys / net / ipv4 / conf / eth1 / arp_ignore
[0033] echo 1> / proc / sys / net / ipv4 / conf / all / arp_ignore
[0034] echo 1> / proc / sys / net / ipv4 / conf / lo / arp_ignore
[0035] echo 2> / proc / sys / net / ipv4 / conf / eth1 / arp_announce
[0036] echo 2> / proc / sys / net / ipv4 / conf / all / arp_announce
[0037] echo 2> / proc / sys / net / ipv4 / conf / lo / arp_announce
[0038] This is used to disable ARP answering on the network card and enable ARP proxy answering on the virtual switch. This way, traffic accessing the VIP from both the internal and external networks will first pass through the virtual router (vrouter), which will distribute the traffic and avoid the situation where two load balancer nodes compete to answer ARP responses, thus preventing a split-brain scenario.
[0039] 4. In the virtual router (vrouter), deploy equal-cost routes, setting the weight of the affinity group to 3 and the weight of the anti-affinity group to 1. Configure traffic allocation according to a 3:1 strategy. This way, when access traffic reaches the vrouter and TCP connections are established, they will be allocated in a 5:1 ratio. For example, with 400 new connections, 300 will be allocated to the affinity group and 100 to the anti-affinity group. Using 172.16.122.1 as the VIP, 172.16.122.2 and 172.16.122.3 as the tenant service network IPs of the affinity group, and 172.16.122.4 and 172.16.122.5 as the tenant service network IPs of the anti-affinity group, with the gateway NIC name qr-2b749a55-20 as an example, execute the following command in the vrouter:
[0040] ip route add 172.16.122.1 nexthop via 172.16.122.2 dev qr-2b749a55-20weight 1nexthop via 172.16.122.3dev qr-2b749a55-20 weight 1nexthop via 172.16.122.4dev qr-2b749a55-20 weight 5nexthop via 172.16.122.5dev qr-2b749a55-20 weight 5
[0041] And enable ARP proxy in the virtual router (vrouter) using the following command:
[0042] echo 1> / proc / sys / net / ipv4 / conf / qr-2b749a55-20 / proxy_arp
[0043] echo 1> / proc / sys / net / ipv4 / conf / qr-2b749a55-20 / proxy_arp_pvlan
[0044] In this way, traffic accessing the VIP from either the internal or external network will first pass through the virtual router (vrouter), which will then distribute the traffic, thus avoiding a split-brain situation where two load balancer nodes compete for ARP responses.
[0045] 5. After configuring the load balancer and virtual router (vrouter), configure NAT for external network access. First, bind the VIP to a floating IP address. Then, configure NAT on the egress firewall using the public IP address and the floating IP address (provided the floating network and the egress firewall are interconnected). Traffic accessing the public IP address first reaches the egress firewall, where a DNAT operation is performed to translate the destination IP into the FIP address bound to the load balancer VIP. Then, via the SNAT NS of the network node, it reaches the virtual router (vrouter). Based on the equal-cost route with the destination IP as the VIP, the traffic is forwarded to the load balancer. The load balancer, according to the nginx configuration, then forwards the traffic to the final application server.
[0046] 6. Verify public network accessibility by using a public network client to access the public IP address, and verify internal network accessibility by using client1 and client2 on the internal network to access the VIP. Also, test the number of new connections to see if the connection allocation matches the configured 5:1 strategy.
[0047] Some terms explained in this article: vrouter, which stands for Virtual Machine Router; VIP, which stands for Load Balancer Virtual Address; QPS, which stands for Queries Per Second, is a measure of the amount of traffic a specific query server processes within a given time.
[0048] The above description is merely a preferred embodiment of the present invention and is used only to illustrate the technical solution 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 method for allocating weights for multi-active load balancing in a cloud platform, characterized in that, 1) Group the load balancing cluster; this refers to grouping the cluster according to its physical location relative to the backend servers, and setting up affinity groups and anti-affinity groups; 2) Configure the weight of each group; set the weight of the affinity group to N (N>1) and the weight of the anti-affinity group to K (K>1), and allocate the number of connections according to the ratio of N to K.
2. The method according to claim 1, characterized in that, Weights can be customized, with the affinity group having a higher weight than the anti-affinity group.
3. The method according to claim 2, characterized in that, By leveraging the multipath routing supported by the Linux system kernel, an equivalent route with the destination address as the load balancer VIP can be deployed on the virtual router (vrouter). This allows the same destination address to be used by multiple links simultaneously in the network environment, with the next hop being the business network IP address of each load balancer node.
4. The method according to claim 3, characterized in that, Based on this, when routing routes with the destination address of the load balancer VIP on the virtual router (vrouter), the weight is adjusted according to the affinity between the load balancer node and the backend server. If they are affinities, the weight setting value is increased; otherwise, the weight setting value is decreased.
5. The method according to claim 1, characterized in that, Affinity groups are load balancing clusters located on the same physical machine as the backend servers, handling more than half of the network traffic and acting as a master server. Anti-affinity groups are load balancing clusters located on different physical machines from the backend servers. They handle less than half of the network traffic and act as a backup server.
6. The method according to claim 4, characterized in that, After configuring the load balancer node and the virtual router (vrouter), configure NAT for external network access.
7. The method according to claim 6, characterized in that, First, you need to bind the VIP to a floating IP address. Then, on the outbound firewall, configure NAT using the public IP address and the floating IP address. Traffic accessing a public IP address first reaches the egress firewall, where a DNAT operation is performed to translate the destination IP into the FIP bound to the VIP of the load balancer. Then, via the SNAT NS of the network node, it reaches the virtual router (vrouter). Based on the equivalent route with the destination IP as the VIP, the traffic is forwarded to the load balancer. The load balancer then forwards the traffic to the final application server according to the Nginx configuration.
8. The method according to claim 7, characterized in that, To verify public network accessibility, use a client connected to the public IP address. To verify internal network accessibility, use client1 and client2 connected to the VIP address. Also, test the number of new connections to see if the connection allocation matches the set ratio.
