Search code examples
dnsgeolocationserverload-balancinghigh-availability

domain name to IP/Server mapping as per geolocation


Say I have a domain called example.com now there are two clients trying to connect it

+----------+                                      +-------------+
| Client 1 |\                                     |             |
+----------+ \            +--------------+        |             |
(East Asia)   \---------> |              |        |             |
                          | example.com  | <--->  |   Server    |
              /---------> |              |        |             |
+----------+ /            +--------------+        |             |
| Client 2 |/                 (DNS)               |             |
+----------+                                      +-------------+
(North America)                               (sample application 
                                       server located in North America)

This causes big latency for clients in East Asia what I would like to have is:

                                                  +-------------+
                                                  |             |
+----------+                                      |  Server 1   |
| Client 1 |\                                /--->|  (Asia)     |
+----------+ \            +--------------+  /     |             |
(East Asia)   \---------> |              |-/      +-------------+
                          | example.com  |        +-------------+ 
              /---------> |              |-\      |             |
+----------+ /            +--------------+  \     |  Server 2   |
| Client 2 |/                 (DNS)          \--->| (N America) |  
+----------+                                      |             |
(North America)                                   |             |
                                                  +-------------+

My application is not using standard HTTP its a custom protocol in TCP and needs to maintain connection with the client.

How can I do this kind of mapping based on geo-location on same domain name.


Solution

  • Given the distributed nature of DNS, what you're asking for is really not easy to do (consider for example the case where both Client 1 and Client 2 are using Google's public resolver at 8.8.8.8 to do their lookups). If you really want to go that way, start looking at the web pages of the major DNS-server service companies and see if any of them offers it.

    A probably much cheaper and easier alternative is to add a step to your application, where your server checks where the connecting client is coming from and can tell the client software "Go talk to this other server instead of me".