If I have multiple A records for the same DNS name (i.e. example1.com has two A records of 200.1.1.1 and 222.1.1.1) and for example one server is located in Canada and the other is located in Hong Kong, will the visitor's ip address and physical location automatically be used to direct them to the closest physical ip address? If one server goes down, will requests automatically be rerouted to the other server? If this is not the case, what are some good solutions to make this happen? I'm hoping that the "Internet" and all of it's routers and DNS servers are smart enough to at least go to the closest ip address...

3 Answers
3

The case you describe is called "round-robin DNS". Client PCs will pick a random IP address from the pool that are returned to it. It is not smart like you hoped.

The kind of service you're looking for is a DNS server that does a GeoIP lookup of the incoming request and serves an IP address closest to the requesters location. There are 3rd party DNS providers that support this, I believe.

I've never used this, but I take it that all I would need is a linux server? Then I just point my domain hosts nameserver entries to this linux server once it's set up the way I want?
–
PsychoDadOct 28 '10 at 22:13

To be clear, this only solves the geo-location problem. If a user has been given the IP address of the Hong Kong server and it goes down, they will continue to use that IP address until it expires from their DNS cache. (Which may be hours.) Even then, BIND (as far as I know) has no concept of health checking, so when the user queries again, they will be return the IP address of the (still down) closest server.
–
Murali SuriarOct 29 '10 at 9:30

The problems you are trying to solve are separate, but related. Specifically, you are attempting to achieve the following two things:

Load-balancing

High availability

Load-balancing is distributing user requests across different servers. The way that users are distributed across servers can vary. To give but two examples:

round-robin - alternate between your two servers for every request

least-connections - have your load-balancing device keep track of how many connections each server is handling, and send new requests to the least loaded server

In this case, you want users to be directed to the server 'closest' to where the request is coming from. As mentioned in other answers, various DNS providers offer this service, as do DNS servers such as BIND.

High availability refers to ensuring that if one of your servers is no longer available that users are directed to an alternative. A common way of doing this is through the use of IP anycast; however, in order for this to work, your hosting provider must be willing to accept routing advertisement from you, among other things. See this question for a more in-depth discussion of anycast.