How does a user connect to a website?
How is a user able to access a site from the browser? What happens in the backend?
Whenever a user types a website name in the browser and searches, it meant he/she is searching for the IP associated with it[ DNS mapping ]. The IP address would serve the request made by the user.
Who maintains this Domain mapped to IP’s info?
The DNS mapping is maintained by the non-profitable organisation called ICANN https://www.icann.org/. It maintains all the names and IP addresses. So when a user fires a request to a particular site it would first hit the DNS Servers and from there it would see a particular IP of a site and a point of contact is made to it.
What are DNS servers?
As ICANN is non-profitable, it is also hard to serve all the internet users at once and also it should maintain security so associated IP's don’t get corrupted. It takes the help of third-party vendors for serving the same purpose. The third-party vendors would maintain the same DNS-mapped data in their server and would do the DNS resolution, they would update or pull data from the ICANN whenever changes are made.
Some of the famous DNS servers are:
Google
Big rocks
Here is the list of registered DNS servers available https://www.icann.org/en/accredited-registrars/
How can we use the DNS Servers?
In the browser network settings, we can configure which DNS server to use. We can change the default DNS to our desired DNS server. So when a request is made it would be that DNS server which would be searched for DNS resolution.
Would every time we search for a site will go to DNS Servers?
Not really every time we make a request for a website doesn’t go for the DNS server. Remember faster the response greater the user engagement. So even to fasten this DNS resolution cache is maintained at some levels.
Levels of DNS caching:
Browser level: This is the first cache the browser lookup, It maintains our frequently visited site's IP’s so when the further process doesn’t take place and resolution is made quickest. If not found it would go for the OS level
OS level: It is much larger than a browser and it would be searched when the browser level is not met
Router level: This is maintained in the router but generally not advised as it can be easily manipulated.
ISP level: This is our internet service provider, they maintain all its users frequently visited site IP’s. In Max cases the DNS resolution will be done here else at the next point it would be our DNS servers.
So now we got a detailed picture of how a point of contact is made between a user and a website. If we know the IP address of a site we can directly go to that website in case of a single server website.
What if the website is hosted on multiple servers?
So if we maintain our website in 10 servers[ application servers] do we maintain 10 ips for the website? No, here the load balancer comes into play. A load balancer would distribute the request to the available servers routing algorithms. Every routing algorithm will have its own method of even distribution of requests to servers, monitoring the servers etc
In the DNS server, the load balancer Ip will be mapped to the website name, likewise, it would see a load-free or load-less server and forward the request to that server.
This site can help to find the list of IP’s of a website https://www.whatismyip.com/dns-lookup/.
There are other things like Zoo-keeper which will ensure the proper function and also handle the load balancer failure cases.