1

I've been reading about DNS failovers and a bunch of other technical terms however I'm a bit of a newbie in this so it all sounds Greek to me. Basically here's what I just need:

I have two shared hosting accounts from two different providers (Server A and Server B). Each of this accounts contain exactly the same website content.

On a normal day, typing my domain name should point to the IP of Server A. But on a bad day in which Server A is down or unreachable, my domain name should point to the IP of Server B in the fastest way possible.

How do you achieve this and what services can you recommend if any? Thanks.

Note: this question has a follow-up question: DNS Round Robin: Multiple Nameservers VS Multiple A Records?

IMB
  • 499
  • 2
  • 7
  • 13
  • 1
    related: [When my A web server gets unplugged, how do I automatically redirect all the users to my B web server in another city, and vice versa?](http://serverfault.com/questions/383497/when-my-a-web-server-gets-unplugged-how-do-i-automatically-redirect-all-the-use) – David Cary Jul 04 '12 at 14:05

2 Answers2

3

The simple answer is to use a content distribution/delivery network to handle your traffic. They already have the infrastructure in place to handle failover like this.

If you must host it yourself, one route to take is this:

  • Set the DNS TTL very low
  • Set up a server which monitors the web servers
  • If one of the web servers goes down, automate a script on the monitoring server to modify the DNS and remove the failed server

My first recommendation is still to use a CDN, though.

Hyppy
  • 15,458
  • 1
  • 37
  • 59
  • Thanks for the reply. Can a CDN be used as a host for an entire website? I thought it's only used for storage. – IMB Mar 25 '11 at 19:53
  • CDNs are generally best for static content (HTML, JS, CSS, images, etc), but some CDN hosts offer whole site delivery for sites with server-side applications. It's not cheap, though, but 99.999% uptime never is. – Hyppy Mar 25 '11 at 20:03
  • If that's the case then I would need a CDN that offers whole site delivery because a normal CDN implementation will not achieve my goal right? – IMB Mar 25 '11 at 20:19
  • I don't know. Do you run any server-side applications? – Hyppy Mar 25 '11 at 20:22
  • Yes, PHP MySQL. – IMB Mar 25 '11 at 20:25
  • Then yes, you'll need whole-site CDN service for that to work, though beware that it's a fairly new technique. I don't think MySQL is supported at all, though. – Hyppy Mar 25 '11 at 20:25
  • I see, Ok I was Googling for a couple of CDN providers and can't seem to find one that offers even plain HTML serving as a main host. Can you recommend a provider which does whole-site? – IMB Mar 25 '11 at 20:34
  • Akamai provides application acceleration services – Hyppy Mar 25 '11 at 20:37
  • Thanks however looks like Akamai is quite expensive. Can you recommend a service that provides your second suggestion? :-) – IMB Mar 26 '11 at 09:40
  • 2
    Search for 'DNS failover'. Some companies offer it inexpensively. – Seun Osewa May 09 '11 at 04:49
  • https://en.wikipedia.org/wiki/List_of_managed_DNS_providers – isync Dec 16 '15 at 13:34
0

It will never work only with shared hosting accounts. You will need something intelligent to handle outages. There is many options:

1. CDN as wrote @Hyppy

This is simplest and we can say cheapest solution for static content. You will upload you static content (js, html, images and so on) into CDN and it will distribute it across the globe. You have high availibility for your content and your visitors will download your content from nearest servers, not across the whole Internet. CDN cannot serve dynamic content (ok, some like Akamai can, but it's expensive and cannot provide everything)

2. Loadbalancer

You would set up your own server as loadbalancer using HAProxy. You'd point your DNS records to the loadbalancer and the loadbalancer will route traffic to target servers. Loadbalancer can manage load distribution when all servers are ok and disable traffic when some servers die.

If you need HA, you should have more loadbalancers in backup using virtual IP (using something like KeepAlived). This is quite simple to achieve if both of your loadbalancers are on same network, but it is quite difficult if you want to have those loadbalancers in different providers (you will end up with something called multihoming AS, your own IP subnet and another stuff). You can use specialized hardware as loadbalancers, like appliances from F5.

This is an expensive solution in terms of buying, but can be cheaper than CDN in terms of TCO and you're not limited in terms of what you handle.

Michael Graff
  • 6,588
  • 1
  • 23
  • 36
Ondra Sniper Flidr
  • 2,623
  • 11
  • 18