What happens when I google search

The little details we don't see

ยท

5 min read

Table of contents

No heading

No headings in the article.

When you type "google.com" into your web browser and press enter, a series of events is triggered that eventually leads to the Google website being displayed on your computer. Understanding these events is important for anyone working in the field of software engineering, as it helps to understand how the various components of the web stack work together to deliver content to users.

The first step in the process is the DNS request. When you enter a URL into your web browser, your computer sends a request to the Domain Name System (DNS) server to resolve the domain name to an IP address. The DNS server acts like a phonebook, matching domain names to the corresponding IP addresses of the servers that host the websites.

For example, when you enter "google.com" into your web browser, your computer sends a request to the DNS server asking for the IP address of the server that hosts the Google website. The DNS server responds with the IP address, and your computer stores this information in its cache so that it can access it more quickly in the future.

The process of resolving a domain name to an IP address is important because computers communicate with each other using IP addresses, not domain names. By using the DNS system, we can use easily-remembered domain names instead of having to remember long strings of numbers.

Once the DNS server has resolved the domain name to an IP address, the next step is to establish a connection with the server using the Transmission Control Protocol (TCP). This process, known as the "handshake," involves your computer sending a message to the server saying, "Hey, I'd like to establish a connection," and the server responding with a message saying, "Sure thing, let's do it."

The handshake process serves several important purposes. First, it allows the two computers to negotiate parameters for the connection, such as the maximum size of the packets that can be transmitted and the timeout period for the connection. Second, it allows the two computers to verify each other's identity and ensure that they are communicating with the intended party.

Once the connection has been established, it may need to pass through one or more firewalls before it can be completed. A firewall is a security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules. For example, a firewall might be configured to block all incoming traffic from a specific IP address or range of addresses, or to allow only traffic from specific ports.

The purpose of a firewall is to protect a network from unauthorized access or attacks. It acts as a barrier between the network and the outside world, and helps to ensure that only authorized traffic is allowed to pass through.

After the connection has been established and has passed through any necessary firewalls, the next step is to establish an encrypted connection using SSL (Secure Sockets Layer) or TLS (Transport Layer Security). This is necessary when the "https" protocol is used in the URL, as it indicates that the website is using a secure connection.

Encryption is important because it helps to protect the data being transmitted between the two computers from being intercepted and read by unauthorized parties. Without encryption, anyone who is able to intercept the data would be able to read it in plain text.

Once the encrypted connection has been established, the next step is to determine which server or group of servers will handle the request. If the website's server is part of a group of servers that work together to host the website, the request is forwarded to a load-balancer.

The load-balancer is responsible for distributing incoming requests to the various servers in the group in a way that is efficient and ensures that no single server becomes overwhelmed. There are many different algorithms that can be used to distribute the load, such as round-robin, least connections, and least response time.

After the request has been forwarded to the appropriate server or group of servers, the web server receives the request and sends back a response in the form of an HTML file. This file contains the structure and content for the website.

If the website requires additional processing, such as executing a database query or running a custom application, the request is forwarded to an application server. The application server performs the necessary tasks and sends the results back to the web server.

If the website requires data to be retrieved from a database, the application server sends a request to the database server to retrieve the necessary data. The database server responds by sending the requested data back to the application server.

Finally, your web browser receives the HTML file from the web server and renders the website on your computer. It does this by parsing the HTML code and using it to create a visual representation of the website, including the layout, text, images, and other elements.

And that's it! That's what happens when you type "google.com" into your browser and press enter. Understanding the various components of the web stack and how they work together is essential for any software engineer, and being able to explain it clearly is a valuable skill in any technical interview.

In summary, the process of accessing a website involves several steps, including:

  1. Sending a request to the DNS server to resolve the domain name to an IP address

  2. Establishing a connection with the server using TCP

  3. Passing through any necessary firewalls

  4. Establishing an encrypted connection using SSL or TLS

  5. Forwarding the request to the appropriate server or group of servers

  6. Receiving a response in the form of an HTML file

  7. Rendering the website on your computer

By understanding these steps and the various components of the web stack, software engineers can more effectively design, develop, and maintain websites and web-based applications.

ย