Ever Wondered What Happens When You Type google.com in your browser?
Tags: webdev, beginners, tutorial, learning
Published: 2024-03-28 15:41:35

What happens when you type in [google.com](http://google.com/) into your browser? Less than 20% of the world can answer this question. You are about to become part of this elite group. In simple terms, when you type in [google.com](http://google.com/) and press enter, you are sending a request for Google’s homepage. Google receives this request and responds with the homepage, Tada!. That’s it guys, thank you for coming.

**The Journey Begins: DNS Lookup**

If you’re still reading, I’ll assume you want to know more. We will get a little more technical (Not too much, hopefully). When you type [google.com](http://google.com/) into your browser, your browser needs to know Google’s address. Address?, yes websites live at specific addresses. You can think of the internet as a network of roads for that link computers together. If you wanted to go to the mall, you would get on the road and navigate towards the mall. Likewise, data must navigate its way across the internet from source to destination. It needs to know where it’s going. Computer addresses look like this 195.94.234.134. That is called an IP address. While IP addresses are great for identification, it’s difficult for humans to remember (Imagine having to type something like that to watch Netflix…ugh). To solve this problem, we use the Domain Name Server which maps IP addresses to text-based names like [google.com](http://google.com/) just like a phonebook matching names with numbers. That way, we focus on remembering the domain name and let the DNS figure out the IP address.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97zd34zcqh3h625bqk29.png)
**Establishing Communication: The TCP Handshake**

Now let’s do this again. When you enter [google.com](http://google.com/) into your browser, your browser sends asks the Domain Name Server for google’s IP address. Once your browser knows google’s IP, it initiates a conversation with a google server using the TCP (Transmission Control Protocol). Let’s simplify this using our everyday human protocols. For example, in certain cultures, people greet each other by bowing while in some cultures, a handshake is the norm. Computers also communicate using certain protocols. Your browser first sends a message to the server, and the server sends back an acknowledgement to your browser. Then your browser sends a message again to establish a TCP connection. This is called the three-way handshake (Computers exchange pleasantries too). After establishing the connection, our browser sends the request to the Google server, and the server responds with the homepage.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v6cegmrg9waj8igxxgez.png)
**Servers and Web Servers: What's the Difference?**

But wait, what is a server? It is a computer (physical or virtual) dedicated to providing functionality to other computers. Servers perform tasks, house applications and websites. Servers differ from web servers. Web servers are software applications that live on servers. A web server connects a server to the internet. It handles web requests, serves static content or communicates with other applications to serve dynamic content (we won’t go into that in here).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ije1kemohd1yfjdz24r3.png)
**Handling the Traffic: Load Balancers**

Let’s tie all these together. We enter [google.com](http://google.com/) into your browser, your queries the DNS for google’s IP address. Using google’s IP address, our browser sends a request to a google server and the two computers (our computer and Google’s server) establish a TCP connection. The request is the received by a web server on a google server. The web server then returns Google’s homepage as an HTML file for our browser to open. You might have noticed I kept mentioning ‘a google server’ that’s because a company as large as google has thousands of servers. How does our browser know which server to send the request to? It doesn’t, that’s the job of the conveniently named load balancer. If you have ever had to call customer service to lodge a complaint, you might have probably been told that you were being routed to an available service agent. There could be a thousand service agents, but you only need one free agent to address your issue. This is the job of the load balancer, it routes incoming requests to available servers.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/67dfdtba5taq7781c89f.png)
**Security Matters: HTTPS and Firewalls**

Great, if you’ve read this far, you are part of the elite 20% who understand how web requests are handled. The request your browser sent to google’s server is called a HTTP request (Hypertext Transfer Protocol). HTTP is the set of procedures that transfer information from one computer to another. It is like sending a letter with data and instructions from one computer to another. However, HTTP is open, anyone that intercepts it can read that letter. To solve this problem, the introduction of HTTPS (Hypertext Transfer Protocol Secure) encrypts the data, allowing only the sender and receiver to access it, similar to putting a letter in an envelope and sealing it. It achieves using SSL certificates (Secure Socket Layer). The Server keeps a private key and shares the public keys with the browser. SSL certificates help to establish a secure connection to encrypt data.  Another security feature is the use of a firewall. A firewall acts like a filter to determine what sort of requests or connections are allowed to and from a computer. For example, preventing malicious actors from accessing the server.

**Conclusion**

Finally (I promise!), when you type [google.com](http://google.com/) into your browser, your browser queries the DNS for google’s IP address. After receiving the IP address, it sends a HTTPS request that is received by a google server that hosts a firewall and a load balancer. The firewall filters the traffic and the load balancer sends your request to an available server. Your request reaches the available server via the web server that it hosts. The web server then sends an acknowledgement with a secret key to your browser to establish a secure TCP connection via HTTPS. Your browser then sends the request with this secret key, ensuring the request is encrypted. The web server receives the decrypts the request for the homepage and sends a HTTP response containing a HTML of Google’s to your browser. Your browser opens this HTML file and reveals google’s home page!. There you have it, that is what happens when you enter [google.com](http://google.com/) into your browser