Question

I'm a Java coder and not very familiar with how networks work (other than basic UDP/TCP connections)

Say I have servers running on machines in the US, Asia, Latin America and Europe. When a user requests a service, I want their request to go to the server closest to them.

Is it possible for me to have one address: mycompany.com, and somehow get requests routed to the appropriate server? Apparently when someone goes to cnn.com, they receive the pictures, videos, etc. from a server close to them. Frankly, I don't see how that works.

By the way, my servers don't serve web pages, they serve other services such as stock market data....just in case that is relevant.

Since I'm a programmer, I'm interested to know how one would do it in software. Since this is little more than an idle curiosity, pointers to commercial products or services won't be very helpful in understanding this problem :)

Was it helpful?

Solution

One simple approach would be to look at the first byte (Class A) of the IP address coming into the UDP DNS request and then based off that you could deliver the right geo-located IP.

OTHER TIPS

Another approach would be a little more complicated. Instead of using the server that is geographically closest to the user, you could use the server that has the lowest latency for that user.

The lower latency will provide faster transfer speeds while being easier to calculate than geographic location.

For a much more detailed look, check out this article on CDNs (pay attention to the Technology Section):

Content Delivery Network - Wikipedia

These are the kinds of networks that the large sites use to distribute their content over the net (Akamai is a popular example). As you can see, things can get pretty complicated pretty quickly with CDNs having their own proprietary protocols, etc...

Update: I didn't see the disclaimer about commercial solutions at the end of the original post. I'll leave this up for those who may find it of interest.

--

Take a look at http://ultradns.com/. A managed DNS service like that may be just what you need to accomplish what you are looking for.

Amazon.com, Forbes.com, Oracle, all use them...

Quote From http://ultradns.com/solutions/traffic.html:

UltraDNS Traffic Management solution provides a set of tools allowing IT administrators to define load balancing configurations for content servers residing in one or more geographic locations. The Traffic Management Solution manages traffic directed to the servers by dynamically changing the responses to DNS requests. Load balancing is performed based on dynamic metrics obtained from the host servers on a continual monitoring basis. The UltraDNS Traffic Management solution is not a single application, but combines the capabilities of several existing UltraDNS systems to control traffic, manage site failures, and optimize web content systems.

One approach is, as Jeff mentioned, using the IP address: http://en.wikipedia.org/wiki/Geolocation_software

In my experienced, this is precise to the nearest relatively large city (in the US at least). There are several open databases to aid in this (see the wiki link). Then you can generate image tags and download links and such based on this information.

As for locating the nearest server, I'm sure you can think of a few ways to do it. For instance, if the best return you can get is major city, you can lookup that city in a list of Latitude/Longitude and calculate the nearest server based on that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top