Load Balancing - Health - Debugging Failure Reasons

Learn how to configure Load Balancing and Intelligent Failover with Cloudflare.


Cloudflare users with China network access should not use Load Balancing because it causes 530 errors.

Load Balancing delivers traffic evenly across healthy servers, automatically failing over if any server seems unhealthy. With Load Balancing, you can set up health checks to monitor your servers at configurable intervals, and look for specific status codes, response text, and/or timeouts. The health checks run from each Cloudflare data center, so only the data centers that can’t reach you have to failover.


A Load Balancer defines which servers are used and the order they should be used in. Geo-routing is also configured at the Load Balancer level. Load Balancing also allows you to direct your site visitors in Europe to a European data center, or US visitors to a North American data center, or dive deeper and configure traffic at a regional level. For example, your .co.uk domain might use a different ordering of Pools (favoring your London servers, for instance) then your .com.au domain.

Load Balancing applies to your Cloudflare account, not to a specific domain.

Step 1 - Create a Load Balancer and enter hostname

Before creating a Load Balancer, you must have Load Balancing enabled and at least two (2) origin servers for which to configure traffic.

If you don't have servers to configure, or are looking to test things out, review the Digital Ocean tutorial on setting up nginx on Ubuntu 16.04.

To configure a Load Balancer,

1. Log in to your Cloudflare account.

2. Choose the domain for which you would like to create a Load Balancer.

3. Click the Traffic app.

4. Click the Load Balancing tab, then click Create a Load Balancer. A Load Balancing dialog appears.


5. Enter your preferred Load Balancer Hostname.

  • If you have an existing DNS record at this name, your Load Balancer will overwrite it.
  • The "orange cloud" to the right of the hostname indicates that Cloudflare will proxy the traffic, allowing you to benefit from the same caching, security and performance benefits that you would normally benefit from. If you want a DNS-only Load Balancer (e.g. for a non-HTTP(S) protocol) you can click this to set it to "grey cloud" (unproxied) mode.

6. (Optional) Enable Session Affinity.

7. Click Next to continue. After adding your hostname, the next step is to create an Origin Pool.

Step 2 - Create an origin pool

Pools are groups of origin servers, or endpoints, that Cloudflare will steer traffic to.  Cloudflare Load Balancing allows you to configure multiple Pools, and configure a failover priority (Pool A-> Pool B-> Pool C) as needed. You can add up to 20 pools on a Free, Business, or Pro plan.

The fallback pool is not available when all pools are disabled.

To create an origin pool,

1. In the Load Balancing dialog, click Create an origin pool

2. Enter a Pool Name, Origin Name, Origin Address, and Weight your origin servers. 

  • The Pool Name must be unique. If you previously configured pools, you can choose which one to add from a drop-down list.
  • The Origin Address can be either an IP address or hostname.
  • The Weight (0.01 - 1.00) of each origin is relative to other origins in the pool. Equal values mean equal weighting. A weight of 0 means traffic will not be sent to the origin server, but health is still checked. A weight of 1 means all traffic will be sent to that specific origin server. The calculated percentages apply when all origins are healthy. 


3. After entering the necessary information, click Save. 

4. After adding at least two (2) pools, the next step is to configure Health Checks.

Disabling a Pool will disable it for all associated Load Balancers, so take caution if disabling a Pool after configuring multiple Load Balancers.

Step 3a - Attach health check

A Health Check describes how the Load Balancer will check the status of your origin. You have the option to determine if the Health Check occurs over HTTP or HTTPS, the status code(s) to look for, how often, and more. Health Checks attach to Pools, so you can monitor different locations or groups of servers differently, if necessary.

To configure health checks, 

1. Click on Attach Health Check, then Create a Health Check

2. Choose a Type, and enter a Path, Port (optional), and Health Check Description (optional).

  • The Type is the protocol used for the Health Check. There are three options: HTTP, HTTPS, and TCP.
  • The Path is the endpoint path to health check against.
  • The Port is the specific port health check against.

You have the option to add custom headers, change the timeout and retries, and check for a specific response body. If your origin responded without that body, the health check would mark it as unhealthy.

In the example below, the 'Production Health Check' has been set up to occur over HTTP every 60 seconds. The check will timeout after 5 seconds and if the check fails, there will be two (2) additional attempts before marking the origin pool unhealthy. 


3. Click Save, then click Next to Configure Health Check.

Step 3b - Configure health check

Configuring the Health Check requires setting the Health Threshold and the Health Check Regions. The Health Threshold defines how many origin servers must still be healthy before the pool itself is marked unhealthy. The Health Check Regions allow the load balancer to check your origin health from multiple locations, improving failover granularity.

To configure health checks, 

1.  Enter your desired Health Threshold. 

2. Choose your desired Health Check Regions from the drop-down menu.

3. Enter your preferred Email Address for status notifications. 

You can also enter a mailing list address (e.g. a Google Group) or a PagerDuty address to share status notifications with a larger team. 


4. Click Save, then Next to complete. You will see the Add Traffic Steering dialog. 

After attaching a Health Check, the origin status will be unknown for a moment while the first checks run. The dashboard will poll for updated health status every 60 seconds, and you should see a green healthy status or a red critical status if the health check failed. If you're seeing failures, you can mouse-over the tooltip and see the exact reason it failed. Failure reasons and steps to resolve can be found here in our troubleshooting guide.

Step 4 - Add Traffic Steering

Traffic steering allows you to route traffic to the pools in specific regions in order of availability. Traffic outside of your preferred regions will follow your previously defined load balancing traffic settings. 

To add Traffic Steering,

1. In the Add Traffic Steering dialog, choose from the following four (4) options:

  • Off: Cloudflare will rout pools in failover order.
  • Dynamic steering: Route traffic to the fastest pool based on measured latency from health checks.
  • Geo steering: Route to specific pools based on the Cloudflare region serving the request.
  • Random: Route to a healthy pool at random.


2. Click Next. Your last step is to review your Load Balancing configuration and decide whether you need to make any changes.

Step 5 - Review Load Balancing Settings

After configuring traffic steering, a Review dialog will appear. Review your load balancing settings and click,
  • Save as Draft to save your work without enabling the load balancer, or 
  • Save and Deploy to immediately start load balancing that hostname. 

Sharing your Load Balancer within your account

You can also share your Load Balancer with other sites in your account by creating a CNAME record - e.g. you can CNAME "www.example.com" to "lb.moonbrookbowlsclub.com" in the DNS app. This is useful if you want to share the same configuration with multiple other domains, and saves you having to re-create the Load Balancer each time.

You can also configure separate Load Balancers for each domain, and re-use the same Monitors and Pools. This can be useful if you want to change the failover order for different domains - e.g. perhaps "example.co.uk" has a different failover priority from "example.com" or "example.com.au".

Related resources

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