How the Web works behind the scene?

How the Web works behind the scene?

This is the most frequently asked question whenever you appear in an interview for Software Developer roles. Let us deep dive and see what actually happens when we type "google.com" (or any other URL) in our web browser.

---> You type the URL "google.com" in the browser. When you type any URL that means you want to reach the server where the website is hosted.
NOTE - Every data on the internet is hosted on some servers. Servers are machines just like your system but with very high computing power and of course with large memory capacity.

---> The browser doesn't understand the URL (string format), so it tries to search the IP address of the domain name you entered with the help of a process known as "DNS resolution" in the Domain Name Server (DNS).
Domain Name Server is a list of URLs and their corresponding address just like the telephone book which stores the numbers corresponding to the names of the people.

The DNS checks at the following places for the IP address->

  • Check Browser Cache: The browser (Chrome/Firefox etc) maintains cache of the DNS records for some fixed amount of time. This time is known as Time to leave (TTL). It is the first place where the DNS query runs.
  • Check OS Cache: If the browser cache doesn't contain the IP then it requests the underlying operating system cache which also maintains the list of DNS records.
  • Check Router Cache: If your system cache doesn't have the IP then it searches the routers as router also have the cache of DNS records
  • ISP cache: If the IP is not found at the above three places then it is searched at the cache that the ISP maintains of the DNS records. If not found here also, then DNS recursive search is done. In this process the DNS server initiates a DNS query that communicates with several other DNS servers to find the IP address. When recursive query is failed then iterative query is initiated to different levels of DNS servers.

Topic to study here: 1. recursive & iterative query, 2. Different types of DNS servers, 3. Component of an URL.

---> When the browser receives the IP address it will build a connection between the browser and the server using the TCP protocol. The connection is established using TCP three way handshaking.

Topic to study here: 1. TCP/IP connection, 2. TCP handshaking, 3. How HTPP/HTTPS works.

---> Once the TLS handshaking is complete, from now on the TLS session transmits the data encrypted with the agreed symmetric key.

Topic to study here: 1. Symmetric/Asymmetric Cryptography, 2. Hashing & Digital Signatures in terms of cryptography.


And trust me this entire process occurs within a millisecond of time.

DNSResolution.jpeg