10

I have a website which is developed by using ASP.NET and MY DB is MySQL. Currently it hosted in USA Servers. But When I try to access it near India dynamic contents are loading too slowly. It is acceptable since request has to go to another side of the world. In USA its really fast. I already connected this site with cloudflare CDN. But CDN is useful for static contents. My every pages almost have dynamic contents.

So I want to scale this website. So if a request came from America I want to handle that request from USA server and If a request came from ASIA I want that to handle from an ASIAN Server. But keep in mind no matter where they were redirected content should be same on two servers. ( Two servers should be sync )

So how to achieve this architecture?

How google, Facebook,Yahoo do this? How they serve world wide? I think they have datacenters on every continent. How they sync with each other?

3 Answers3

11

In addition to what answered by @Gabriel-Talavera, I'd add a couple of notes:

  • Network routing, as well as Geographical Load Balancing, is totally unrelated to "data synchronization" between different servers. They are two problems addressed with plenty of very different technologies.

As the title of your question seems to be focused on the networking side, I'll focus on the first part (the network routing issues).

As you can see by yourself, requirements are hard to be met by small ICT companies. But "global" companies (like the ones you mentioned in your OP), will have no problem adopting it.

As a side note, the first time I heard about "anycast" was thanks to a CloudFlare BLOG post, where they discussed (...among lots of other things), how anycast can be also adopted as a counter-measure to D-DOS attacks.

Damiano Verzulli
  • 3,948
  • 1
  • 20
  • 30
3

You can give selective DNS responses based on location with BIND Views if you are using BIND as your external DNS server. The Technical Preview of the new version of Windows Server also has a feature called DNS Policies which looks very promising.

To serve content based on client location and other criteria such as User Agent or schedules, F5 has an appliance called Global Traffic Manager which used in conjuntion with their load balancers achieves what you are looking for. In Cloud environments, Amazon's Route 53 can accomplish the same.

In order to keep the data in sync you must have a storage backend capable of do synchoronous replication, or use the replication provided by MySQL, which will keep the replicated data consistent.

Gabriel Talavera
  • 1,367
  • 1
  • 11
  • 18
  • but this will not work reliable if the clients use different DNS servers like Google DNS or OpenDNS. – Josef Aug 11 '15 at 15:11
  • Replication with mysql can show significant lag between writes and that data being available for reads. Something which scales replication like riak or other nosql databases should be considered. – chicks Aug 13 '15 at 11:27
0

There are situations where you would like to have:

  • The data integrity guarantees of serializable transactions.
  • Data can be updated by users globally.
  • Data can be updated with low latency.

Unfortunately the combination of all of the above is not physically possible. You will be constrained by the speed of light.

Instead you need to consider your exact requirements. For some data, limited accuracy is good enough. Consider the view counter on a YouTube video. Most people don't care if the view counter is temporarily a bit off. If views which happened 10 seconds ago on the other side of the world are not included yet, but views that happened 5 seconds ago closer by are included, it is still accurate enough. If you are that relaxed with the integrity of the view counter you run the risk that two different persons may both think they were viewer number 100 of that particular video. But most people would consider the harm done by that to be negligible.

In other cases data integrity is more important. Consider two persons simultaneously trying to sign up with the same username. Telling both persons that they got the username is not acceptable, so in such a situation you would choose a slower approach with better integrity. It is acceptable to tell both persons that the username was taken, so a possible approach would be to try to reserve the username on each replica and only report success if you succeeded on more than 50% of the replicas. It is not unlikely that this approach would have the user wait for half a second to get a reply. But users don't go through this process often enough to be bothered by that delay.

In yet other cases you may need good integrity and fast updates, but only one person can update this particular piece of data. In that case you can put the authoritative copy of the data on a server you think is close to that user, and let other servers have a cached version, which is mostly up to date.

kasperd
  • 29,894
  • 16
  • 72
  • 122