For our SaaS web-app we have two identical servers in two geographically separated data centers.

FOO_1 is the production server and does real-time (MySQL master-slave) replication to its backup F00_2. We want our users to always go to THEFOO.COM which somehow points to the production server.

So even if FOO_1 dies, we can just switch THEFOO.COM to redirect to FOO_2 so the failure is transparent. This switch can be manual or automatic but without failback (if FOO_1 somehow becomes available again).

Is there a way to do this with DNS? I am getting stuck with ANAME and CNAMEs configuration. We don't use sub-domains, just straight domains.

If not, what are other options? Does it make sense to just have a web server at LOVELY_FOO.COM and just redirect all traffic? I also looked at load balancers but didn't see a solution for across data centers/network providers.

  • Anycast might be what you're looking for. Jun 6, 2014 at 23:42

3 Answers 3


You can, as you mention do this with a reverse proxy front-end.( EG apache ) Similarly, a web application firewall (e.g. sophos / astaro web proxy ) could provide fail-over (and also other goodies you might want in addition, like various web application security features.


Just use an A record. It maps thefoo.com to any IP address. So under normal circumstances, it will point to foo_1's IP. If foo_1 goes down, you change the A record to point to foo_2's IP.

Keep the TTL short to make sure the change propagates quickly. Some DNS providers offer automatic failover as a service (Amazon Route53 being an example).

  • 2
    Every time somebody says "DNS propagates" on Server Fault, the Flying Spaghetti Monster kills a kitten.
    – MikeyB
    Jun 7, 2014 at 8:21

You can do this thought a global load balancer. We have a few F5 gtms that handles this traffic. This is done through DNS and based upon configuration you can determine which record is given to the client. You can buy this service if you can't host your own gtm's.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.