What Happens When You Type 'www.google.com' In Your Browser And Press Enter
Have you ever wondered what happens when you type a domain name (like www.google.com) in your browser and hit Enter? Well, several crucial processes take place within milliseconds to resolve your request.
From DNS lookup to encryption, the steps ensure secure communication and that the response is relevant to your request. Read on to learn more.
What Happens?
This is what happens when you type www.google.com in summary:
DNS lookup
TCP/IP connection
Going through the firewall
Use of HTTPS/SSL for encryption and authentication
Load balancing to determine which server will resolve your request
A web server resolves your request
An application server generates dynamic content and interacts with the database
A response is sent to your web browser
DNS Request
So, what happens when you type www.google.com? Well, your browser will query DNS servers to resolve the domain name. Ideally, a query will consist of the following pieces of information:
A DNS domain name such as www.google.com
A query type can be a resource record type or a specialized query operation such as CNAME or A.
A class for DNS domain name like A (host address) or NS (internet).
Take www.google.com as an example. Here, the destination URL is google.com. The query type is A since we are looking for Google’s IP address. Think of a DNS query as asking for a person’s address.
Once your browser receives a response from the DNS server, it reads and interprets the A record, revealing Google’s IP address, to which it can connect.
A DNS request can be resolved in different ways. Your browser can resolve locally using cached information from previous queries.
The DNS server can also contact other DNS servers in a process known as recursion. If the DNS Resolver does not have the IP address, it sends a request to the root server.
The root server will then contact the TLD server for the answer, which is then routed to the user.
Unfortunately, not all DNS requests are successful. Your browser will only work once it knows the IP address of the domain name. If the DNS server goes down, the request will not return an answer.
TCP/IP
Transmission Control Protocol/Internet Protocol (TCP/IP) is a set of protocols that specifies how data is exchanged over the Internet.
There are currently two main protocols IPv4 and IPv6. IPv4 is the most widely used while IPv6 has more available addresses and is gradually being embraced.
So when you type www.google.com, your browser will use TCP/IP to communicate with the server that hosts the website.
Generally, your browser will send a SYN (synchronize) flag set to the Google server requesting a connection. The server will respond with SYN and ACK (acknowledge) flags set, indicating it is ready to initiate a connection.
Finally, your browser sends a segment with the ACK flag set, completing the handshake and establishing the TCP connection.
Firewall
Most large companies like Google use firewalls to filter connections to their servers. Once the TCP connection is established with Google’s server, it still has to go through their firewall.
If the connection is not suspicious and meets preset security rules, the firewall will approve it, allowing your browser to communicate with the Google server. Otherwise, the connection will be rejected.
Firewalls work 24/7 to protect networks from attackers. They monitor incoming and outgoing requests, meaning they can prevent attackers from using your network to spread malicious code.
HTTPS/SSL
HTTPS stands for Hypertext Transfer Protocol Secure. It is a secure version of the HTTP protocol, which uses SSL/ TLS to encrypt and authenticate communication over the Internet.
Since the firewall has approved your connection to the Google server, your browser can use its SSL/TLS certificate with a public key to communicate with the server. They will create a secure and encrypted channel to transmit data; in this case, Google’s landing page.
Thanks to HTTPS, not even hackers can intercept communication between your browser and the Google server. It is encrypted, meaning only the two parties can understand the data being transmitted.
Load-balancer
A load balancer is a device that distributes network traffic across several servers. They are used to distribute capacity, increasing a website’s or application’s reliability and performance.
They use several load-balancing algorithms to improve a server’s performance. They include round robin, threshold, least time, least connections, and consistent hashing among others.
Google receives billions of requests daily. As such, they use load balancers to distribute incoming network traffic so that your request can be resolved in milliseconds.
For your connection, the load-balancer will choose which server will resolve your request depending on the preset load balancing algorithm.
Web Server
A web server is a computer system that hosts websites and servers web pages to your browser when you request them. It consists of two main parts: hardware and software.
Hardware is the physical machine that stores the web content while the software is the application that handles your requests. Popular software web servers include Nginx and Apache.
When the web server receives your request, it determines what content you want to see. In this case, Google’s homepage. It retrieves necessary files (HTML, CSS, JS, images, etc.), which are sent to your browser for rendering.
Application Server & Database
Unlike the web server, the application server generates dynamic content based on your requests. It handles business logic and interacts with the database.
For example, if your request requires complex processing, the web server will send it to the application server. Requests that need access to the database are also sent to the application server.
Let’s say you want to log in to your Google account. This request will be resolved by the application server to verify your credentials by querying the user database.
Final Rendering
Once the Google server processes your request, it will send a response with the relevant HTML, CSS, and JS files for your browser to render.
This involves rendering the HTML body, displaying relevant images, and processing CSS and JavaScript code. Once the rendering is done, you can interact with Google's homepage.
Subscribe to my newsletter
Read articles from Allan WANJIKU directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Allan WANJIKU
Allan WANJIKU
I am a technical writer and software engineer