Load Balancing: Best Practices for Planned Maintenance

When making changes to your application, or adding assets to it you may be presented with the following problem: you want to roll out changes one origin at a time to make sure they work as intended. However, as the load balancer continues to load balance between multiple origins, users are balanced between both versions of your app, and get an inconsistent experience.

Here we will go through the steps of how to tackle this issue:

1. Change the server you're about to upgrade to fail the health check - e.g. /health returns a non-matching status code that Load Balancing sees as "down". You can configure the "Response Body" field in a Monitor to look for specific text.

lb-monitor.png2. Confirm the server is now not receiving traffic. You should receive a notification email about the origin being down and/or be able to confirm through your own metrics.

3. Upgrade the origin and test and the new change is working as intended

4. Swing back traffic by making health checks pass again.

5. Repeat for other origins.

This process allows you to make controlled changes to your origin servers without disrupting users. Further, this can also be automated via our Load Balancing API to set the status of an origin server to "disabled" by setting the "enabled" field on an origin object to "false" - e.g. 

# PUT https://api.cloudflare.com/client/v4/user/load_balancers/pools/{{pool_id}}
{ "description": "Production Datacenter #1 - US West ", "created_on": "2016-12-22T16:16:16.206253Z", "modified_on": "2017-01-14T00:11:23.656655Z", "id": "916167df7265e0ab2284400cee32282f", "enabled": true, "minimum_origins": 1, "monitor": null, "name": "Production Datacenter 1", "notification_email": "you@example.com", "origins": [ { "name": "server-1", "address": "", "enabled": false }, { "name": "server-2", "address": "", "enabled": true } ] }
Not finding what you need?

95% of questions can be answered using the search tool. This is the quickest way to get a response.

Powered by Zendesk