In this walkthrough, you will use the Load Balancing interface in the Traffic app of the Cloudflare dashboard to create a load balancer in active-passive failover configuration. An active-passive failover configuration sends traffic to the servers in your active pool until a failure threshold (configurable) is reached. At the point of failure, Cloudflare then redirects traffic to the passive pool.
Be sure that you have the following:
Access to Load Balancing via one of the following:
To start, we’ll create a load balancer using the Create a Load Balancer wizard in the Cloudflare Traffic app:
Log in to the Cloudflare web application and select the site for which you want to create a load balancer.
Open the Traffic app. If you see the Enable Load Balancing action instead of Create a Load Balancer, you will need to add the Load Balancing service to your customer plan in order to proceed.
Click Create a Load Balancer and provide the hostname for your load balancer—the DNS name at which the load balancer will be available.
Click Next to continue.
Deleting a Load Balancer does not delete associated pools and monitors. Delete pools and monitors via the respective Manage Pools and Manage Monitors buttons within the Load Balancing tab under the Traffic app of the Cloudflare dashboard.
In this example, we are going to create two pools: The primary pool, and a secondary, backup pool that will serve traffic if the primary fails. (To set up an active-active failover configuration, where all servers receive traffic at once, we would create only a single pool.)
Click Create an origin pool.
Enter a name and origin server address for the first pool (this must be unique). This example uses an IP address, but if the origin server has a hostname, you can enter that instead. If you have configured pools already, you can select and add those here as well.
Click Save to continue.
Add a second pool, similar to our first, by clicking Add Pool. Name the pool and provide an origin server name and address. Click Save. By default, pools are ordered by date created. You can reorder them by clicking the arrows next to the numerals in the Order column. For now, leave the order as it is.
Click Next to continue.
Now you will create monitors to run health checks that track the status of your origin servers.
Click Attach Health Check and then Create a Health Check.
Click Next to attach the new health check to your primary pool.
Configure the health check:
Repeat Steps 1–4 to attach a health check to your secondary pool. The status of your health check will be unknown until the results of the first check are available.
Cloudflare polls for health status every 60 seconds. A green indicator represents a healthy status; red indicates a failed health check. Move the mouse over the indicator to display a tooltip with the reason for the failure (see Troubleshooting).
Click Next to configure Geo Routing.
Monitors are highly configurable. For more detail and a complete list of properties, see Monitors.
Use Geo Routing to configure traffic policies and failover priority by geographic region. This is extremely useful when you want site visitors to access the origin server closest to them, which improves page-loading performance.
For this exercise, don’t add new regions. For more on Geo Routing, see Traffic steering.
Click Next to continue to the final step, Reviewing the Load Balancing configuration.
Before creating your load balancer, the creation wizard presents your a summary of your configuration so that you can review and make changes.
Once you approve the configuration, click Save and Deploy to commit the configuration and immediately start your load balancer. Clicking Save as Draft will commit your configuration without starting the load balancer.
Once you have saved your load balancer configuration, you will be returned to the Load Balancing dashboard.
You can monitor your load balancers on the Load Balancing dashboard. The dashboard also provides quick access to common actions, such as creating new load balancers, managing monitors (health checks), and managing pools.
You can share your load balancer with other sites in your account by creating a canonical name (CNAME) record in the Cloudflare DNS app. This is useful for sharing configurations with multiple other domains, and you don’t have to create new load balancers for each site.
You can also configure separate load balancers for each domain and reuse monitors and pools. This is especially useful for changing the failover order for different domains, such as when your example.co.uk server has a different failover priority from example.com or example.com.au.