Weighted Load Balancing
- Last UpdatedApr 28, 2025
- 3 minute read
This topic describes how to assign weights to your data centers and origin servers to gain more precise control over the distribution of load between them.
Overview
The weights you assign determine the ratio of traffic distribution.
If a data center or server goes down or is taken offline, the traffic is redistributed according to the initial ratio.
For example, suppose you have 3 data centers configured for a website: DC1, DC2, and DC3, and you define a distribution of 50:30:20 for them, respectively. If DC1 is down, DC2 gets 60% of the load, and DC3 gets 40%.
The same principle applies to the ratio set for servers within a data center.
Guidelines
You can define a weight distribution for all the data centers configured for your site, and also for the servers within a data center.
Assigning weights to data centers
For a site with multiple data centers:
-
Weighting is supported only for sites configured with the Weighted global server load balancing mode.
- Define weights for active, enabled data centers only. Weights of enabled data centers must sum up to 100.
- Weighting is not supported on a standby data center
- Weighting is not supported on a data center that supports only forward rules.
Assigning weights to servers in a data center
-
Weighting is supported only for data centers configured with the Weighted mode.
- Define weights for enabled servers only.
- Define weighting separately for active and standby servers:
- Weights of active servers must sum up to 100
- Weights of standby servers must sum up to 100
How to configure weighted load balancing
Weights are defined in the website's Origin Servers settings. For details, see Load Balancing Settings.
For multiple data centers:
- Set the Global Server Load Balancing mode to Weighted.
- Set a weight for each active, enabled data center, adding up to 100.
For multiple servers in a data center:
- Set a weight for each active server in a DC, adding up to 100.
- Set a weight for each standby server in a DC, adding up to 100.
Example
In this example, there are 3 data centers configured for the website: DC1, DC2, and DC3.
- The weight distribution for the data centers is 25:25:50 respectively.
- DC1 is configured with a single public IP with port offsets. Load is distributed evenly between its 5 servers.
- DC2 has one active server that handles 100% of the data center's load, and 2 standby servers that are weighted 80:20.
- DC3 has two active servers, weighted 60:40.
API
You can also configure weighted load balancing for a website via the API.
The default weight when you add a new data center or server is 0.
To configure weighting, use the POST methods for editing data centers or servers.
For details, see Load Balancing Settings API Definition.