What is Weight, and how should it be set?
Short answer
Weight is an integer in the range 1–256 that determines how much traffic a Backend Service receives relative to the others in the same list; its default value is 1. The share of each server is the ratio of its own weight to the total weight: three servers with weights 1, 2 and 3 receive approximately 17%, 33% and 50% of the traffic. The weight is set according to the capacity of the servers. The vService's default algorithm Round Robin ignores the weight; for the weight to take effect, an algorithm that uses the weight, such as Weighted Round Robin, is selected.
How Does It Work?
- Share calculation: share = the server's weight ÷ the sum of the weights of all the servers in the list. Example: 8, 4 and 2 → approximately 57%, 29% and 14%.
- Depends on the algorithm: The weight is applied if an algorithm that uses the weight is selected in the vService's LB Algorithm field.
- The ratio is what matters: If all servers are given the same weight, the distribution is equal; 1-1-1 and 50-50-50 give the same result.
- Per vService: If the same Backend Service is used in more than one vService, the share is calculated separately according to each vService's own list.
- Backups are not counted: Backend Services marked as Backup Service do not receive traffic while the main servers are up; the share is distributed among the main servers.
Which Algorithms Use the Weight?
| vService type | Uses the weight | Ignores the weight |
|---|---|---|
| HTTP | Weighted Round Robin, Least Connection, Least Response Time, Least Bandwidth, Random, Source, URI, URL Param, HDR | Round Robin (default), First, Fastest, Fastest+ |
| L7 TCP | Weighted Round Robin, Least Connection, Least Response Time, Least Bandwidth, Random, RDP Cookie | Round Robin (default), First, Fastest, Fastest+ |
| Network | Weighted Round-Robin, Weighted Least-Connection, Locality-Based Least-Connection, Source Hash | Round-Robin (default), Least-Connection, Destination Hash |
With the First algorithm, server selection is determined not by the weight but by the Connection Limit: the first server in the list takes the entire load until it reaches the connection limit. Fastest and Fastest+ select the server according to the selected measurement (e.g. response time). For Network vService algorithms: Network vService · Algorithms.
How Is It Set?
| Situation | Recommendation |
|---|---|
| The servers are on the same hardware | The same weight for all of them, or an algorithm that ignores the weight |
| One server is twice as powerful as the other | 2 for the more powerful one, 1 for the other |
| Bringing a new server into service gradually | A low weight first (e.g. 1 while the others are 10); the load is monitored and the weight is increased |
| A server in a remote data center | A lower weight than the local servers |
Weights are chosen in proportion to the number of cores, the memory, or the requests/second capacity measured with a load test.
In TR7
- Individual Backend Service: Load Balancer → Backend Services → Add or Edit → Details switch → Weight. When the field is empty, the default value 1 is shown in it.
- Backend Group: Weight is per server; it is entered separately for each row in the Backends table (Backend Groups · Weight).
- Algorithm: Load Balancer → Load Balancer vService List → vService → Edit → LB Algorithm; the change is saved with Save.
- For a value outside the range, the form gives the warning "Weight must be in range 1-256", and for a value that is not an integer, the warning "Weight must be an integer".
- On the Live Stats screen, the weight of each Backend Service with an assigned weight appears with
W=in its name cell; the actual distribution is monitored on the Backend Service's Dashboard screen. - When Clustering is on and Manual Sync Mode is off (default), a weight change is transferred to the peer device automatically.
Common Misconceptions
- "I entered a Weight, but the distribution did not change." The vService is on the default Round Robin algorithm, which ignores the weight; a switch is made to Weighted Round Robin or to another algorithm that uses the weight.
- "With Weight 0, the server is taken out of traffic." 0 cannot be entered; the lowest value is 1. To stop traffic, Maintenance Mode is used (Maintenance Mode does not apply to a Network vService; the Backend Service is removed from the vService's Backend Services list).
- "A server with Weight 1 receives no traffic at all." Weight 1 is the lowest share, but it is not zero.
- "The weight is the maximum number of connections the server will receive." The weight is a ratio; the upper limit is set with Connection Limit.
How it is done in the documentation
