The Goal: to make the client's web browser select the next available server if one is down instantly.
That's generally done by introducing a 3rd server, called a load balancer. The load balancer:
- Directs traffic to the 2 web servers.
- Monitors the health of the 2 web servers.
- Switches traffic to the remaining web server if one fails.
The load balancer itself can be made highly available by using 2 load balancers (LB), i.e. at least 4 servers (2 LB's, 2 webapp servers) in total. However, many smaller shops run with just one load balancer, because they are relatively simpler systems, and will often be very reliable.
Method 1: Do I set my nameserver entries at Godaddy like this?
1. ns1.serverA.com
2. ns2.serverA.com
3. ns1.serverB.com
4. ns2.serverB.com
Absolutely not. The name servers are only used for resolving the IP addresses of the web servers. Keep the name servers for the domain to your registrar/DNS host (GoDaddy) defaults.
Method 2: Or do I make Godaddy as my nameserver and add A Records like this:
1. A @ 1.1.1.1
2. A @ 1.1.1.2
3. A @ 2.2.2.1
4. A @ 2.2.2.2
When DNS Round Robin (DNS RR) is used as part of a high-end failover / high availability setup, then the IP addresses the DNS RR points to are highly available. In other words, each IP address is a virtual IP handled by 2 devices. As a pure high availability solution, without higly available server IPs, DNS RR doesn't work too well. The basic problem is that some clients may continue to use the 'dead' IP address, you're relying on the client doing 'the right thing', and not all clients do. Using a real HTTP load balancer is better.
That said, many small websites use DNS RR for load distribution only with good results. It's all about your expectations I guess.
In the DNS RR case, having 2 IP addresses per physical server gives you nothing, only extra complexity. So just use one IP for each server, in your notation:
A @ 1.1.1.1
A @ 2.2.2.1
If you place the load balancing function outside your wan links such that it has its own public ip address(external to your network) to point your clients at, you can configure it to reverse-proxy to services at both your wan link ip addresses. Such a design would make for load balancing and failover without bgp.
I guess you could co-locate a redundant load balancer, use a cloud service or similar, as long as you procure for very high uptime. You would ideally want it to be more reliable than both your wan links when seen as a bundle.
Best Answer
The name server solution is the simplest option, but you must set the TTL according to your needs. There are a lot of discussions regards TTL. We are using name servers with low TTL from several years and this solution works well for us, but if you want a real and prompt failover system you must go on more complex solution like BGP, if your ISP support it.
Little sample (with very simple TTL explanation) of failover by name servers.
Type A record in both dns server: www.domain1.com 1.1.1.1 TTL 10 (1.1.1.1 is the public ip of primary ISP)
When primary ISP fails you must change the A record of www.domain2.com to 2.2.2.2 (where 2.2.2.2 is the public ip of failover ISP).
TTL tells to client (browsers and other name servers) around the world that the ip address for www.domain1.com is valid for 10 seconds. After 10 seconds the client must re-ask ip to name server.
This link can explain better, also why this is not a perfect solution.