What Happens When You Type www.google.com and Press Enter?

What Happens When You Type www.google.com and Press Enter?

Every time we want to visit a website, we quickly type in the domain name or URL(Uniform Resource Locator), and voila - the webpage appears on our screens. But have you ever wondered what happens under the hood when you type "www.google.com" in your browser's address bar?

Naahhh, you haven't! Or have you? Well, I have penned this down for you then. So what exactly happens the moment you click on that "ENTER" key hoping to be shown a nice Google page in less than a second?

The Initial Request

The moment you press the "ENTER" key, in a fraction of a millisecond, your browser interprets this input as a URL request. This simply means the browser now understands you want to send it on an errand, "Hey go help me get whatever google.com has to give me". It then verifies if the URL is valid and parses it into separate components such as the protocol (HTTP or HTTPS), domain name (google.com), and path to the specific webpage.

Resolving the Domain Name

Every computer connected to a network(and the internet by extension) has an Identity and this identity is its IP address just the way citizens of a country have a special number on their ID cards. Therefore to communicate with any computer, you need it's IP address. You may ask "But I just want a single page, not a computer address"! The thing is, the page you want is stored somewhere, where you ask? you guessed right! on a computer. This is Google's IP address => 142.251.46.174 (try typing this in your browser and press enter). Can you imagine having to memorize hundreds of thousands of those?

The next step is to resolve the domain name "www.google.com" into an Internet Protocol(IP) address that the browser can understand. This process is known as the Domain Name System (DNS). The DNS involves recursively asking DNS servers until the IP address is obtained. Once the browser has the IP address, it sends a connection request to the corresponding web server. A web server is a computer software that delivers web pages.

Establishing a Connection

After resolving the IP address, the browser initiates a connection request to the web server using the HTTP(Hypertext Transfer Protocol) protocol. To establish the connection, a three-way handshake process called Transmission Control Protocol(TCP) handshake occurs between the client(your browser) and server(computer responding to your request with a webpage). Before TCP, there was User Datagram Protocol(UDP) which does the same thing as TCP but insecurely. Google uses HTTPS - s stands for secure - which is a secure version of HTTP. HTTPS builds on top of the TCP handshake by adding encryption and authentication layers to protect data during transit, making it a preferred choice for secure communication on the web.

The Request

Once a connection is established, the browser sends an HTTPS GET request(web terminology) to the webserver to retrieve the specific webpage for "www.google.com". In response, the web server processes the request and generates a response. A few things happen while processing the response. When Google started, they probably didn't have 1000 people searching the web for "google.com". But as days turned to weeks and months turned to years and the requests started entering millions. Today over 8 billion people visit "google.com" daily, how do they manage all that traffic?

Balancing Everything

One of the essential components of this process involves load balancers and data centers. Let's briefly explain these concepts:

Load Balancers: Load balancers are critical software components of web infrastructure that play a crucial role in ensuring high availability, scalability, and optimal performance of websites and online services. They balance website traffic by redirecting them to servers following industry-standard algorithms.

Data Centers: Data centers are facilities equipped with a network of servers, storage devices, networking equipment, and other infrastructure components. They serve as the physical locations where organizations host and manage their online services and data.

Think of it like this, Google has hundreds of thousands of servers in its data centers, these servers have load balancers installed on some of them. The load balancers distribute the traffic it receive from clients(other people like you searching for "google.com") to the various other servers where the webpage is stored. What happens if the load balancers fail? They can't because google.com has no SPOF!

WTH is SPOF?

A single point of failure in infrastructure is a point where, if something goes wrong, it's going to affect everything else. Think of an older person taking care of two troublesome twins. If that person leaves without putting someone in charge of them, what would happen? chaos! That's a single point of failure. Conversely, if there was another adult who would stand in, the peace might have just continued. That's redundancy.

Can I Come In?

Remember the GET request your browser sent? it has now gotten to Google's servers, where a firewall would either let you in or deny you access. The software or hardware responsible for this is called a firewall.
A firewall is a network security device or software that acts as a barrier between a trusted network (like an organization's internal network) and an untrusted network (like the Internet). It enforces rules to monitor and control incoming and outgoing network traffic, based on predefined security policies. Firewalls help protect against unauthorized access, malware, and other cyber threats by filtering and managing network traffic according to specified criteria.

Webserver

Ah! You didn't receive any errors? The firewall allowed you in then, because you are not a hacker, or are you? Let me believe you are not. The firewall will now most likely direct your request to the web server which is responsible for handling client requests and serving static content (e.g., HTML, CSS, JavaScript files). What about the application server?

Application Server

  • When a request involves dynamic content or complex processing, the web server may forward the request to the application server.

  • The application server processes the request by executing the application's business logic, which may involve data retrieval from databases, computations, and interactions with other services.

Database

  • If the application server requires data from a database, it makes requests to the database using SQL queries(this is a tool used to interact with the software(Database management system) where the data is stored) or other data access methods.

  • The database responds with the requested data, which the application server uses to generate dynamic content.

Response and Rendering

Once the browser has received the response from the web server, it interprets the response, including the HTML, CSS, and JavaScript files contained within. The browser parses the HTML code to construct the webpage you see, based on the HTML and CSS styles. Finally, the browser executes any JavaScript in the webpage to add interactivity or functionality to the webpage.

Conclusion

From typing "www.google.com" in the address bar to viewing the webpage, this process may seem simple, but it requires a significant amount of infrastructure and technology to make it happen seamlessly. It's thanks to these technologies that you can instantly access any website on the internet with just a few clicks.

Pic Credits

1. https://seopressor.com/wp-content/uploads/2017/07/HTTP-vs-HTTPS.png
2. https://academy.avast.com/hs-fs/hubfs/New_Avast_Academy/what_is_a_firewall_and_do_you_need_one_academy_refresh/Firewall-01.png?width=1980&height=900&name=Firewall-01.png
3. https://academy.bit2me.com/wp-content/uploads/2019/05/49_DNS.webp
4. https://seopressor.com/wp-content/uploads/2017/07/HTTP-vs-HTTPS.png
5. https://img.freepik.com/free-photo/search-engine-optimization-research-infomation-technology-concept_53876-124895.jpg?w=826&t=st=1694996581~exp=1694997181~hmac=195e6002676350881b69dbb82bf7f609e9a1db83c2ed1957d6dff55666d43e00