Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I serve a dynamic javascript file (a PHP file that echos javascript) from my webserver to thousands of websites (mainly in the USA). I want to speed things up by adding a webserver on the east coast, and one on the west coast (every millisecond counts). Then I want the closest server to be accessed depending on the viewer. Is there a service or method out there that will detect which server should serve the javascript based on the viewers location?

share|improve this question

@GruffTech, actually, OSPF is not going to work at all for his solution as it is mostly an internal networking protocol and I doubt he's going to have a private circuit between his servers placed around the world.

As GruffTech mentioned, a Content Delivery Network company would be able to do this more cheaply than you could build a proper system with redundancy, anycast, multiple data centers around the world, etc.

You could use DNS Anycast or, at the very least something like Cisco's old LocalDirector (which you can emulate with lvs). The localdirector method actually would intercept the request and balance it to the closest node based on some internal metrics. I believe the LVS patches can look at ASPath when handed a BGP feed. If you are hosted at a data center, you might find it difficult to get hold of a BGP feed. Use bird rather than quagga if you are doing BGP4 on your director. DNS Anycast would hand the surfer a DNS record that would be close to that surfer's DNS server, but, if they are using a DNS server that isn't anywhere near them, it could hand them a worse surfing experience. I'm not a fan of the redirect method, since you had their connection there already, why not just send them the small payload at that point.

Remember that Geographically close doesn't always mean Network Topologically close. A surfer in South Florida may get better service from a hub in Atlanta, GA than they would from a hub in Miami, Florida because AT&T/Bellsouth tends to shove all of their exit traffic through Atlanta.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.