Can CloudFlare perform automatic failover to a different backend?

henry.oswald picture henry.oswald · May 5, 2014 · Viewed 15.6k times · Source

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?

Answer

Thomas Hunziker picture Thomas Hunziker · Jul 3, 2015

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.