---
title: "Cloudflare Load Balancing to Route Server Traffic (Step by Step)"
description: "Learn how to configure Cloudflare load balancing and say goodbye to applications and system outrages due to traffic spikes in this step-by-step tutorial!"
canonical: "https://adamtheautomator.com/cloudflare-load-balancing/"
---

# Cloudflare Load Balancing to Route Server Traffic (Step by Step)

> Learn how to configure Cloudflare load balancing and say goodbye to applications and system outrages due to traffic spikes in this step-by-step tutorial!

Source: https://adamtheautomator.com/cloudflare-load-balancing/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Cloudflare Load Balancing to Route Server Traffic (Step by Step)](https://adamtheautomator.com/wp-content/uploads/2022/03/Tapping-Cloudflare-Load-Balancing-to-Route-Server-Traffic.jpg)

# Cloudflare Load Balancing to Route Server Traffic (Step by Step)

[![](https://secure.gravatar.com/avatar/8bdc28e164f55988af82834833a3141a1efa1ff841a84d73bdff4544f888358b?s=192&d=mm&r=g)Elly Obare](https://adamtheautomator.com/author/elly-obare/)6 April 20225 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[CloudFlare](/tag/cloudflare/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Configuring a Failover for Traffic Steering](#configuring-a-failover-for-traffic-steering)
*   [Steering Traffic with Active-Passive Failover](#steering-traffic-with-active-passive-failover)
*   [Steering Traffic with Active-Active Failover](#steering-traffic-with-active-active-failover)
*   [Creating a Load Balancer](#creating-a-load-balancer)
*   [Editing and Deleting Load Balancer Configurations](#editing-and-deleting-load-balancer-configurations)
*   [Conclusion](#conclusion)

Are you tired of applications and system outages whenever your site detects a spike in traffic? Worry not! All you need is a networking cloud-based solution to help in routing traffic evenly across your servers. Luckily, there is Cloudflare load balancing which distributes traffic across your multiple servers, providing the high availability your site users need.

In this tutorial, you’ll learn to configure Cloudflare load balancing while highlighting its key features and advantages.

Read on and start creating your own load balancer!

## Prerequisites

To follow along, be sure you have a [Cloudflare](https://adamtheautomator.com/cloudflare-workers/) account, an active domain, and more than one origin server to serve content. An origin server is the source of your website content, with a minimum of two being necessary to demonstrate Cloudflare load balancing.

## Configuring a Failover for Traffic Steering

Before you can take advantage of Cloudflare load balancing, you need to understand the different available [failover](https://www.cloudflare.com/learning/performance/what-is-server-failover/) configurations. Server failover requires having a backup server (alternative origin server) configured to serve traffic and take over if the primary server (first origin server) becomes unavailable.

Automatic failover distributes traffic based on server latency and geographic regions of users when any server is unresponsive or unavailable.

Cloudflare’s common failover configurations include:

*   **Active – Passive**: The primary origin services all traffic until it is unavailable and the passive, or alternative origin, is promoted to service all traffic instead.
*   **Active – Active**: All origins are available to service traffic, with traffic divided up between them.

### Steering Traffic with Active-Passive Failover

An active-passive failover configuration steers the traffic to servers in your active pool until a failure threshold occurs. The load balancer will then redirect traffic to the configured secondary origin when the failure happens.

This configuration provides an uninterrupted service, especially when there are planned outages, but may result in slower responses due to all traffic being directed to a single origin.

To have an active-passive failover, you’ll need to have a load balancer with two origin pools.

1\. Open your favorite web browser and log in to the [Cloudflare dashboard](https://dash.cloudflare.com/).

2\. Create the first [origin pool](https://developers.cloudflare.com/load-balancing/how-to/create-pool#create-a-pool) and set that pool as the primary pool for your load balancer.

An origin pool consists of a group of servers known by their IP addresses or hostnames. Cloudflare load balancing redirect traffic towards the hostnames according to the health and weight of each origin.

![Creating the primary origin.](https://adamtheautomator.com/wp-content/uploads/2022/03/image-599.png)

Creating the primary origin.

3\. In the **Origins** section, click **Add Origin** to add a second origin to the existing pool, and click **Next**.

![Adding a secondary pool.](https://adamtheautomator.com/wp-content/uploads/2022/03/image-600.png)

Adding a secondary pool.

4\. Finally, select the [Off](https://developers.cloudflare.com/load-balancing/understand-basics/traffic-steering/pool-level-steering#off---standard-failover) option to direct traffic from any unhealthy pool to the next healthy pool in the configuration, and click **Next** to prompt you to save the configuration.

With this configuration, your load balancer will direct all traffic to be primary until the primary pool has fewer available origins than specified in its health threshold. Only then will your load balancer direct traffic to the secondary pool.

![Selecting Traffic Steering Option](https://adamtheautomator.com/wp-content/uploads/2022/03/image-601.png)

Selecting Traffic Steering Option

> _With the massive presence of Cloudflare servers around the globe, Cloudflare load balancing reduces latency by serving traffic across multiple servers. Or routing traffic to the closest geolocation region to ensure customers are not getting any lags at all._

### Steering Traffic with Active-Active Failover

An active-active failover steers traffic to servers within the same pool until the pool reaches its configured failure threshold. The load balancer would then redirect traffic to the set fallback pool when a failure occurs.

Create two origin pools (primary and secondary) then save the origin pool configurations, which you’ll use in step three of the “Creating a Load Balancer” section.

![Setting up an Active-Active Failover](https://adamtheautomator.com/wp-content/uploads/2022/03/image-602.png)

Setting up an Active-Active Failover

## Creating a Load Balancer

Cloudflare load balancing enhance application performance and availability by channeling traffic away from unhealthy and unavailable servers. At the same time, dynamically distributing the traffic to any available and responsive server pools without experiencing any latency. But how to create a Cloudflare load balance?

The first step in creating a load balancer is to create a hostname. A load balancer defaults to the root hostname, but you can also set a unique hostname matching your needs. Secondly, note the [session affinity](https://developers.cloudflare.com/load-balancing/understand-basics/session-affinity) that attempts to pin a session to a single origin.

1\. On your [Cloudflare dashboard](https://dash.cloudflare.com/), click on the **Traffic** menu —> **Load Balancing** tab to launch the creation page, as shown below.

Click on Create Load Balancer to configure a new load balancer.

> _Setting up _Cloudflare__ _load balancing requires no additional software or hardware, just the Dashboard or REST API. Additionally, you are at liberty to [scale origin pools](https://developers.cloudflare.com/load-balancing/understand-basics/health-details) tied to load balancers depending on the traffic in your system._

![Initiating Cloudflare Load Balancing ](https://adamtheautomator.com/wp-content/uploads/2022/03/image-603.png)

Initiating Cloudflare Load Balancing

2\. Next, configure a hostname with the following:

*   Supply a **Hostname**, basically a DNS name that hosts the load balancer to be created. In this demo, the hostname blur the hostname.

For this tutorial, traffic to the set hostname will not pass through Cloudflare. But as a developer, you can choose whether to [proxy](https://developers.cloudflare.com/load-balancing/understand-basics/proxy-modes) or not to [proxy](https://developers.cloudflare.com/load-balancing/understand-basics/proxy-modes) traffic to this hostname through Cloudflare by clicking the icon to the right of the hostname input box.

*   Shift the session-based load balancing toggle for [Session Affinity](https://developers.cloudflare.com/load-balancing/understand-basics/session-affinity). When session affinity is enabled, your load balancer will direct all requests from a particular end-user to a specific origin server.

Session affinity also reduces request traffics, saving customers on usage billing.

*   Click Next to load the Origin Pool page.

![Configuring a Hostname](https://adamtheautomator.com/wp-content/uploads/2022/03/image-604.png)

Configuring a Hostname

3\. Select an existing pool from the dropdown box and click **Add Pool** or click on **[Create a new origin pool](https://developers.cloudflare.com/load-balancing/how-to/create-pool)** to create a new one, then click **Next**. This demo uses the existing origin pool you created in the “Steering Traffic with Active-Active Failover” section.

![Adding an Origin Pool](https://adamtheautomator.com/wp-content/uploads/2022/03/image-605.png)

Adding an Origin Pool

4\. Now, select an existing Cloudflare [monitor](https://developers.cloudflare.com/load-balancing/understand-basics/monitors) or create a new one to attach to your origin pool, and click **Next**.

The Cloudflare monitor you attached will perform health checks regularly to determine the health of your origin pool. Your load balancer will therefore not direct traffic to that pool if it becomes unhealthy.

![Attaching a Health Check Monitor](https://adamtheautomator.com/wp-content/uploads/2022/03/image-606.png)

Attaching a Health Check Monitor

5\. Select your desired option shown below **Add Traffic Steering**. Geo or dynamic steering is only ideal for enterprise scenarios. So instead, choose the conventional failover ([Off](https://developers.cloudflare.com/load-balancing/understand-basics/traffic-steering/pool-level-steering/)) option, then click **Next**.

[Traffic Steering](https://developers.cloudflare.com/load-balancing/understand-basics/traffic-steering) distributes incoming requests to a load balancer based on factors such as [pool and origin health](https://developers.cloudflare.com/load-balancing/understand-basics/health-details), [pool steering](https://developers.cloudflare.com/load-balancing/understand-basics/traffic-steering/pool-level-steering), and [origin steering](https://developers.cloudflare.com/load-balancing/understand-basics/traffic-steering/origin-level-steering). Any traffic decision to be made starts from which pools and origins are healthy and available and should receive traffic.

![Selecting Preferred Traffic Steering Option](https://adamtheautomator.com/wp-content/uploads/2022/03/image-607.png)

Selecting Preferred Traffic Steering Option

6\. Finally, review the summary for your load balancer configuration, and click on the **Save and Deploy** button to deploy the new load balancer.

> _Suppose you want to [share](https://developers.cloudflare.com/load-balancing/how-to/create-load-balancer#sharing-your-load-balancer-with-other-sites) with the load balancer you created with other sites, you’ll need to create a [canonical name (CNAME)](https://developers.cloudflare.com/dns/zone-setups/partial-setup) first. A CNAME will help you share your configurations with several domains without creating new load balancers for each domain or site involved._

![Saving a Load Balancer](https://adamtheautomator.com/wp-content/uploads/2022/03/image-608.png)

Saving a Load Balancer

> _You’ve seen how sequential creating a load balancer is. But creating a load balancer can also be achieved through an [API](https://developers.cloudflare.com/load-balancing/how-to/create-load-balancer#via-the-api) approach to simplify the activity._

## Editing and Deleting Load Balancer Configurations

In case you made some errors while creating your load balancer, you can either edit or delete the configurations through the Cloudflare dashboard.

> _With Cloudflare load balancing, you can fashion [custom rules](https://developers.cloudflare.com/load-balancing/additional-options/load-balancing-rules) or reuse monitors and pools across multiple load balancers, Doing so, lets you adjust routing according to attributes of each request sent from different domains._

1\. Navigate to the **Traffic page** and click the **Load Balancing** option.

![Load balancer dashboard.](https://adamtheautomator.com/wp-content/uploads/2022/03/image-609.png)

Load balancer dashboard.

2\. Click on either **Edit** or **Delete** depending on your goal for your target load balancer configuration.

![Edit or delete dashboard.](https://adamtheautomator.com/wp-content/uploads/2022/03/image-610.png)

Edit or delete dashboard.

3\. Update the settings as needed while going through the creation workflow if you’re editing a load balancer configuration.

4\. Click the **Save** option after you’re satisfied with all the adjustments.

![Saving Modifications on a Load Balancer Configuration](https://adamtheautomator.com/wp-content/uploads/2022/03/image-611.png)

Saving Modifications on a Load Balancer Configuration

## Conclusion

In this article, you’ve learned how to create a load balancer. You’ve also looked into steering traffic with two different failovers for your load balancer, ensuring the high availability of your website.

Cloudflare’s global load balancing operates at the DNS level, supporting major protocols – HTTP(s), TCP, and even UDP-based services. This feature allows for integration with Cloud platforms or other services, be it compute or storage.

Now that you have seen Cloudflare Load balancing in action, why not implement it in any of your high-volume transaction businesses? Such as eCommerce applications to keep them fast and stable.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fcloudflare-load-balancing%2F&text=Cloudflare%20Load%20Balancing%20to%20Route%20Server%20Traffic%20\(Step%20by%20Step\))[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fcloudflare-load-balancing%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fcloudflare-load-balancing%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2021/07/How-to-Set-Up-End-to-End-SSL-Encryption-with-CloudFlare.jpg)

### [How to Set Up End-to-End CloudFlare SSL Encryption](/cloudflare-ssl/)

Securing connections to your server is always a good plan. Learn how to set up an end-to-end SSL encryption with Cloudflare in this step-by-step tutorial!

![](https://adamtheautomator.com/wp-content/uploads/2026/07/featured_image-4.png)

### [Migrate from EWS to Microsoft Graph API](/migrate-ews-microsoft-graph-api/)

Move EWS mailbox automation to Microsoft Graph with a practical inventory, permissions, PowerShell SDK, and cutover validation checklist.

![](https://adamtheautomator.com/wp-content/uploads/2026/06/featured_image-21.png)

### [Automate SOC 2 Compliance with PowerShell](/automate-soc-2-compliance-powershell/)

A comprehensive walkthrough on using PowerShell and Azure Policy as Code to automate evidence collection and enforce SOC 2 compliance controls across enterprise cloud environments.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
