Which load balancing algorithms are supported?
Short answer
The selectable algorithms vary by vService type: there are 13 algorithms on the HTTP vService, 10 on the L7 TCP vService and 7 on the Network vService. Round Robin, Weighted Round Robin, Least Connection, Least Response Time, Least Bandwidth, First, Random, Fastest and Fastest+ are common to HTTP and L7 TCP; Source, URI, URL Param and HDR are available only on HTTP, and RDP Cookie only on L7 TCP. The algorithm is selected in the LB Algorithm box in the Details section of the vService; the default is Round Robin.
HTTP and L7 TCP vService
The algorithms are given in the order of the selector. Those marked "(Self-persistent)" automatically send a client carrying the same value to the same Backend Service; when one of them is selected, the Persistence field is hidden.
| Algorithm | How it selects | Uses Weight | HTTP | L7 TCP |
|---|---|---|---|---|
| Round Robin (default) | Distributes to the servers in turn and equally | No | ✓ | ✓ |
| Weighted Round Robin | Distributes in turn, in proportion to Weight | Yes | ✓ | ✓ |
| Least Connection | Selects the server with the fewest connections at that moment | Yes | ✓ | ✓ |
| Least Response Time | Selects the server with the lowest value of active requests × average response time ÷ Weight | Yes | ✓ | ✓ |
| Least Bandwidth | Selects the server carrying the least bandwidth (bytes/second, scaled by Weight) at that moment | Yes | ✓ | ✓ |
| First | Gives all the load to the first server in the list until its Connection Limit is full | No | ✓ | ✓ |
| Random | Draws two random candidates in proportion to Weight and selects the less loaded one | Yes | ✓ | ✓ |
| Fastest | Selects the server with the best value in the metric selected in the Fastest Opt-1 field | No | ✓ | ✓ |
| Fastest+ | If there is a tie in Fastest Opt-1, looks at the Fastest Opt-2 metric | No | ✓ | ✓ |
| Source (Self-persistent) | Selects according to the hash of the client IP address | Yes | ✓ | – |
| URI (Self-persistent) | Selects according to the hash of the request path | Yes | ✓ | – |
| URL Param (Self-persistent) | Selects according to the hash of the value of the specified URL parameter | Yes | ✓ | – |
| HDR (Self-persistent) | Selects according to the hash of the value of the specified HTTP header | Yes | ✓ | – |
| RDP Cookie (Self-persistent) | Selects according to the hash of the cookie value in the RDP connection | Yes | – | ✓ |
Least Response Time and Least Bandwidth are applied as Least Connection when the Core Engine version of the vService does not support them.
Network vService
| Algorithm | How it selects | Uses Weight | Protocol in which it can be used |
|---|---|---|---|
| Round-Robin (default) | In turn and equally | No | All |
| Weighted Round-Robin | In proportion to Weight | Yes | All |
| Least-Connection | The server with the fewest active connections | No | TCP - L4, UDP - L4 |
| Locality-Based Least-Connection | Traffic to the same destination IP address goes to the same server if that server is not overloaded; otherwise to the server with the fewest connections | Yes | TCP - L4, UDP - L4 |
| Weighted Least-Connection | The server with the lowest ratio of connection count to Weight | Yes | TCP - L4, UDP - L4 |
| Source Hash | The hash of the source IP address | Yes | TCP - L4, UDP - L4 |
| Destination Hash | The hash of the destination IP address | No | TCP - L4, UDP - L4 |
When ANY - L3 is selected as the Protocol, only Round-Robin and Weighted Round-Robin are listed and the algorithm is automatically set to Round-Robin. While Port Range is on, the other five algorithms appear selectable, but distribution is done with Round-Robin; Weight is applied only if Weighted Round-Robin is selected.
In TR7
- Selection: The vService is edited on the Load Balancer → Load Balancer vService List screen; Details is opened, the LB Algorithm box is checked and the algorithm is selected from the Algorithm list (on the Network vService, the list has no label). The info line below it briefly describes the selected algorithm. If the box is unchecked, the algorithm returns to the default and the Persistence setting is cleared.
- Algorithm-specific fields: URI Character Length and URI Depth for URI, URL Parameter to Use and Check Post Parameters for URL Param, HDR Name for HDR, RDP Cookie Name for RDP Cookie, Time Metric for Least Response Time, Bandwidth Window for Least Bandwidth, Fastest Opt-1 for Fastest, and additionally Fastest Opt-2 for Fastest+; Hash Consistency in self-persistent algorithms (algorithm-specific additional fields).
- Monitoring: The selected algorithm and its description are shown on the Load Balancer Management screen of the vService.
- WEB-CLI: The
--algorithmfield is used for HTTP and L7 TCP, and the--l4Algorithmfield for Network (distribution algorithm). Among the WEB-CLI values,roundrobinNoWeightis Round Robin, whileroundrobinis Weighted Round Robin.
Common Misconceptions
- "Round Robin uses Weight." Round Robin ignores Weight; for distribution in proportion to Weight, Weighted Round Robin is selected.
- "The Source algorithm is also available on L7 TCP." Source is available only on HTTP; on L7 TCP, persistence based on the client IP is provided with Persistence → Hash.
- "On Network, Least-Connection works while Port Range is on." While Port Range is on, distribution is done with Round-Robin.
- "The algorithm makes a difference with a single server." If there is a single Backend Service, all traffic goes to it; the choice of algorithm does not matter.
How it is done in the documentation
