Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can CloudFlare perform automatic failover to a different backend?

I am looking for an easy way to fail over to a different DC quickly, does CloudFlare offer anything special in this regards with things like health checks or is it just like a standard DNS service?

like image 565
henry.oswald Avatar asked May 05 '14 17:05

henry.oswald


People also ask

Does Cloudflare have DNS failover?

Beyond reducing requests to your origin server, this setup allows your application to take advantage of Cloudflare's Zero downtime failover. When a request to one IP address fails, Cloudflare automatically retries the request to other IP addresses associated with the same hostname.

How Cloudflare Load Balancing works?

Cloudflare Load Balancing fits seamlessly into a multi-cloud environment, enabling you to avoid costly vendor lock-ins. Using a vendor-agnostic load balancer increases the fault tolerance of your architecture by safeguarding your applications from disruptions caused by any single provider.

How do I create a DNS failover?

To implement failover on the server side, you'll need to monitor all the servers listed in the DNS records—the primary server and additional redundant servers. As soon as a server goes down, the DNS server should automatically switch the DNS A record to list the IP address for the working server first.


3 Answers

Update: CloudFlare started a closed beta for the Traffic Manager feature which allows to do exactly this kind of failover:

https://www.cloudflare.com/traffic-manager/


AWS Failover:

The following solution seems to work well when you are hosting your backend system on AWS:

  1. I setup a AWS Route 53 zone with a separate domain (e.g. failover-example.com). Route 53 allows you to setup health checks on the backend server (e.g. the load balancer) with DNS failover. AWS will remove the unhealthy backend system from the DNS record list.
  2. In cloudflare I setup a CNAME for example.com record to failover-example.com and activate the cloudflare proxy on example.com.

The result is that the browser resolves the IP address of example.com to a cloudflare IP address. Cloudflare queries the AWS DNS server to lockup failover-example.com. Cloudflare fetches the content from the resolved IP address and returns the content back to the browser.

In my tests the switch to the other backend system occurs after ca. 20 seconds.

The separate domain is required because cloudflare does not route the traffic through the proxy when the CNAME is a subdomain of example.com.

I have tried to visualize the failover. In theory the failover works with any DNS failover capable service and not only with Route53:

enter image description here

The browser connects always with CloudFlare and hence a DNS failover of the backend system does never effect the browser of the user.

like image 59
Thomas Hunziker Avatar answered Oct 16 '22 09:10

Thomas Hunziker


We don't have automatic failover at this time (something we're looking at). We can support the additional DNS entries in your zone file, of course, but you would currently have to manually make the change in that circumstance.

like image 40
damoncloudflare Avatar answered Oct 16 '22 09:10

damoncloudflare


To add -- in the mean time, I'd recommend looking at https://runbook.io

Several other DIY options:

  • http://blog.booru.org/?p=12
  • https://vpsboard.com/topic/3341-running-your-own-failover-dns-setup/
  • https://github.com/marccerrato/python-dns-failover

You'd want to decide if these are the right options for you, of course.

like image 14
xxdesmus Avatar answered Oct 16 '22 08:10

xxdesmus