Could a name server resolve IP addresses dynamically based on some strategy?
We have registered some name servers for DNS resolving for our website which is deployed in several data centers.
Our current strategy of DNS resolve is that based on the different client IP addresses, the name server will return different IP addresses for the same domain. For example, if the client IP address is from North America, the name server will return an IP address which is the IP address of our North America data center.
But the client IP address sometimes is not the real IP address of the users. It may be an IP address of DNS which belongs to an ISP or a proxy server. On the other hand, if one of our data centers is down, we want our name server exclude that IP address which belongs to the crashed data center. So we hope that we can get a more dynamic strategy for our DNS resolve. Is there a solution for that?
Solution 1:
It sounds like you want anycast. That is the type of thing that sites like Google use. You have a single address (resolved by DNS) for all your web sites, and you let the Internet routing protocol (BGP) direct the users to the nearest (by the routing protocol) site. If a site goes down, the next closest site is placed in the Internet routing table automatically by BGP.
The classic example is 8.8.8.8
for DNS. It resolves to different locations around the globe, and if one location goes down, then it goes to the next closest location.
The answer is not DNS, it is routing.
Solution 2:
What you need is exactly what Amazon Route53 DNS service offers:
Latency based routing - Route end users to the AWS region that provides the lowest possible latency.
Geo DNS - Route end users to a particular endpoint that you specify based on the end user’s geographic location.
Health Checks and Failover - Amazon Route 53 can monitor the health and performance of your application as well as your web servers and other resources.
... and many more advanced DNS features.
You don't have to host your website on AWS to be able to use Route53, it will happily work with services deployed across private datacentres.
Unless you're a Facebook or Google pricing shouldn't be an issue either, starting from $0.40 per million requests (see pricing details).
Hope that helps :)