0. The Function of Link Load Balancing (What)#
The role of link load balancing is to distribute the traffic of internal users accessing the external network across multiple links. It's like having several routes to choose from when going home from work; link load balancing can help us select the fastest route to relax at home after work, or the route with the best scenery, or even the route with barbecue.
From the functionality, we can see the scenarios for link load balancing:
For enterprises, using multiple exit links can prevent the impact of a single exit link failure on company operations and can also avoid slow resource access across ISPs.
1. Why Do We Need Link Load Balancing (Why)#
As mentioned above, the main function of link load balancing is routing, and routing in the network also has equivalent static routing and policy routing that can be applied to multiple exit links. So why do we still need link load balancing?
Equivalent Static Routing and Policy Routing#
To answer this question, we first need to define the concepts of equivalent static routing and policy routing:
Equivalent Static Routing: Manually configured static routes with the same destination, same priority, and different next hops. During data forwarding, one of the static routes is randomly selected;
Policy Routing: Manually configured routing that can match multi-dimensional information such as four-tuples, roles, ISPs, applications, and domain names, and selects routes based on different routing algorithms among multiple next hops.
From the concepts of equivalent static routing and policy routing, we can see that both can perform multi-exit routing, and policy routing has more powerful functionality, achieving something closer to link load balancing. However, the drawbacks of both are also evident: the policies are static, while links are dynamic.
Link Load Balancing#
Links have the concept of health. In a dynamic network environment, links may fail or become congested, leading to various unexpected situations. The need for link load balancing arises from this, as static routing policies cannot perceive dynamic changes in links. Therefore, an enhanced policy is needed to dynamically select routes based on the state of the links, under the premise of routing matching.
Link load balancing is an enhancement of routing functionality, relying on the results of routing matching.
2. What Should Link Load Balancing Achieve (How)#
To achieve link load balancing, we first need to organize its characteristics:
- Maintenance of basic link information: outgoing interfaces, next hops, ISPs, bandwidth, priority, weight, health status, etc.;
- Link state awareness:
- Interface status: enabled, disabled, new IP, deleted IP, type as routing port, switch port...
- Link status: related to the destination, packet loss rate, bandwidth, load...
- Link pool: a collection of links, which is the selection range for load balancing;
- Link load balancing algorithms: random, round-robin, weighted round-robin, priority, load rate, nearest route...
- In addition to the above characteristics, considering the situation where multiple connections from the client to the server are NATed to different IPs, which may be regarded as an attack and blocked by the server, it is necessary to perform link selection following sessions with the same characteristics (such as four-tuples) within a specific time, referred to as "session persistence."
Link State Awareness#
- Monitor interface status
- Use protocols like ping to perceive link status
Excessive awareness of link status is not recommended, as it can consume link bandwidth and server resources. Typically, traffic statistics can be used to calculate link load rate information, combined with interface status monitoring.
Link Load Balancing Algorithms#
Random#
Select one link from the normal links using a hash algorithm; if none are available, randomly select from overloaded links.
Round-Robin#
Select one link in order from the normal links; if none are available, select in order from overloaded links.
Weighted Round-Robin#
Distribute connections to the normal link list based on weight ratios. If none are available, select one from overloaded links using weighted round-robin.
The principle of weighting is essentially to simulate selecting a link based on weight each time, then reduce the weight of that link by one, and for the next simulation, select based on the new weight, ultimately generating a selection list. During actual routing, this selection list is then polled. For example, if there are links a:2, b:4, c:1, the simulated selection list generated based on weight would be: {b, b, a, b, a, b, c}, and the actual selection would be made by polling this list.
Priority#
Select one link from the normal link list based on priority; if none are available, select one from overloaded links based on priority.
Load Rate#
Calculate the load rate based on the ratio of link traffic to link bandwidth, selecting the link with the lowest load.
Nearest Route#
Query the ISP information database based on the destination IP, find the ISP where the destination is located, and select the link for that ISP. Other algorithms can be combined to further balance the load of the selection results.
Session Persistence#
Establish a session persistence table based on four-tuples and routing results, with items in the session persistence table expiring at regular intervals. When a new connection arrives, check the session persistence table; if a match is successful, update the expiration time of the session persistence table; if not, add a new item to the session persistence table.
Done!
This article is synchronized and updated to xLog by Mix Space The original link is https://www.vikifish.com/posts/network/linklb