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?
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:
My first recommendation is still to use a CDN, though.
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.