Balance traffic across multiple origins
Spread the requests of an Application across several origin addresses with an origin of the Load Balancer type.
You can spread the requests of an Application across several origin servers with Load Balancer, from Azion Console or the API. Load balancing belongs to an origin of the Application, of the Load Balancer type, and Load Balancer distributes the requests among the addresses of that origin with a balancing method. A rule with the Set Origin behavior sets the origin of the requests it matches. For every field of an origin, refer to Origins.
Prerequisites
Console
- An Application, and a hostname that reaches it.
- Two or more origin servers that hold the same content and are set up the same way for the Application.
curl, to request the hostname.- Access to Azion Console. To sign in, refer to Access Azion Console.
Plan the addresses
The example on this page balances three origin servers. Each one is hosted with a different storage provider or cloud service, because server outages rarely occur at the same time. All three hold the same content and are set up the same way for the Application. Two of them share the traffic, and the third stands by for the case where both fail.
| Address | Server | Load capacity | Weight | Server role | Active |
|---|---|---|---|---|---|
example.com |
Primary | High | 3 |
primary |
Always |
example.net |
Secondary | Medium, enough for large surges of traffic | 2 |
primary |
Always |
example.org |
Backup | Low | 1, the default when the weight is left blank |
backup |
Always |
The weight follows the load capacity of each server. Both example.com and example.net are primary, so example.com receives about three requests for every two that example.net receives. example.org receives requests only when both primary addresses fail. It stays active, because an address that is not active receives no request, even as a backup. For how the weight, the server role, and the active state distribute requests, refer to Balancing methods.
Balance the addresses on an origin
Console
Load Balancer is a setting on the Application, and the addresses sit on one origin. To set both in Azion Console:
Access Azion Console > Applications > your Application.
In the Main Settings tab, under Modules, turn on Load Balancer.
In the Origins tab, select Default Origin to balance the addresses the Application already uses, or + Origin to add a separate one. Editing the default origin replaces the address the Application was created with.
Enter a name and set Type to Load Balancer.
In Method, select a method, such as Round-Robin.
In the first Address field, enter the primary server. In Weight, enter its share of the requests, such as 3 for a server with more capacity. In Server Role, keep Primary, and keep the address Active.
Select + Add Origin for each further address. A Weight left blank takes 1. An address with Server Role set to Backup receives requests only when the primary addresses fail, and an address with Active off receives none.
Select Save.
For every field of the origin, refer to Origins.
Confirm that the Application answers
The change takes a few minutes to propagate. Until then, the Application answers as it did before.
To confirm it, send a request to a hostname that reaches the Application, with that hostname in place of <your-domain>:
The response starts with the status line that one of the primary addresses returns, such as HTTP/2 200, followed by the response headers of that origin server. A header that each origin server sets to its own value, such as server, shows which address answered. If the response does not come from your origin servers yet, send the request again until it does.