Why do I need a Geo-distributed site?
If you are serving to a global audience (or even an audience across geographies), it is very desirable to have your site geo-distributed to enable you to serve your site to users from closer to their location. So, instead of a site being hosted in a set of servers in one location, you host a set of servers in a set of locations which are geographically distant and strategically chosen to be closer to the biggest user clusters’ locations.
Typically, these are known as mirrors. Mirrors are used by all global sites, especially all sites enabling file transfers/downloads. In fact, these sites let you choose your mirror for download to rule out any error while automatically selecting a mirror for you when you first visit.
What does it mean for my user?
It is entirely invisible to a normal user and he doesn’t normally figures out which mirror is he/she being served the site from. He/she still gets pages served on the same domain name and the same URL’s. Technically, someone would basic computer science and networking know-how would know or be in a position to find out the difference in mirrors.
How would this work?
A typical process of first-time requesting a page from a website includes the following steps –
- User’s machine requests its ISP’s DNS servers for the location of the site
- User’s ISP’s DNS server sends out a request to site’s DNS server for the location of the site
- Site’s DNS server provides to the location of the site (in form of an IP Address)
- User’s machine requests the site location for the page
The trick here, in geo-distributing this site, lies in 2nd step. This is enabled by a Anycast DNS service. What that means is – a set of identical DNS servers therefore, when a nslookup (the basic networking request to resolve a domain name) is done on a domain name, the user’s ISP’s DNS server would send back the location it receives from the site’s DNS server which responds before the others – typically the closest DNS server.
All the site’s DNS servers carry different locations of the site hence, based on which DNS server does a user get the domain name resolved from, the mirror he/she would end up being served from would vary. These DNS servers also cache this information with themselves for other users in their networks who might request for the same domain name some time later.
PS – I did get lose in how I was writing this post many a times therefore, if you find any flaws in the post, do post a comment and I would edit it accordingly.