Automatic load balancing
Last updated 2022-07-21
This guide describes how to automatically load balance between two or more origin servers. Load balancing distributes requests across multiple servers to optimize resource use and avoid overloading any single resource.
Before you configure load balancing, keep in mind the following:
- To prevent errors when shielding is enabled, all backends in the automatic load balancing group must use the same shielding location.
- Conditions on your origin server can directly change how automatic load balancing behaves. Be sure to review conditions behavior to ensure automatic load balancing works properly.
- Many customers configure failover at the same time they configure load balancing functionality. Our guide on configuring failover can show you how.
To enable load balancing across two or more origin servers, follow the steps below:
- Log in to the Fastly web interface.
- From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.
- Click Edit configuration and then select the option to clone the active version.
- Click Origins.
Click the name of the Host you want to edit.
From the Auto load balance menu, select Yes.
In the Weight field, enter the percentage of the total traffic to send to the origin server.
When you specify a whole number in the Weight field, you specify the percentage of the total traffic to send to a specific origin server. Each origin server receives the percentage (
/ ) of the total traffic equal to the number you specify. For example, if you have two origin servers, A and B, setting the weight to 50 on both splits the traffic between them equally. Each origin server receives 50 percent of your total traffic. If you increase the weight on origin server A to 55 and decrease the weight on origin server B to 45, the percentage of traffic changes to 55 percent and 45 percent respectively.
Repeat steps 5, 6, 7, and 8 for each origin server you want to include in the automatic load balancing group.
- Click Activate to deploy your configuration changes.
You can set conditions on origin servers to change how load balancing works. The load balancing autodirector groups servers together based on like conditions, giving you the flexibility to effectively create subsets of the autodirector by assigning a condition to one group of origins and another condition to another set of origins. If each group of origin servers has a different condition that affects load balancing, the auto load function will not randomly load balance between the different servers.
For more advanced load balancing scenarios, refer to our developer documentation.