paint-brush
Ever Wondered What Happens When You Type google.com in Your Browser?by@zeekthebuilder
292 reads

Ever Wondered What Happens When You Type google.com in Your Browser?

by April 9th, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

When you type 'google.com' into your browser, it starts a journey involving DNS lookup for Google's IP address, a TCP handshake to establish a connection, routing through load balancers to available servers, and secure communication via HTTPS with encryption and firewalls ensuring data safety, ultimately fetching Google's homepage for display in your browser.
featured image - Ever Wondered What Happens When You Type google.com in Your Browser?
undefined HackerNoon profile picture


What happens when you type ‘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 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’ into your browser, it needs to know Google’s address.


Address? Yes, websites live at specific addresses.


You can think of the internet as a network of roads that link computers together. If you wanted to go to the mall, you would get on the road and navigate towards the mall. Likewise, 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 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.



Establishing Communication: The TCP Handshake

Now let’s do this again. When you enter 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 acknowledgment 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.



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).




Handling the Traffic: Load Balancers

Let’s tie all these together. We enter google.com into your browser, you query 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 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 complain, 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.




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 sends to Google’s server is called an 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, and anyone who 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 is achieved 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 into your browser, your browser queries the DNS for Google’s IP address. After receiving the IP address, it sends an 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 acknowledgment 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 an HTTP response containing an 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 into your browser