What happens behind the scenes when you type google.com and hit enter

What happens behind the scenes when you type google.com and hit enter

What happens?

Have you ever wondered what happens behind the scenes when you are trying to find information on the internet? If so you are not alone I too never understood what happens till now.

Many people use web browsers to search for different information on the website and do not understand what happens when you type the domain name you want to search for in your browser and hit enter, so what really happens within those few seconds to generate the list of search results that Google displays when you search for something on the website, well I have learned what happens while studying Sofware engineering program at Holberton School under ALX Africa. I am tackling a project under system engineer DevOps on the curriculum and I would like to share with the world in detail what really happens. I would like to teach you too so that you know what goes on when you browse the Internet and, you are in the loop of what happens behind the scenes. So without wasting time let's dive right into it.

I will be covering this topic;

  1. DNS request

  2. TCP/IP

  3. Firewall

  4. HTTPS/SSL

  5. Load balancer

  6. Web server

  7. Database

These topics above may sound too technical, and truly they are but I am hoping to break them down for you in simple terms so that you understand what really happens. So let's get started.

DNS request

Before I explain what a DNS request is, let me break it down to define what a browser is. It is simply a piece of software that displays requested websites, and Google is a website and a website is simply a collection of interconnected pages that contain meaningful information.

Now let's talk about DNS requests, when you type Google.com or any domain name in your browser on your computer or device what really happens is, a request is sent to the domain name system (DNS) server which serves as an address book for all domain names. This then sends back the exact IP address of the server which google.com points to. This address will be like 123.122.130.3 rendering these numbers for humans is not possible to remember, hence the need for servers known as Domain Name System Servers. The domain names are a way for humans to remember easily for e.g Google.com, twitter.com, etc.

I know you might be wondering what is a server. A server is a computer program or device that provides a service to another computer program and its user, also known as the client. In this case, you are the client and you would like to access google.com or twitter.com, etc.

If you had accessed google.com or twitter.com earlier, the browser first checks its cache to see if it has a recent record of that domain name.

If there is a recent copy of the DNS records for that domain, it will use the IP address in the cache to send a request to the server. This speeds up the process of resolving the domain name to an IP address because it avoids the need to send a request to the DNS server.

If the browser cache does not find a copy of the recent record of the requested domain, or if the DNS record has changed since the last time it was cached, the browser will send a request to the DNS server to resolve the domain name to an IP address.

This process is called the DNS lookup process, and it works in detail. Let's explore each one of them.

  1. If the requested domain name or UR is not present in the browser’s cache, the browser makes a call to the (OS) which is your Operating system, and asks it if it has the address in its cache.

  2. If the browser doesn't find it on the OS cache it then requests the resolver name server cache which is (IPS) Internet Service Provider to check if it has the requested address.

  3. If the resolver name server doesn’t find it in its cache, it asks the root name server to give it the location of the top-level domain server (TLD) such as .com or .org, etc

  4. The TLD nameserver responds with the IP address of the authoritative nameserver for the domain.

  5. If the IP address of the requested URL is available, the browser then sends a request to the server at the IP address to retrieve the webpage and now finally you see it on your screen.

It seems like a very long journey isn't it but yeey! We made it. I know now let's go deeper to understand what really goes on.

TCP/IP

Now let's talk about TCP/IP. What does it mean? (TCP/IP)Transmission Control Protocol/Internet Protocol establishes a connection with Google's server or domain name server you are looking for. Once your computer has the IP address for google.com or the URL you are looking for, TCP is a protocol that ensures that the data sent between your computer and Google's server or domain name you are looking for is delivered correctly, while IP is a protocol that ensures that the data is sent to the correct destination. This is like communication between the browser and server with the domain name you are looking for, and when the server receives the request it sends back a message acknowledging the request to establish a connection. This is like the handshake process.

The server finally sends back the requested URL e.g Google.com with HTML code to the browser using TCP. The browser receives the HTML code and uses it to render the webpage on your screen. Any resources (such as images) that the webpage needs are also requested and received using TCP/IP.

Firewall

I know you are wondering what a firewall.

A firewall is a security device that monitors and filters incoming and outgoing network traffic. It ensures that the data being sent between your computer and Google's server or servers domain you are searching for is safe and secure from external threats such as hackers and malware.

You can set rules on your firewall to monitor incoming requests. Two main rules are;

  1. You can set a rule to allow or block traffic based on the source and destination of the request. For example, a firewall may be configured to allow only certain IP addresses to access the network.

  2. You can also set a rule to allow or block traffic based on the type of traffic. For example, a firewall may be configured to allow only certain types of traffic (such as HTTP or HTTPS). And to block traffic on certain ports.

