26

If I have a single domain with visitors from both USA and Europe and also have 2 servers, one in USA and one in UK, how can I force users from USA to go the USA server and visitors from UK to go to the UK server in order to reduce the ping of visitors?

First of all is this possible? And why companies like google have a different domain for each country?

ETL
  • 6,691
  • 1
  • 32
  • 49
Luka
  • 381

9 Answers9

22

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.

TomTom
  • 52,109
  • 7
  • 59
  • 142
13

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

mschuett
  • 3,216
11

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.

8

You can use anycast routing. Google, for example, has DNS servers like 8.8.8.8, which are different servers depending on where you are.

You can also use a content delivery network for your static data.

And different domains for each country provides you with other advantages, but that is not going to help you if all your visitors use one domain, of course.

Halfgaar
  • 8,534
3

You could also look into Load Balancing based on Location proximity. Alternatively check out delivery accelerators like Fastly.

Peter
  • 131
2

What you need is geographic load balancing. It's a very hard, non-trivial problem. The accepted answer is incorrect. You can do it. There was a page I saw a while back with a script that measures users ping and sends them to the nearest server. I THINK this was it: http://www.austintek.com/LVS/LVS-HOWTO/HOWTO/LVS-HOWTO.geographically_distributed.html

Also, F5 Networks sells a geographic load balancing router, but it's expensive.

Chloe
  • 1,184
2

You can use DNS server which will bring visitors from each region to different computer.

Possible duplicate question as: Is there any DNS that supports Geo-location / Directional DNS?

1

You can take a look at http://www.neustar.biz/services/dns-services/managed-dns-packages too. the Enterprise package supports something they call Regional Routing that would be your solution I guess. Same as mentioned before with Akamai offer, the DNS service is smart enough to point to the geographically closest IP.

Piotr
  • 19
1

If you are looking for a load sharing solution, then I would recommend Cloud based hosting/Cloud Service Providers.

The Cloud Hosting Servers are designed in a way to do the exact same process as you required by routing to the most nearest host cluster.

Hope this may help in some way.

krisFR
  • 13,690
Tarique
  • 11