How to configure multiple origins with load balancing algorithms

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

There are separate instructions for API v3 using legacy Origin settings and API v4 using the new Connector product.

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 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.

Now you need to configure a new Connector to link your application to your Object Storage bucket. To do so:

  1. Access Azion Console > Connector.
  2. Click the + Connector button.
  3. In the General section, give your connector a unique and descriptive name (for example, Multiple Origins Connector).
  4. In the Connector Type section, select HTTP.
  5. Enable the Load Balancer switch, this enables you to add multiple addresses.
  6. In the Method field, select Round-Robin.
  7. In the first Address field, specify the primary server. For example, example.com.
  8. Since this origin has a higher load capacity, in the Weight field, add a weight of 3 to this first origin.
  9. In the Server Role field, keep Primary selected.
  10. Keep this address Active.
  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 address.
  13. In the Server Role field, select Primary. This address has a lower weight value, so the preferred address for connections will be the first.
  14. Keep this address Active.
  15. Add a third origin by clicking the + Add Address button.
  16. In the Address field, specify the backup origin. In this case, example.org.
  17. Keep the Weight field blank. It’ll assume a default value of 1.
  18. In the Server Role field, select Backup.
  19. Disable this address by turning off the Active switch.
  20. Click the Save button.

To activate the Connector in your application:

  1. Access the Rules Engine tab.
  2. Edit the default rule or add a new request rule.
  3. In the Criteria section, to apply the Connector for your whole application, set the criteria to If ${uri} starts with /.
  4. In the Behavior section, select the Set Connector behavior.
  5. Select the Connector you want to apply.
  6. Click the Save button.
  7. Wait some time for the changes to propagate to the edge. Then, access your application or use the command line to make a request and check if the changes were made.