This means If the incoming request meets the security rules set by the firewall in front of Google's server or the domain server you are trying to access then it is allowed through, and the browser is able to access the website.

HTTPS/SSL

Once the TCP/IP connection is established, your browser and Google's server or domains name you would like to access then begin a handshake to establish a secure connection using HTTPS (Hypertext Transfer Protocol Secure), this is a secure version of the HTTP protocol used to transmit data on the internet. It is used to encrypt the data. Data is transmitted between your browser and Google's server or the domain URL server you are trying to access. SSL (Secure Sockets Layer) is a protocol that provides the encryption and decryption of data. This ensures that any data exchanged between your computer and Google's server or domain URL you are looking for is secure and cannot be intercepted by a third party like a hacker.

To give an example for you to understand HTTPS/SSL. HTTP is like your mail address box and only you and your mail company delivery have the key to this box . The key is the SSL and therefore no third party is allowed to access your mails. I hope that made sense. Many websites nowadays will show HTTPS before the domain name to show they are secure, you will also see a padlock right before HTTPS. If you click on this padlock you will be able to see the website's SSL certificate.

This gives the clients visiting such websites to have trust in such websites while using them since they know their details are well secured with such websites, so they are able to make transactions safely. For example on an e-commerce website, you will most probably have to give details of your credit card when purchasing a product you like and you know your credit card information and passwords are safe from hackers.

Load-Balancer

I know you are wondering what is a load balancer. Let me explain in simple terms. A load-balancer is a device that distributes incoming network traffic across multiple servers. This ensures that the website can handle a large amount of traffic and prevents any one server from being overwhelmed.

For example, a company like Google, which receives billions of website visitors a day, will need a lot of servers to serve all these users. Therefore, Google team will need to set up load balancers to ensure that some of the servers are not overburdened while others are not utilized.

In a nutshell, this is how a load balancer works in the case of a browser trying to access google.com, the load balancer would receive the incoming request from the browser and then forward it to one of the servers in the Google server network. This will also work the same way for any domain name you are trying to search for.

Web server

Earlier I defined what a server is now let's look at what a web server is. It is a software program that is responsible for delivering web content to clients, typically web browsers, in response to their requests.

So Once the request is received by one of Google's servers, or the domain URL server you were looking for from the load balancer, it is passed to a web server. The web server is responsible for processing the request, generating the HTML, CSS, and JavaScript that make up the webpage, and sending it back to your browser for you to see it.

NB: I know I have mentioned URL more than once in case you don't know what a URL is, it is (a uniform resource locator ) for the domain you are looking for like Google.com, amazon.com, twitter.com, etc.

Application Server

If the webpage you are accessing requires additional processing, the request may be passed to an application server. An application server is a server that runs the code required to process a request and generate a response. This allows websites to provide dynamic content, such as personalized recommendations or interactive features.

Database

Finally, if the request requires data from a database, the request is passed to a database server. The database server is responsible for storing, organizing, and retrieving data. This allows websites to provide personalized content and store user data.

I will still use the example I gave earlier when you visit an e-commerce website, you will most probably like to find out a certain product, well this product is stored in a database on this website, and the work of the database is to retrieve this product from the database for you before you can actually see it on your screen. It's quite a process, right? I know...

In conclusion

Accessing a website may seem like a simple task, but it involves a complex series of events that happen in just a few seconds like magic. From the DNS request to the database, every step is critical to ensuring that you can access the website quickly and securely. Understanding the underlying technologies that power the internet can help you appreciate the incredible complexity and power of this vast network of networks.

This post is my submission to a task focused on technical writing as part of the ALX Africa Software Engineering program. I hope you enjoyed it and now appreciate exactly what happens when you type "google.com" or any other domain URL your might be looking for into your browser and what happens in just seconds.

If you would like to connect with me personally, do send me DM on my twitter https://twitter.com/myrajarenga, I would love to hear from you if you enjoyed reading it as I enjoyed writing it. Thank you for your time. You can also support me by following me on this blog

References

https://www.youtube.com/watch?v=FsGUi5pXpLk

https://www.youtube.com/watch?v=hExRDVZHhig

https://www.youtube.com/watch?v=KAt1y4i4OGA

https://youtu.be/zN8YNNHcaZc

https://www.geeksforgeeks.org/how-does-the-internet-work/amp/

https://www.google.com/amp/s/www.geeksforgeeks.org/what-happens-when-we-type-a-url/amp/