Question

How does a highly scaled company serve users on the opposite end of the world?

Take Facebook for example (headquartered in California). If someone hit their endpoints from a place like South Africa, how are they routed to the nearest webservers?

I thought the load balancer would do this, but that doesn't make sense to me because how do we make sure the load balancer isn't 400ms rt away as well?

Was it helpful?

Solution

This is essentially how CDNs work. When a person in South Korea requests a given resource, the DNS server replies with an IP address of a reverse proxy located in Seoul. Another user from California will get a different IP address which may point to a datacenter in Oregon, and a user from Spain may get another IP which leads to a datacenter in Frankfurt.

While CDNs serve static content, things get more complicated with dynamic content, where a user from Korea will want to get content generated by his friend from Spain, while expecting the HTTP request to take only a few milliseconds.

One of the techniques is to replicate dynamic content in multiple datacenters across the world; a change by a user from California may be stored on only on the servers in Oregon, but also synchronized in Seoul and Frankfurt.

Another approach is to keep the content in a few geographically close data centers (say in North Virginia and in Oregon), but also proxy the content through the data centers which are closer to the users. In other words, the first person from South Korea who requests a given piece of data will have to wait for a few hundreds of milliseconds for the Seoul's data center to get the data from US servers, but further requests from other Korean users will simply load the data cached by Seoul's servers.

Licensed under: CC-BY-SA with attribution
scroll top