Shift traffic between two origins by weight
Move a share of requests from one origin to another with Load Balancer weights, and take an origin out of rotation with one switch.
You shift requests from one origin to another in steps, with the weights of the addresses of a Load Balancer connector, from Azion Console, the API, or the Azion CLI. To keep a standby out of traffic until the primary fails instead, refer to Add a backup origin to a connector.
Under Round Robin, each address receives a share of the requests in proportion to its weight, a whole number from 1 to 100. The weight sets a proportion, not an exact split: each data center balances on its own, so the share an address receives varies around the one its weight asks for. A weight cannot be 0, so an origin leaves the rotation through its Active switch, not through its weight.
- Both origins sit on one connector as Primary addresses, and the new origin starts with a small weight.
- Hold each set of weights until the new origin has served enough requests to show its errors.
- When new errors appear, turn the new origin’s address off to roll back.
- When no new error appears, raise the new origin’s weight, and hold again.
- When the new origin carries the share you want, turn the old origin’s address off to cut over.
Prerequisites
Console
- A connector of type
httpthat reaches the current origin, and a rule whose Set Connector behavior sends requests to it. To create both, refer to Connectors quickstart. - A new origin that holds the same application as the current one. Every address of a connector receives the same
Hostheader, so both origins must answer for the same name. - Access to Azion Console. Refer to Access Azion Console.
The examples use old-origin.example.com for the current origin and new-origin.example.com for the new one. Replace them with yours.
Put both origins on the connector
The connector gets Load Balancer with Round Robin, and the new origin joins as a second Primary address. A weight of 9 on the current origin and 1 on the new one sends about one request in ten to the new origin. A connector holds up to 15 addresses with Load Balancer on.
Host takes a name both origins answer for, such as ${host}, which sends the host the client requested. A literal name of the current origin would reach the new origin under a name it may not answer for. The examples set Max Retries, Connection Timeout, and Read/Write Timeout to 3, 30, and 60, the values the Console fills in. The API and the CLI give a key the body leaves out 0, 60, and 120.
Console
To put both origins on the connector in Azion Console:
Access Azion Console > Connectors, and select the connector of the current origin.
In Host, enter ${host}.
In Modules, turn on Load Balancer. The form fills in Max Retries, Connection Timeout, and Read/Write Timeout.
In Load Balancer Configuration, set Method to Round Robin.
Under Address Management, on old-origin.example.com, set Server Role to Primary and enter 9 in Weight.
In the new Address, enter new-origin.example.com, without a protocol or a port.
Set Server Role to Primary and enter 1 in Weight.
The Console shows Connector has been updated.
The connector holds two active addresses and sends about one request in ten to the new origin. A connector change reaches Azion’s distributed infrastructure over several minutes, and until every data center holds it, some requests reach the current origin alone.
In the Migrate an application to a new origin without downtime use case, this section takes these values:
| Setting | Value |
|---|---|
| Host | ${host} |
| Transport Protocol Policy | Force HTTPS, because both origins answer HTTPS on port 443 |
| Method | Round Robin |
| Max Retries, Connection Timeout, Read/Write Timeout | 3, 30, and 60 |
old-origin.example.com | Server Role Primary, Weight 99 |
new-origin.example.com | Server Role Primary, Weight 1 |
The connector holds two active addresses and sends about one request in a hundred to the new origin. A connector change takes several minutes to reach every data center, and until then some requests reach the old origin alone.
Change the weights
Each step changes only the weights. Hold a step long enough for the new origin to serve the requests that expose its faults before you take the next one. Each record of the HTTP Requests data source of Real-Time Events carries Upstream Status and Upstream Addr, the status and the address of the origin that answered, so a filter on the new origin’s address shows its errors.
Console
To change the weights in Azion Console:
Access Azion Console > Connectors, and select the connector.
Under Address Management, on old-origin.example.com, enter the new weight in Weight, such as 5.
On new-origin.example.com, enter the new weight in Weight, such as 5.
The Console shows Connector has been updated.
The new origin receives the share of the new weights once the change reaches each data center. During the spread, some data centers still apply the previous weights, so judge a step only after it has spread.
In the Migrate an application to a new origin without downtime use case, this section takes these values:
| Step | Old origin weight | New origin weight | Share on the new origin |
|---|---|---|---|
| 1 | 99 | 1 | About 1 in 100 |
| 2 | 90 | 10 | About 1 in 10 |
| 3 | 50 | 50 | About half |
| 4 | 10 | 90 | About 9 in 10 |
The new origin receives the share of the step once the change reaches each data center. During the spread, some data centers still apply the previous weights.
Take an origin out of rotation
The Active switch of an address takes it out of rotation without deleting it. The address keeps its ports, role, and weight, so turning it back on restores the step it left. Turning the new origin’s address off rolls back, and turning the current origin’s address off cuts over.
Console
To take the new origin out in Azion Console:
Access Azion Console > Connectors, and select the connector.
Under Address Management, on new-origin.example.com, turn off Active.
The Console shows Connector has been updated. To cut over instead, turn off Active on old-origin.example.com.
The address that is off receives no request once every data center holds the change. The change takes several minutes to spread, so keep the origin you turned off answering until no request reaches it.
The Migrate an application to a new origin without downtime use case uses the values of this example.
Measure the share and the errors of each origin
Each step is judged on what each origin received and how it answered. The checks below read a response header that tells the two origins apart, such as the server header each one sends, the requests of one hour grouped by upstream address in Real-Time Metrics, and the failing requests of the new origin in Real-Time Events. The examples use www.example.com for the site and <new-origin-ip> for the IP address that new-origin.example.com resolves to, which the event filters match on.
-
Both origins answer. Send the same request several times and read the header that tells the origins apart:
At equal weights, about half of the answers carry the new origin’s header. At weights of
99and1, most runs show only the old origin’s header, because one request in a hundred goes to the new one. The answers come in no fixed order. -
The new origin receives its share. Query the requests of one hour grouped by upstream address. Replace the token, the hour, and the hostname:
ShellThe API answers
200with one row per upstream address, in the form{"data":{"workloadBreakdownMetrics":[{"upstreamAddr":"<new-origin-ip>:443","total":<requests>}, …]}}. The new origin’s total against the sum of all rows tracks the share of the weights. -
No new errors on the new origin. In Azion Console > Real-Time Events, select the HTTP Requests data source and a period that covers the step, and enter this filter in Filter by:
An empty result means that no request to the new origin ended with
502. Repeat the filter with the other5xxcodes your origin can return. -
The rollback holds. After a rollback, run the filter
upstream_addr like '%<new-origin-ip>%'over the minutes after the change. The newest records stop once every data center holds the change.
A step that seems to have no effect may still be propagating. Repeat the check after a few minutes before you change the weights again.
These checks confirm the Migrate an application to a new origin without downtime use case.