What is Load Balancing?
Load Balancing is a feature whereby your router has more than one WAN (Internet) connection, for example two ADSL lines and distributes your Internet traffic across both of them. Load balancing can operate over any number of WAN feeds and they can be of different types - for example an ADSL connection and a fibre connection.
The purpose of load balancing is either:
- To try to achieve a uniform traffic balance - spreading connections equally across your WAN connections, thus making best use of your available bandwidth or
- To distribute traffic according to a set of rules defining which WAN feed should be used for a given data or connection type.
The type of WAN connections supported (ADSL, VDSL, Ethernet, 3G/4G etc.) will depend on the specific router model. For instance the Vigor 2860 series has an ADSL2+/VDSL2 modem for WAN1 and an Ethernet WAN interface for WAN2, it also has two USB ports for 3G/4G modems and can load balance all four connections potentially.
Any WAN interfaces on the DrayTek Vigor routers can be added to, or removed from, the Load Balancing Pool. In its default state, all WAN interfaces on the router are part of the Load-Balancing Pool and client connections will be balanced across those connections. When a WAN interface is removed from the Load-Balance Pool, connections are only sent through that WAN interface when traffic matches a Load Balance/Route Policy Rule, which could be important for metered Internet connections such as 4G/LTE ISPs.
IP-Based Load Balancing
In the simplest setup, your router will send outgoing data requests over all available connections when the router has more than one Internet connection active.
For example, if you have two WAN connections (Internet feeds); one PC requesting a web page might be sent over WAN1 and then a second PC's request would then be sent over WAN2.
In this way, if, say each connection has a download rate of 12Mb/s, both PCs would be able to download at 12Mb/s at once - your data is balanced across the two connections. Note that those 'two PCs' might actually be just one PC as each can make several connections (sessions) to the Internet at once.
In this mode, the load balancing is referred to as "IP-Based" because the assignment of each session is based on the remote IP address; access to a remote server will be sent through one WAN for all sessions to that server.
When testing Internet speeds on popular speed test sites, this would result in seeing the speed of one of the WAN interfaces. While performing this test though, the other WAN interfaces could be used to access other websites or download files.
Session-Based Load Balancing
When a DrayTek router is configured to load balance using "Session-Based" mode, sessions are assigned to a WAN connection (Internet feed) on a per-session basis, meaning that multiple sessions to the same remote server can make use of each WAN interface on the router.
Accessing a website will typically use multiple sessions, for instance downloading the HTML text and downloading the images on the page would be performed as individual sessions. Sending these sessions through two or more WAN interfaces instead of accessing the website over a single WAN interface can improve load times to sites that would use a large amount of bandwidth split into multiple downloads.
Peer-to-Peer applications will typically use many sessions to transfer files and can benefit significantly from Session-Based Load Balancing.
Speed Testing with different Load Balancing modes
When testing broadband speeds with IP-Based Load Balancing, where WAN1 has 10Mbps downstream with 10Mbps upstream and WAN2 has 10Mbps downstream with 5Mbps upstream, only one WAN interface is utilised for the speed test.
When testing broadband speed with Session-Based Load Balancing, where the speed test site is able to use mutliple sessions, this would show the aggregate speed of the multiple Internet connections.
In the example earlier, we cited two 12Mb/s connections but, in reality, you might have WAN feeds, each of different capacity (bandwidth).
For example you might have one 60Mb/s VDSL connection, a 20Mb/s ADSL connection and a 5Mb/s 3G Cellular connection. In that scenario, your router would typically apply a distribution ratio so that three times as many connections (sessions) are sent over the VDSL connection compared to the ADSL, as it has three times the capacity.
Similarly, the 3G connection would have an even smaller proportion.
Limitations to even distribution of connections
We've spoken about the router allocating sessions (or connection requests) that you get a good spread of connections over all of your WAN connections however, the number of sessions actually has little relationship to the actual volume of data that might be sent over that session. For example, if 10 users request web pages, of, say, 120KB each and two other users starts FTP file downloads of 26MB each, you have 12 sessions in total and the router will allocate 6 sessions to each WAN connection (WAN1 & WAN2) in the order in which they start.
In this way, you may happen to end up with both of the large downloads on the same WAN feed (WAN1) with four of the web sessions, and the other 6 web sessions on the other WAN connection (WAN2). The 6 sessions on WAN2 will complete quickly, and then WAN2 is idle - its bandwidth wasted whilst WAN1 is still busy with those large downloads.
Ideally, the two file downloads would have been allocated to different WAN connections, along with 5 of the web sessions each however, your router doesn't know in advance the volume of data that each of those 12 sessions will generate - it has to allocate each session to one of the WAN connections, and there it will stay.
In reality, routers don't apply such simple decisions; the decision making facility is a bit smarter than just round-robin allocation, but you know your data better than the router does, and that's where rules become useful.
Load Balancing According to Rules
Instead of letting your router entirely decide how to distribute connection requests, your load balancing can instead operate according to rules, or a routing policy. There are several different criteria you can apply as rules for the router to follow but the most common are selecting the WAN connection based on the source or destination, or the traffic type.
If traffic matches a load balancing rule it can then be routed via a chosen interface. The interface could be a specific WAN feed (WAN1, WAN2 etc) or a VPN tunnel and is applied depending on the Source IP / Destination IP / Destination Port that the traffic uses
Metrics and Priority
For granular control over the routing decision that is taken for specific traffic, metrics can be used to decide which routing entry is chosen where multiple rules might match. Pre-set metric values are used for different classes of routing entries (For example Static Routes, VPN Routes, Default Routes etc.) and manually added Policy Rules have a configurable priority metric which allows these rules to over-ride the router's routing table if required. A metric system provides flexibility and gives predictable control.
More information is available in this article:
Failover is very closely related to load-balancing in that it makes use of two or more WAN connections, but in this case the additional WAN connections would be used as 'emergency' connections in place of the primary connection when that fails. For example, if your main connection is a VDSL line, and your line breaks, a router can automatically switch over to (say) a 4G/LTE wireless connection or another DSL line etc.
Failover is an inherent part of load-balancing, in that two WAN connections can be load-balanced, but in the case of one connection going down, all traffic is routed via the remaining connection. Once the other WAN connection resumes, new sessions can be load balanced once more.
The Failover behaviour can also be controlled using the Failback options in Route Policy rules, which make it possible to specify whether or not the router would force traffic back onto the main primary connection when it resumes service.