There are two alternate views of this question, and it's one that is ultimately going to be debated forever. I'm not going to give my opinion (because I'm torn myself), but the general arguments each way typically are:
You should define A records for your physical machines, and then CNAME services onto those machines. This does make it rather clear as to what is what, and in the event that you need to renumber there's not a lot of records to change -- just the machine records. On the other hand, it does increase your DNS lookup load somewhat, and "auxiliary" IPs (think SSL vhosts) don't fit neatly into this model.
The literal meaning of "canonical name" (CNAME) is to define strict aliases of the same name (think mail
and smtp
), and if you have multiple services running on the same machine they should all have A records, because it reduces load on DNS and some services (NS records and, to a lesser extent, MX records) really aren't impressed with dealing with CNAMEs, so if you have to handle those services differently anyway, we may as well do it for everything.
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
Best Answer
I'm afraid you cannot do what you are asking directly unless you want HTTPS traffic to go to e.g. secure.example.com instead of www.example.com.
The only solution would be to put a proxy/firewall/load balancer device in front of your webservers that forwarded on traffic to the different IP addresses based on the protocol used.