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
- 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, for the Console procedure. Refer to Access Azion Console.
- A personal token and the ID of the connector, for the API procedure.
- The Azion CLI installed and authorized, and the ID of the connector, for the CLI procedure.
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.
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.
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.
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.
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.
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.