FAQs Regarding DNS
It seems that these types of questions are asked almost daily, so I thought I would write a brief FAQ on commonly asked DNS questions. Here we go:1) I want to establish a basic fallover solution using multiple A records. Won't DNS clients automatically eliminate down servers from their selections?
The answer is no. most common DNS clients/caching nameservers will not do any type of host selection based on if that host is available or not. The reason? How would DNS clients/caching nameservers be able to tell which application is being used, and if the host is online?
DNS clients/caching nameservers will usually simply pick a single A record out of a group of multiple A records at random. That DNS client/caching nameserver will then cache that result for the length of time set by the TTL value for that A record.
To implement a fallover solution using round robin dns(RRDNS) some sort of manual/automatic editing and publishing of your DNS zone files will be needed incase a host goes offline. By setting low TTL values(300 seconds or so), and writing a shell script that monitors each application server you can effectively create your own "load balancing" system with RRDNS.
However, it is very important to mention that the application that will be using this type of load balancing cannot rely on session affinity between a specific server and client. What this means is that if your application uses server side sessions it will most likely break when your client is redirected to another application server in the cluster.
2) I have multiple MX records, why does some mail get delivered to my secondary record even though the TTL is set really high?
This is a result of *broken* MTA(Mail Transfer Agents) using only the secondary MX for delivering mail. The most common uses of these clients are in sending SPAM and viruses, as the sender is betting that your secondary MX server will not have Virus/SPAM filters running on it.
There is really nothing you can do about this, short of running just one MX record. Plan on having your secondary MX record receive mail even when the primary is online.
If your setup is configured correctly this should not be a problem as the backup MX should simply forward the e-mail directly to the online primary.
3) I have two nameservers setup at my registrar: ns1.mydomain.com and ns2.mydomain.com . I am going to use ns2.mydomain.com as my backup server, as it will have the "backup" zone files installed on it. These backup zone files will point to my backup cluster. I will get 100% uptime, right?
Well, in a way, yes.
Contrary to popular belief, both of your nameservers(ns1 and ns2) will receive approximately an equal amount of DNS requests. So, in your example above, ns2.mydomain.com will return the set of backup A records approximately 50% of the time.
Now, for most people this is exactly what they don't want. Even though your primary site is online, ns2 is merrily directing clients to the machines defined in your "backup" zone files. BAD News.
DNS clients/caching nameservers will query all of the published nameservers for your domain(often called authoritative nameservers) and equal amount of the time. Some clients get fancy and will query the nameserver that has returned the fastest results, however, don't bet on all clients doing this.
In short: Have all of your nameservers publishing the same information. Refer to question #1 above on information on how to do RRDNS fallover with a custom written script and low TTLs.
I am sure I will think of some more FAQ, however, please feel free to post on this thread in an effort to help people in the future.
Peter