If I have 3 servers for my website, how would I direct users geographicaly to the right place?
The main server is in Australia, but content is synced to a US server. As someone in the uk my ping times to the US server are under 100ms, but Australia is 300-600ms.
What are my options for directing traffic to the correct server?
- Wide IP?
- Detect and lookup IP on the first server they hit and then redirect to another domain?
How do Googe do it?
The best way IMHO is to recompile BIND with GeoDNS patch
then you can control clients by views i.e.
view "north_america" {
Google does it using a technology called "anycast". They use the same IP assigned to multiple machines that are placed around the world. Long story short, the least expensive according to the BGP system, and often shortest path is used.
Normally multiple paths to one IP are exported when multihoming... more than one ISP comes into your network, so there is more than one way to get there. You take the cheapest / fastest path in. With anycast, everything happens the same way, but the different paths lead to physically different machines in far away places instead of just more than one way to the same machine. To the end user, it doesn't matter because the content they get from any of them will be the same.
Because this trick takes having a BGP id and at least a /24 block worth of addresses that you won't be able to use for anything else, you probably won't use their solution. You can contract this out for static content via Akamai Technologies, and probably several other companies as well. I don't know if any providers will handle dynamic content in that way.
You can use a service such as MaxMind's GeoIP as well. That may be the most cost-effective, but you'll have to do some upfront coding to redirect your users based on checks against the IP data. Note that they do offer a free database, and for the country-level direction, that's probably good enough. Disserman's BIND patch idea may also work out just fine, using DNS replies to direct people instead of redirects. This could get confusing for some very technical users, or when debugging strange issues where different hosts think the same name points different places.
The latter approach will work and is in fact used by lots of servers but you could also consider global load-balancing as this will fix this problem and also help with business continuity.
I'd advertise the second option, coupled with a GeoIP lookup to redirect to the closest server.
If the website is identically served by the three servers, make it transparent and do not redirect. It does not make sense to have identical content on different domains.
Also, the techniques used to do that will let you fail-over if one of the servers fails.