How can I force users from USA to go the USA server and visitors from UK to go to the UK server

Solution 1:

And why companies like google have a different domain for each country?

Because it makes it easier to have SEPARATE CONTENT for every country. Content should be static - so if you want English and for example Spanish pages to be indexed, they must have separate url's. One way is example.com/en - the other is en.example.com. The later scales better.

First of all is this possible?

Not for you. You need a provider that supports anycast routing.

To do it yourself you need your own internationally routed IP addresses - which are impossible to get for a normal user as the smallest block assigned is more than 4000 addresses (which you must USE) and the costs are high.

If you would get one you would get routing as an AS (Autonomous System) and just publish routes going to the closest server.

So, not for you. But some hosts may support it.

CDN's do it - so you can definitely move your static stuff off to a content delivery network.

What you can do is country prefixes, and then redirect to them from the main domain.

Solution 2:

+1 for anycast routing as "the real solution".

An easier alternative is to provide different DNS records per continent. Amazon sells this as Latency Based Routing but I assume other large DNS providers offer similar tools.

Solution 3:

Some people have mentioned CDNs as a solution. You don't really need that. All you need is for the authoritative DNS server for your domain to pick the optimal server for a given user based on where their DNS request is coming from (and potentially what the current load is). Akamai, for example, while also the largest CDN, offers a product called Global Traffic Management that is completely separate from its CDN offerings that provides this very service (for a fee). It accomplishes this by becoming the authoritative DNS server for the various domains you administer, and then for incoming DNS requests, it then hands out the IP addresses of your web servers, correctly accounting for load and locality.

If your servers can't handle your load (and you don't want to buy and administer more), that's when you want a CDN, but it doesn't sound like that's your problem.