What Happens When You Type www.google.com in Your Browser and Press Enter.
Tags: devops, webdev, internet, webstack
Published: 2024-03-18 10:36:10

## Introduction 
For many people who access the internet using their browsers, it's just as simple as entering the web address (url) on the browser and then pressing enter to get access to the information we seek. But, let's take a pause and wonder, what actually happens behind the scene when you type a web address into your browser and hit the enter key?

Aloooot! Yeeeees, a whole lot happens, but it happens so fast that the average internet user doesn't even think about it. This action that may seem simple actually sets off a complex chain of events that involves various technologies communicating and working together to bring you the information you need.

Now that the question has been put forth, this post will take you on a ride into the exciting world of the web stack and explain what unfolds when you enter "www.google.com" and press enter. 

Let's start by exploring several key players involved in this process. 

## DNS (Domain Name System) Request
There are hundreds of millions of websites on the internet today, if not billions. These websites are hosted on servers/computers that have their own identity called IP Address - a unique numerical label assigned to every device on the internet. IP Addresses often look something like: `154.243.002.118`; you can agree that memorizing these numbers can be a lot of work and it will be easy to mix up one website address from another when they're all in number formats like this. 

The DNS acts like the information operator for a phonebook where websites are listed by names (like www.google.com) instead of numbers (Ip address). When you type in "www.google.com", your browser really can't understand this name, so it initiates a DNS request to a DNS server, asking it to translate "www.google.com" into an IP address of the target computer and then your request is processed further.

## TCP/IP (Transmission Control Protocol/Internet Protocol)
You can think of TCP/IP as the language spoken on the internet. Once the DNS server translates "www.google.com" to an IP address (let's assuming it's 142.250.874.196), your browser can now communicate with the Google server. TCP/IP establishes a connection and breaks down the data you're requesting (the Google webpage) into smaller packets. These packets are then individually sent over the internet.

## Firewall
Firewalls act as digital security guards, monitoring incoming and outgoing traffic on your computer. Before the data packets reach your browser, the might pass through a firewall that checks for any suspicious activity or malicious content. Firewalls are a great security measure that helps to ensure your computer's safety by clocking harmful traffic.

## HTTPS/SSL
HTTPS is the more modern and enhanced version of HTTP, a protocol for communicating between computers. It stands for Hypertext Transfer Protocol Secure". When you see "HTTPS" at the beginning of a web address, it indicates a secure connection. This security comes from a technology called SSL (Secure Sockets Layer) or its successor, TLS (Transport Layer Security).  When you request "https://www.google.com", HTTPS scrambles the data being exchanged between your browser and the Google server. This makes it very difficult for anyone eavesdropping on the communication to steal sensitive information like passwords or credit card details.

## Load Balancers
Think of a load balancer as a traffic director during rush hour.  With millions of users potentially trying to access a website like Google or Facebook simultaneously, a single server would be overwhelmed. The load balancer steps in, strategically distributing incoming traffic across a pool of web servers (often referred to as a server farm). This ensures that no single server gets overloaded, and users experience a smooth and responsive website.

Here are some real-world examples of load balancers:
- HAProxy: A free and open-source software load balancer known for its performance and ease of use. Many companies, including Netflix, use HAProxy to manage their high traffic websites.
- AWS Elastic Load Balancer (ELB): A cloud-based load balancing service offered by Amazon Web Services (AWS). This service allows companies to easily scale their web applications according to traffic demands.

## Web Servers
Imagine a web server as a tireless waiter in a busy restaurant.  When you request a webpage, the web server acts like the waiter, receiving your order (the request for a specific webpage) and fetching the necessary ingredients (HTML files, CSS styles, JavaScript code) from the kitchen (storage location).  The web server then assembles these ingredients on a plate (prepares the webpage) and sends it back to you (your browser) for you to enjoy (view the webpage).

Here are some popular web server options:
- Apache HTTP Server: One of the most widely used web servers globally, known for its reliability and flexibility. It powers millions of websites, including popular platforms like Wikipedia and eCommerce giant Amazon.
- Nginx (pronounced Engine-X): Another popular choice, known for its efficiency and handling high traffic websites well. Many content delivery networks (CDNs) utilize Nginx for its speed and scalability.

## Application Servers
While web servers primarily deal with static content, application servers take things a step further.  Imagine an application server as a skilled chef in a restaurant kitchen.  It receives instructions (requests) from the web server (waiter) and interacts with the pantry (database) to gather ingredients (data).  The application server then prepares a customized dish (dynamic content) based on the specific recipe (user request). This dynamic content could be anything from personalized search results to displaying your shopping cart items on an e-commerce website.

## Databases
The database is the heart of many dynamic websites, storing all the information that makes them function.  In Google's case, the database might hold information about webpages you've visited, search history, or even emails (if you use Gmail). When the application server needs data to fulfill your request, it retrieves it from the database.

## Conclusion
The web stack functions like a symphony orchestra, with various technologies working in harmony to deliver a seamless web experience.  The next time you type in a web address and hit enter, take a moment to appreciate the intricate dance behind the scenes that brings the vast world of the web to life.

That concludes our exciting exploration of what happens behind the scenes when you type "https://www.google.com" and press enter.