What happens when you type google.com in your browser and press Enter?

What happens when you type google.com in your browser and press Enter?

It takes you to the Google search home page!
Actually, it is way more than that. A lot of things are going on in the background before the browser can render the search page. This article aims to demystify what happens in the background before the requested resource is rendered.

Domain Name Service (DNS) request
Computers generally communicate with each other over the internet using IP addresses. The computer does not automatically recognize “google.com” as a valid resource address. That is where the Domain Name System (DNS) comes in. The primary function of DNS is to resolve domain names to IP addresses. The DNS servers are of four types, each with its distinct function but all working together in the IP address resolution. They include:

Recursive resolver
Root nameserver
Top-level domain (TLD) nameserver
Authoritative nameserver

The process of IP address resolution starts with the browser checking its cache to see if it knows the IP for the domain. In our case, the browser checks if it has the IP for “google.com” in its cache. If it does, then the IP is returned. If it doesn’t, the “resolver” comes in.

Recursive Resolver acts as a middleman between the client (our browser) and a DNS nameserver. Similar to the browser, it also checks its cache for the domain and returns it if found, else, it makes a request to the root nameserver for the domain name.

The Root nameserver responds with the address of the Top-level domain (TLD) server for the domain name provider (in our case, for “.COM”).
The resolver proceeds to the TLD nameserver, making a request to the .com TLD nameserver. The TLD nameserver responds by providing the authoritative name servers for the domain (google.com).

From the image above, we can see that google.com has four (4) authoritative name servers, each with the ability to resolve the domain “google.com” to its IP address. At this point, the resolver makes a request to any of the Authoritative nameservers (ANS). The ANS is the ultimate source of truth for a domain’s DNS records which returns the IP address for the domain.

TCP/IP
With the IP address at hand, the browser can now communicate with “google.com”. This is done through the Transmission Control Protocol and Internet Protocol (TCP/IP). These are communication protocols used communicate and send data over the internet.

Firewall

HTTPS/SSL

Load-balancer / Web server

Application server

Database