A failover group is a managed, quick-response DNS address that automatically follows your application's web endpoints.
You can connect it to up to two instances of an application at any time - a primary and backup instance. Should you need to switch traffic between your instances, you can flip a switch and your traffic will begin flowing to the backup instance within 5 minutes.
What you'll need
Before you start, please check you have the following:
- A Cloud 66 Account — If you don't already have one, sign up for a Cloud 66 account. You'll get free unlimited access to all products for 4 weeks.
- An existing application set up in Cloud 66 — To make the most of this tutorial you need to have an app already set up in Cloud 66. Follow our Getting Started guide if you're not sure how to do this.
Creating a failover group
To add your first Failover Group:
- Click the Failover Groups link in the right-hand panel of the main Dashboard page.
- Click the Add a failover group button
- Select your Demo-app as the Primary Application
- Leave the Backup Application set to "No Secondary application yet"
You'll now be taken to a list of your Failover Groups, and you'll see the Group you just set up.
Notice that the group has its own unique domain, separate from your application servers. If you click on that domain, you will reach the same application that you created by following our Getting Started guide.
This is the power of Failover Groups at work - the public CNAME for your application can stay static while the underlying servers change within a matter of minutes.
Adding a secondary application
In order to properly use a failover group, you need to have a second instance of your application running somewhere.
The simplest way to do this is to clone the demo application. To do this:
- Open the Overview page for your application
- Click the Clone button below the Application panel on the right of the screen
- Name the clone you're about to create
- Click "Create Clone and follow the process to deploy the Secondary instance of your application
Once your Secondary has been successfully deployed:
- Navigate back to the Failover Groups page
- Click on the edit icon the the right of your only failover group
- Set the clone application you created above as your *Backup Application using the dropdown.
- Click Update Group
You'll now see that your failover group has two radio buttons - one for each of your application instances - and that the button for your Primary instance is green. This means that it is currently receiving traffic while the Secondary is dormant.
Switching between instances
To switch between application instances in your failover group:
- Click on the (grey) radio button of the Secondary instance.
- A pop-up will open warning you about what is about to happen.
- Click Switch Traffic Now to start the switching process.
After five minutes traffic will begin flowing to the Secondary instance.
You can test this by visiting the failover address. The count of visits on your Secondary instance will be different from your Primary application. You can double check this by visiting the direct address for your Primary and comparing the visit counts.
How failover groups work
A failover group follows the web head of your application. In other words it points at your load balancer or, if you don't have one, your web server.
A failover group will automatically update to point at any newly added load balancer. Similarly, it is automatically updated when you rename your application or change your web servers.
A great way to test this is to use the
dig command in your terminal, for example
dig 414-262-781.cloud66.net, which allows you to see where the DNS is pointing.
Requirements and limitations
- You don't need to select any applications for your failover group. This allows you to reserve the address provided for future use. This is particularly useful when you want to keep address the same.
- Having a backup application is not mandatory.
- You can only delete a failover group when it isn't pointing at any applications.
- Once you delete a failover group, the DNS record for it is permanently deleted and you won't be able to get the same address back.
Why use failover groups?
There are two major use cases for this:
By building and nominating a secondary backup on a different cloud provider or data center you can use a failover group to switch your visitors from the Primary to the Backup instances of your application with ease.
If you need to clone or rebuild your application, you can use a failover group to switch your traffic to the backup instance without interruptions to your service.
There is an environment variable called
FAILOVER_STATUS with three different values:
online- traffic is flowing to this application
offline- traffic is not flowing to this application
none- this application is not part of any Failover Group
This variable allows you to configure notifications and other jobs on both applications that will only run for the app that is currently online.
Why use Failover Groups?
There are two major use cases for Failover Groups:
- Application resilience
By building and nominating a secondary backup on a different cloud provider or data center you can use a failover group to switch your visitors from the Primary to the Backup application with ease.
- Cloning applications
If you need to clone or rebuild your application, you can use a failover group to switch your traffic to the new application without interruptions to your service.
How Failover Groups work
A Failover Group follows the web head of your application. In other words, it points to either your load balancer or your web server (if you don't have a load balancer).
A Failover Group will automatically update to point at a newly added load balancer. Similarly, it will be automatically updated when you rename your application or web servers.
Using Failover Groups with SSL certificates
One of the challenges of switching to a backup instance of an application is SSL certificates:
- If your certificate is not kept updated on the backup, then switching traffic over will result in errors and prevent your customers from reaching your app.
- If you're using Let's Encrypt, your SSL certificate on your backup stack can't be created or renewed because it doesn't actually receive traffic via your public (external) domain.
To solve these issues, Cloud 66 automatically handles the transfer of your SSL certificate(s) when you switch between your primary and backup applications (or visa versa). However for this to work correctly ONE of the following conditions must be met:
- Your backup application must have no certificate installed
- The certificate on your backup application must declare the same server names as the SSL certificate on your primary application
This applies to both custom certificates (i.e. from a third party supplier) and to Let's Encrypt certificates.
SSL certs are not renewed on backup apps
Since your backup application is, by definition, not receiving traffic while your primary application is active, we will not automatically renew your Let's Encrypt SSL certificates on the application which is acting as a backup. It will be transferred and resume automatic renewal when you switch using your Failover Group.
Testing Failover Groups
A great way to test Failover Groups is to use the
dig command in your terminal, for example
dig 414-262-781.cloud66.net. This allows you to see exactly where the Cloud 66 DNS is pointing.