How to configure multiple origins with load balancing algorithms

When you create an edge application, you need to define an origin. However, more complex and robust infrastructures may need multiple origins for the same application. The Load Balancer module allows you to use load balancing algorithms to manage high access numbers and control the behaviors of your origin.

The following steps will walk you through a hypothetical scenario where the default origin should be of the Load Balancer-type with the Round Robin algorithm. Feel free to interpret and modify the step-by-step instructions according to your specific use case.

The following business rules of different origin servers must be configured with load balancing:

  • The application should have three origins.
    • The primary server should have a higher load capacity.
    • The secondary server should have a medium load capacity, enough to handle large surges of incoming traffic.
    • The backup server should have a low load capacity and only be active in special circumstances.
  • Each of these servers should be hosted in a different storage provider or cloud service since server outages don’t often occur simultaneously.
  • All origins must contain the same content and be set up in the exact same way for the edge application.

Therefore, the setup would be:

OriginRoleAddressLoad capacityStatus
1Primary serverexample.comHigh load capacityShould always be active.
2Secondary serverexample.netMedium load capacityShould always be active.
3Backup serverexample.orgLow load capacityShould only be active in case of maintenance or traffic surges.

First, to enable the Load Balancer module:

  1. Access Azion Console.
  2. On the upper-left corner of the page, open the Products menu, represented by three horizontal lines, and then select Edge Application.
  3. Click the edge application for which you want to configure a new origin with load balancer.
  4. On the Main Settings tab, under Modules, activate Load Balancer.
  5. Click the Save button.

To customize the origin according to the scenario described above:

  1. Select the Origins tab.
  2. In the Origins tab, click the Default Origin from the list.
  3. Give your new origin a name.
  4. Under Origin Type, select Load Balancer.
  5. In the Method field, select Round Robin.
  6. In the first Address field, specify the primary server. For example, example.com`.
  7. Since this origin has a higher load capacity, in the Weight field, add a weight of 3 to this first origin.
  8. In the Server Role field, keep Primary selected.
  9. Keep this origin Active.
  10. Add another origin by clicking the + button.
  11. In the second Address field, specify the secondary server. In this case, example.net.
  12. Due to its lower capacity, in the Weight field, add a weight of 2 to this origin.
  13. In the Server Role field, select Primary. This origin has a lower weight value, the preferred origin for connections will be the first.
  14. Keep this origin Active.
  15. Add a third origin by clicking the + button.
  16. In the Address field, specify the backup origin. In this case, example.org.
  17. Keep the Weight field blank. It will assume a default value of 1.
  18. In the Server Role field, select Backup.
  19. Disable this origin by turning off the Active switch.
  20. Click the Save button.

Wait a few minutes for the changes to propagate. Then, access your application or use the command line to make a request and check if the changes were made.


  1. Run the following GET request in your terminal, replacing [TOKEN VALUE] with your personal token and <edge_application_id> variable with your edge application ID to retrieve your default origin’s <origin_key>, which is a UUID value:
Terminal window
curl --location 'https://api.azionapi.net/edge_applications/<edge_application_id> \
--header 'Accept: application/json; version=3' \
--header 'Authorization: Token [TOKEN VALUE]'
  1. You’ll receive a response similar to this:
{
"results": {
"origin_id": <origin_id>,
"origin_key": "<origin_key>",
"name": "Default Origin",
"origin_type": "single_origin",
...
}
}
  1. Copy the <origin_key> value.
  2. Run the following PATCH request to modify the default origin as follows, replacing the key and application id in the URL:
Terminal window
curl --location --request PATCH 'https://api.azionapi.net/edge_applications/<edge_application_id>/origins/<origin_key>' \
--header 'Accept: application/json; version=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token [TOKEN VALUE]' \
--data '{
"name": "Default Origin (RR3)",
"origin_type": "load_balancer",
"addresses": [
{
"address": "example.com",
"weight": 3,
"server_role": "primary",
"is_active": true
},
{
"address": "example.net",
"weight": 2,
"server_role": "primary",
"is_active": true
},
{
"address": "example.org",
"weight": 1,
"server_role": "backup",
"is_active": false
}
],
"host_header": "${host}",
"method": "round_robin"
}'
  1. You’ll receive a response similar to this, confirming the changes have been made:
{
"results": {
"origin_id": <origin_id>,
"origin_key": "<origin_key>",
"name": "Default Origin (RR3)",
"origin_type": "load_balancer",
"addresses": [
{
"address": "example.com",
"weight": 3,
"server_role": "primary",
"is_active": true
},
{
"address": "example.net",
"weight": 2,
"server_role": "primary",
"is_active": true
},
{
"address": "example.org",
"weight": 1,
"server_role": "primary",
"is_active": false
}
]
"host_header": "${host}",
"method": "round_robin"
...
}
}
  1. Wait a few minutes for the propagation to occur.

Contributors