GridPane is pleased to announce that we’ve accepted a strategic investment from Automattic Read all about it

How to Setup Snapshot Failover™ with Cloudflare

7 min read

Table of Contents

Introduction

Snapshot Failover™ is our proprietary high availability setup that allows you to clone all of the sites on one server over to another server, and set a syncing schedule for those paired servers of as little as one hour.

Couple this with automatic DNS failover that will switch your DNS records to your backup server if your primary server goes down, and you can ensure that your websites stay up and running even when your provider has an outage that impacts an entire datacenter.

This feature is available on Developer accounts.

Note: Currently Cloudflare’s free plan is not supported. The Cloudflare Load Balancing Feature which can be used for Automatic Failover starts from $5/month per site.

How does it work?

This article details how to setup Snapshot Failover works in conjunction with Cloudflare.

GridPane’s role is to do the cloning and ensure that the websites on your primary server are cloned over to your backup server, on the schedule that you set inside your dashboard.

Cloudflare’s role is to monitor your primary server and if it sees it down, automatically adjust your DNS records to point to your backup server.

Part 1. Setting up Snapshot Failover™ Inside GridPane

First, navigate to the “Tools” page inside your dashboard. Snapshot Failover™ lives directly below the Self Help Tools.

Here we need to set the source server, failover server and sync interval.

  1. Source Server: Select the server you wish to backup
  2. Failover Server: Select the server you wish to use as your backup
  3. Sync Interval (Hours): Select how frequently you want the cloning to take place. E.g. For the servers to sync every four hours, type “4”. You can set syncing to take place anywhere between 1 hour and 72 hours.

Once you’ve set the details, click the “Sync Servers” button.

Part 2: Setting Up Cloudflare Load Balancing

Cloudflare operates a little differently to DNSME and doesn’t have a specific “Failover” feature. 

Instead, Cloudflare has a load balancing feature that will allow us to create our own failover. Below we’ll be configuring load balancing specifically for this purpose.

We do this by creating what are called “Pools”. 

A Cloudflare Load Balancing pool usually represents a group of origin servers, but in our case, one pool will contain our primary source server (Primary-Pool), and the second will contain our backup failover server (Failover-Pool). We’ll set up Cloudflare so that it drives all traffic to the Primary-Pool, and if it finds that this is unhealthy or not responsive, it will change our domains A record to point to our Failover-Pool.

This is called Active Failover. More details can be found here:

https://developers.cloudflare.com/load-balancing/reference/common-configurations

Step 1: Setup Load Balancing 

To create a load balancer, click through to your website inside your Cloudflare account, and then through to the Load Balancing inside the Cloudflare Traffic tab.

Load balancing is a paid feature and has to be able enabled before proceeding. 

You’ll be asked to confirm your subscription or enter your payment details before activation:

When load balancing is enabled, you’ll see these 3 options as blue buttons: 

  1. Create a load balancer
  2. Manage monitors
  3. Manage pools

The following steps are technically the most efficient if this is your first time setting up a load balancer.

Step 2: Create 2 monitors

Click the Manage Monitors button to begin setting up your health monitors.

To ensure your monitor is able to accurately detect whether your site is healthy or not, the following is how you may want to configure these settings, but feel free to adjust as you see fit:

  1. Give your monitor a name
  2. Leave the default HTTP check, and if you wish, set a more lightweight page than the homepage to monitor.
  3. Interval: 60
  4. Method: GET
  5. Timeout: 10 seconds
  6. Retries: 2
  7. Expected codes: 200, 301, 302
  8. Follow redirects: Check (yes)
  9. Configure a request header – choose any name, set the value to your site’s hostname (the address without the https://).

Click “Save” when ready, and then repeat the process to create a second monitor for our Failover site.

Step 3: Create a primary pool and a failover pool

Back on the main Load Balancing page, click the “Manage Pools” button, and then click the “Create” button in the Origin Pools page.

Your primary source server will be used for your Origin Pool in your load balancer. 

  1. Pool Name: Give your origin pool a name (E.g. Primary-Server)
  2. Description: Add a description if needed.
  3. Origin steering: Leave as the default.
  4. Origins: Set your origin name (anything you want), primary source servers IP address, and be sure to enter a hostname with your site address (minus the https://) as pictured below. Set the weight to “1”.

Important: If you don’t set a host header Cloudflare will not be able to properly monitor the health of your site.

You can skip past the follow settings:

  • Configure co-ordinates for Proximity Steering
  • Configure Load Shedding

Next:

  • Health threshold: As we only have one server, we need to set our health threshold to “1”. This means that if our 1 server goes down, Cloudflare will make the switch to the failover server.
  • Monitor: Set the monitor that you created in the previous step for this pool.
  • Health Check Regions: In our case, we’re only allowed to select one, but depending on your subscription you may be able to select up to 8.

And finally, enter an email address for where you wish to receive notifications about the health of this server.

Click Save to finish up.

Create a Secondary Pool

Now we need to add another pool for our failover. Repeat all of the above to add your failover server (and it’s correct IP address).

Step 4.1: Create Your Load Balancer

Back on the Load Balancer main page, click the “Create a Load Balancer” button.

Step 4.2: Set Your Hostname

Your hostname is either your root domain (e.g. yourdomain.com) or a subdomain (sub.yourdomain.com), depending on your site URL. Here you can also choose whether your traffic is proxied or not. 

When configured click Next.

Step 4.3. Set Your Origin and Failover Pools

From the dropdown, select your primary server and add it as your origin pool:

Then set your Failover pool.

Click Next.

Step 4.4. Confirm Your Monitor

The monitor for your origin pool should already have been attached to it in Step 3, but if it isn’t you can set it now. Also, be sure to go to your Failover pool and set the failover monitor so that you’re alerted should it ever go down.

Step 4.5. Traffic Steering

Traffic steering should be set to off. This is what we need for failover to function.

With this turned off, all traffic will be routed to the primary server unless it fails a health check, in which case it will then be routed to our failover server.

Step 4.6. Custom rules

Set them if you want them, but feel free to skip.

Step 4.7. Review and Deploy

Before completing the creation of your new load balancer, CloudFlare will display a summary of your configuration so that you can review and confirm your settings (and make any changes if necessary).

Once you’re satisfied, click “Save and deploy” and your load balancer will immediately go live (or save as a draft if you’re not yet ready to set it live). 

You’ve now completed your Snapshot Failover setup.

Learn More About Cloudflare Load Balancers

The following articles directly from Cloudflare provide an overview of their load balancing suite of tools:

  1. Blog: Introducing Load Balancing & Intelligent Failover with Cloudflare
  2. Service Page: Cloudflare Load Balancing
  3. Learning Center: What is server failover?