Seamless Failover at the Apex: How to Use Cloudflare Load Balancing for High Availability

If you’re managing a production website, high availability isn’t a luxury — it’s a necessity. Imagine this: your primary server unexpectedly goes down. With no standby, your users are met with an error page and your brand takes a hit.

Now, imagine a better scenario — within seconds, traffic reroutes to a standby server, preserving uptime while you fix the issue. That’s the magic of Cloudflare Load Balancing. In this post, I’ll show you how to configure failover for your apex domain (e.g., example.com) using two backend servers: one live and one on standby.


The Goal


Step-by-Step Configuration

1. Prep Your Infrastructure

Make sure both servers:

2. Log In to Cloudflare

3. Set Up Your Load Balancer

Click “Create Load Balancer” and configure:

4. Create Pools

Pools define which servers serve traffic.

🔹 Pool 1: Primary

🔹 Pool 2: Standby

5. Define Failover Order

6. Point DNS to Load Balancer


Testing the Setup

Bring your primary server offline or simulate a failed health check:


Pro Tip

Want a smarter health check than just HTTP 200? Write a custom /health route that tests: