What Happens When You Type "google.com" in Your Browser and Press Enter?
Introduction
Have you ever wondered what happens when you type a URL (Uniform Resource Locator) like google.com in your browser's address box and press enter? Well, there are a series of operations that happen behind the scenes, from the time you press ENTER on your keyboard to when the Google webpage is displayed to you on your device. We often take this for granted, but the process is a fascinating journey through various layers of technology, each playing a crucial role in delivering the web page to your screen.
In this article, we are going to learn about how your browser can display web pages on your screen.
NOTE: In this article, I will use client and browser interchangeably.
URL Parsing
URL parsing is the process of breaking down a Uniform Resource Locator (URL) into its parts to extract meaningful information about the resource it represents. A "resource" here is any item or entity that can be identified and accessed on the internet. This includes web pages, images, documents, videos or any other type of content or service hosted on a server and accessible via a URL.
The browser breaks the URL, for example https://google.com
into its component parts. These are;
Scheme: The scheme indicates the protocol used to access the resource. Common schemes include "http", "https", "ftp", "mailto", and "file".
For example:
https://
Host: The host specifies the domain name or IP address of the server hosting the resource.
For example:
www.google.com
Path: The path identifies the specific resource or endpoint on the server. It is typically a hierarchical representation of directories and filenames which we didn't bother adding. But, most browsers will add it for us automatically.
In our case,
https://www.google.com/
the forward slash/
at the end of the URL indicates the path. This/
is the root or starting point of the resource we intend to access.
Other components of a URL that we wouldn't cover in this article are; Query Parameters, Port Parsing and Fragment Identifier (also known as Hash).
DNS Lookup
With the domain name parsed, the browser initiates a Domain Name System (DNS) lookup to translate the human-readable domain name www.google.com
into an IP (Internet Protocol) address. Your computer first needs to translate this human-readable domain name into an IP address, which is a unique numerical identifier for a web server before it can reach the resource you are looking for.
Think of IP addresses as our unique phone numbers. Assuming you want to make a phone call to a friend, you need your friend's phone number to place the call. Likewise, computers on the internet use IP addresses to communicate with each other. Like a phone number, IP addresses do have a format they follow. They come in four numbers called octets separated by dots, like this 192.168.0.15
Every computer or server on the internet does have one of these unique IP addresses. Imagine having to memorise the IP addresses for all the websites you visit. Such a pain it will be. This is why DNS exist to provide a human-readable alternative to these hard-to-memorise numbers.
Let's look at the DNS Lookup in detail.
Initiating the DNS Lookup
Your browser needs to determine the corresponding IP address to establish a connection with the server hosting the
google.com
website. So, it starts looking internally first.Local DNS Cache
Before initiating a DNS query to external DNS servers, your operating system and browser may first check their local DNS cache. This cache stores recent DNS resolutions, allowing quicker access to frequently visited websites. If the domain name is found in the cache and the cached record is still valid (has not expired), the IP address is retrieved directly from the cache, bypassing the need for a DNS query.
Recursive DNS Query
If the domain name is not found in the local DNS cache or the cached record has expired, your computer sends a recursive DNS query to a DNS resolver. This resolver may be provided by your Internet Service Provider (ISP) like Vodafone, MTN, Digicel, Verizon etc, a public DNS service like Google DNS or Cloudflare DNS, or a private DNS resolver within a corporate network.
Root DNS Servers
If the DNS resolver does not have the requested domain name cached or stored already, it begins the DNS resolution process by querying the root DNS servers. These root servers are the authoritative servers at the top of the DNS hierarchy and maintain information about the top-level domain (TLD) servers responsible for specific domain extensions (.com, .net, .org, etc.).
TLD DNS Servers
Based on the TLD of the requested domain name in our case
.com
, the root DNS servers direct the DNS resolver to the appropriate TLD DNS servers. For example with"www.google.com"
, the resolver queries the.com
TLD servers to obtain information about the authoritative name servers responsible for thegoogle.com
domain.Authoritative DNS Servers
The TLD DNS servers provide the IP addresses of the authoritative DNS servers responsible for the specific domain name
(google.com)
. The resolver then queries one of these authoritative DNS servers directly to obtain the IP address associated with the requested domain name.Resource Record (RR) Lookup
The authoritative DNS server responds to the resolver's query with a Resource Record (RR), which contains the IP address mapping for the requested domain name. This response typically includes various types of records, such as A records (IPv4 addresses), AAAA records (IPv6 addresses), MX records (mail server addresses), and others.
Caching the DNS Response
Once the resolver receives the IP address from the authoritative DNS server, it caches the DNS response locally for future use. This caching helps improve the efficiency of subsequent DNS lookups and reduces the load on DNS infrastructure.
Returning the IP Address
Finally, the resolver returns the IP address obtained from the authoritative DNS server to the web browser, allowing it to establish a connection with the server hosting the Google website.
TCP/IP
At this stage, the browser has the IP address of the destination server that hosts the Google website. Your browser now initiates a Transmission Control Protocol (TCP) connection with the IP address it obtained from the DNS lookup. TCP ensures reliable and ordered delivery of data packets, while IP handles routing and addressing to ensure the packets reach their destination.
Before data exchange begins, TCP establishes a connection between the sender (your browser) and receiver (the google.com server) through a process known as the TCP handshake. The TCP handshake, also known as the TCP three-way handshake, is the process of establishing a TCP connection between a client and a server. This connection ensures that both parties are ready to talk to each other, that is, send and receive data.
The Internet Protocol (IP) is responsible for routing data packets across the network and ensuring they reach their intended destination.
Firewall
Servers frequently use firewalls to prevent hackers and other attackers from getting access to data being transferred over networks. A firewall is a piece of software that restricts what may enter and exit a network. It is a security measure that monitors and controls incoming and outgoing network traffic based on predetermined security rules.
In our example, when the browser requests the website at the IP address, the request is routed through a firewall, which determines if it is secure or poses a security risk to the server. The browser may also be configured with a firewall to check whether the IP address returned by the DNS request is a potential malicious agent.
HTTPS/SSL
Remember the URL Parsing stage? Yes, the browser is now ready work on the https
part after receiving the IP address.
Since we're accessing Google via HTTPS (HyperText Transfer Protocol Secure), Secure Sockets Layer (SSL) or its successor Transport Layer Security (TLS) comes into play. This cryptographic protocol ensures secure communication between your browser and the server by encrypting data transmitted over the network.
It involves a handshake process where the server presents its SSL certificate, and both parties agree on encryption parameters. This certificate must be issued from a trusted Certificate Authority (CA). We can see if a website has this certificate by indicating the little lock icon beside the website's name in the address bar. The TLS handshake occurs after the TCP handshake and adds a layer of security to the communication.
Load Balancer
A load balancer as the name implies balances incoming load (traffic) across multiple web servers. For a large-scale website like google.com, it is obvious that a load balancer is being used to distribute incoming web traffic.
Load balancers do not only ensure optimal performance but also prevent any single server from becoming overwhelmed with requests, thereby enhancing reliability and scalability. Load balancers sit between the clients (such as web browsers or mobile devices) and the servers.
When your browser sends a request to access a resource, the request first reaches the load balancer. Upon receiving a request, the load balancer analyses various factors to determine how to distribute the incoming traffic to the Google servers.
Web Server
Once your request reaches the appropriate web server, typically a web server like Apache or Nginx for Linux, or IIS for Windows, it processes the request and retrieves the requested web page or resource.
It receives HTTP requests and breaks them down into parameters including the HTTP request method (e.g., GET
), domain (e.g., google.com
), and requested path page (defaulting to "/"
, which is the root if unspecified). The server verifies the existence of a corresponding Virtual Host for the domain and checks permissions for the client's requested method. If configured, it may apply rewrite rules to modify the request. The server retrieves content corresponding to the request, typically falling back to an index file. Depending on the server's configuration and the file's handler, it interprets and processes the file before streaming the output to the browser.
The web server may also perform tasks like content compression, caching, and request logging before sending the response back to your browser.
Application Server
In more complex web applications, which google.com
is an example of, an application server is involved in handling dynamic content generation, business logic, processing client requests, and generating dynamic content to be delivered to users. This implies that you can interact with the site, store information, log in using your username and password, and so on.
In our example, the application server is responsible for generating content based on what you input in the search bar on Google. Google is not a static webpage but a dynamic web application that generates search results based on user input in real time. The application server processes user queries entered into the search bar and executes complex algorithms to retrieve relevant search results from its massive index of web pages.
Once the application server generates the search results or other dynamic content, it formats the data into HTML, JSON, or other suitable formats for delivery to the client (browser).
Database Server
If the requested content involves fetching data from a database, the application server queries the database server. Google's vast database infrastructure comes into play here, where millions of indexed web pages, user data, and other information are stored and retrieved efficiently.
Just like a librarian uses an index to quickly find books, the database server utilises indexing techniques to retrieve data efficiently. When the application server needs specific information, it sends a query to the database server. This query includes criteria for the desired data, such as keywords for a search query or user preferences for personalised content.
The database server is a critical component of Google's infrastructure, responsible for storing, indexing, and retrieving vast amounts of data efficiently. Its advanced capabilities enable Google to deliver fast, relevant, and reliable search results and services to users worldwide while maintaining the highest standards of security and privacy.
Conclusion
From entering 'https://www.google.com'
, to viewing the search engine's homepage, and everything that happens involves a series of technologies working perfectly together. DNS resolution, SSL encryption, load balancing, and database queries are all stages in providing a quick, secure, and reliable browsing experience. Understanding this process not only explains the magic of online browsing but also demonstrates the complexity and sophistication of current internet infrastructure. So, the next time you search Google or visit a website, remember the complicated path your request travels to provide you with the desired information in just a few milliseconds.
Congratulations on getting to the end of this article.
Do you find this resource helpful? Have a question or discovered a mistake or typo...? Please leave your feedback in the comments.
Don't forget to share this resource with others who may benefit from it as well. Follow me for more.
Subscribe to my newsletter
Read articles from Patrick A. Noblet directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by