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.
vCanopy’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 vCanopy
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.
- Source Server: Select the server you wish to backup
- Failover Server: Select the server you wish to use as your backup
- 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:
- Create a load balancer
- Manage monitors
- 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
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:
- Give your monitor a name
- Leave the default HTTP check, and if you wish, set a more lightweight page than the homepage to monitor.
- Interval: 60
- Method: GET
- Timeout: 10 seconds
- Retries: 2
- Expected codes: 200, 301, 302
- Follow redirects: Check (yes)
- 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.
- Pool Name: Give your origin pool a name (E.g. Primary-Server)
- Description: Add a description if needed.
- Origin steering: Leave as the default.
- 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:
- Blog: Introducing Load Balancing & Intelligent Failover with Cloudflare
- Service Page: Cloudflare Load Balancing
- Learning Center: What is server failover?