When a user searches google or bing he is automatically directed to the local datacenter, and I am wondering how is that accomplished technically. Is it some kind of DNS feature that returns a different IP number depending on the origin of the request?
I own a website and I want it to target US and UK audience at the same time (or in a similar scenario - Spain and South America). Ideally, I would like to host the site on two servers (US and UK), and direct the user depending on the country of origin. How expensive is to set it up this way? and how is it technically done? The website is not frequently updated so that the sync between the servers should not be an issue. A daily cron would suffice.
I tried to google around on this topic, but nothing found - I guess I don't know the associated terminology and the right keywords to search.
What you are talking about is called Anycast routing. This can be implemented on two different levels. One option is that the DNS server gives different IP addresses for a domain name, depending on the location of the computer which issued the request. The other possibility is that only one IP address is assigned to a domain name, but that the routers in the Internet backbone have different routing destinations in their routing table for that IP address, depending on the geographical location of that router.
One IP address which is routed differently to different location is only possible if you have direct control over the routing tables in the Internet backbone via the BGP protocol. Practically spoken this is out of reach for the average webmaster. You need to be at the level of an ISP with your own assigned IP blocks before you can start to think about such a solution.
Easier to implement is having two different servers with two different IP addresses, where the DNS server returns a different IP address, depending on the source of the query. This can't be done by most DNS servers though. To do this you need some global specialized DNS service provider which has implemented that service for you. There are not many, but you may find some via Google or Bing by searching for anycast dns provider. These DNS providers are for the high end market and ask therefore also high end prices. Some DNS providers claim they do anycast routing, but in fact they only use anycast addressing for their own DNS servers but have no service to dynamically route client addresses based on location.
A third option is something in between. Your main server is in one location, but that server only provides the base HTML pages. All static content is served via a CDN provider (Content Delivery Network). In this case the response time of the HTML page itself may not be optimal for remote clients, but all site furniture is served from a computer close to the visitor and can therefore be loaded very fast. CDN providers used to work only with top-notch clients, but they have entered the lower end markets a few years ago and you should therefore be able to find some competitive offers. Just be sure that the provider you choose has a CDN server in all the areas you want to cover.