views:

254

answers:

4

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 :)

A: 

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.

Jeff Moser
SO, let's say a request comes in from client C to my "proxy" server P, I notice that server X is closest to C so I forward his request to X. But doesn't that mean that all traffic comes into proxy P, then I rout it to closest servers? If P is in New York, does that mean Tokyo traffic comes to NY, then NY forwards each packet to the closest server in Beijing? How can the proxy tell Tokyo to talk to Beijing, then get out of the loop?
Shahbaz
The first time a C wants to connect to your server, he'll do a DNS query to his local DNS. His local ISP's DNS server won't have the IP address, so the ISP's DNS will send a UDP DNS request to your name server. For simplicity, assume that his ISP's DNS is near him. Then, based off the source IP address of the DNS query, decide what specific IP to send back for his DNS query. This is a one time per session thing. From that point, the client connects directly to the IP. No forwarding needed.
Jeff Moser
Jeff's second answer (one with DNS info) is closest to what I was trying to understand. I don't get everything, but have some more relevant keywords to google. I apparently can't flag non-parent comments though. Thanks!
Shahbaz
The following Security Now ( http://www.grc.com/securitynow.htm )podcast episodes might be helpful in understanding what's going on and how this solution would work: 25, 26, 155, and 157
Jeff Moser
A: 

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...

Justin Niessner
A: 

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.

gahooa
A: 

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.

psanf