What happens when you type google.com in your browser and press Enter
You may have been curious about how you enter “google.com” in your browser, and you get the Google webpage delivered to you within a short period, within that short period of time, a lot of data has been transferred and received by your browser. Follow me up as I put you through how your browser interacts with the web server.
Before I proceed, let me explain what a browser is, a browser is a software application that is used to access the web, interpret code, and display webpage content. Examples are Chrome, Safari, Edge, Firefox, etc.
When you enter “www.google.com” in your browser there is a lot of web interaction that happens, but fortunately, it happens within a blink of an eye, even your brain might not even think about it because it happens extremely quickly.
So, let’s summarize what happened within a few seconds, firstly your computer sends a request to the DNS (domain name system) which serves as an address book for domain names and returns the IP address of the URL server.
After knowing the IP address, your computer establishes a connection with the server via the IP address, this connection is known as TCP (Transmission Control Protocol) so, your computer now can establish this connection via the IP. This process is called handshake.
If your computer uses a firewall, the firewall cross-checks if the particular request is allowed before permitting it, likewise the server too, it checks if the request is authorized before you can be able to connect to the server. After the connection is established, the browser now sends a request for the webpage using an encryption protocol like SSL (Secure Sockets Layer) or TLS (Transport Layer Security) to encrypt the data shared between the computer and the server.
A load balancer is required if the website receives high traffic, the load balancer act as a reverse proxy to distribute network or traffic across several servers, so the requests from your web browser will hit the load balancer and forward it to a particular server depending on the load balancer algorithm. After the server receives the request, it responds by sending a response back to the load balancer which will forward the response (response includes HTML, CSS, and JavaScript) back to the browser.
The response returned will tell the browser how to render the content of the web page. The HTML files will tell the browser how to display the content while the CSS will tell the browser how to style it, and the JavaScript will tell the browser how to interact with the content.
If the website has some dynamics content, The web server will send a request to the Application server which might send a request to the database server to fetch so data and send it back to the server, The web server will now have to include the data in the response that will be sent back to the browser, and finally, your browser will show the web page.
What happens when you type google.com in your browser and press Enter
So, let's take each part one after the other with details and the role they played in the process.
DNS Request
The browser always stores information concerning that domain name (DNS record) in its cache whenever you use your browser to access any website.
So, when you enter “www.google.com” into your browser, the browser will first check its caches to see if it has a recent copy of the DNS record for that domain.
If there is an existing copy of the DNS records for that domain, it will use the IP address in the cache to send a request to the server, and if there is no existing copy of the DNS records for that 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.
DNS lookup process
The browser sends a request to the local DNS resolver, which is usually provided by the internet service provider (ISP), then the local DNS resolver checks its cache to see if it has a recent copy of the DNS record for the domain. If it does, it sends the IP address back to the browser.
If the local DNS resolver does not have a recent copy of the DNS record, it sends a request to a root nameserver. The root nameserver responds with the address of a top-level domain (TLD) nameserver, such as .com or .org.
The local DNS resolver sends a request to the TLD nameserver. The TLD nameserver responds with the address of the authoritative nameserver for the domain.
The local DNS resolver sends a request to the authoritative nameserver. The authoritative nameserver responds with the IP address for the domain. The local DNS resolver sends the IP address back to the browser. The browser sends a request to the server at the IP address to retrieve the webpage.
TCP/IP connection
TCP/IP connection is a suite of communication protocols used for connecting devices on the internet. A TCP/IP connection is a network connection established using the TCP/IP protocol suite.
When a TCP/IP connection is established, it uses a combination of the TCP and IP protocols to transmit data between devices. The TCP protocol is responsible for ensuring that data is transmitted reliably and in the correct order, while the IP protocol is responsible for routing data packets between devices.
To establish a TCP/IP connection, a three-way handshake process is used. The process begins with the sender (client) sending a SYN (synchronize) packet to the receiver (server). The receiver responds with a SYN-ACK (synchronize-acknowledge) packet, and the sender responds with an ACK (acknowledge) packet. Once this three-way handshake is complete, the TCP/IP connection is established, and data can be transmitted between the devices.
TCP/IP connections are widely used for internet communications, such as web browsing, email, and file transfers. They are also used in local area networks (LANs) and wide area networks (WANs) for connecting devices and enabling communication between them.
Firewall
A firewall is a security device that monitors and controls incoming and outgoing network traffic based on predefined security rules. When you enter a website address in your browser and press Enter, the firewall on your computer or network may inspect the outgoing request to ensure that it meets the security requirements.
Firewalls work by analyzing the packets of data that are transmitted between your computer and the server hosting the website. They can block incoming traffic that doesn't meet predefined security criteria, such as traffic from suspicious IP addresses or traffic that matches known attack patterns.
Firewalls can also block outgoing traffic that doesn't meet security requirements, such as traffic that contains sensitive data or traffic that violates company policies. In addition, firewalls can prevent unauthorized access to your computer or network by blocking incoming traffic that attempts to exploit vulnerabilities in your system.
Firewalls can be implemented at various levels of the network infrastructure, including at the host level, the network level, and the application level. Host-based firewalls run on individual computers and can provide an additional layer of security against malicious software or hackers.
Network firewalls are located at the perimeter of the network and can protect against incoming traffic that is trying to penetrate the network. Application firewalls are designed to protect specific applications, such as web servers, from attacks that exploit vulnerabilities in the application.
HTTPS/SSL
HTTPS (Hypertext Transfer Protocol Secure) is a secure version of the HTTP protocol used to transmit data on the internet. It is used to encrypt the data transmitted between your browser and Google's server.
SSL (Secure Sockets Layer) and TLS (Transport Layer Security) are encryption protocols that are used to secure the data transmitted over HTTPS.
When your browser establishes a connection with Google's server using HTTPS, your browser and Google's server first agree on the version of SSL/TLS to use and then create a secure, encrypted channel for transmitting the data.
Let me use an analogy to explain what is going on here.
HTTPS is like a locked box that is used to send messages over the internet. When you want to send a message using HTTPS, you put the message in the locked box and send it to the person you want to receive the message. Only the person you are sending the message to has the key to unlock the box and read the message.
SSL/TLS are like special codes that are used to lock and unlock the box. When you want to send a message using HTTPS, you and the person you are sending the message to agree on the code to use to lock and unlock the box. This way, only you and the person you are sending the message to know the code and can read the message.
When you type "google.com" into your browser, the browser is like the person sending the message. The server that hosts google.com is like the person receiving the message. The browser sends a request for the webpage using HTTPS, which is like putting the request in a locked box and sending it to the server. The server then sends the webpage back to the browser using HTTPS, which is like putting the webpage in a locked box and sending it back to the browser.
Load-balancer
A load balancer is a device that distributes incoming network traffic across a group of servers or resources.
Its primary function is to ensure that the traffic is distributed evenly across the servers in order to avoid overloading any single server and to increase the overall capacity and reliability of the system.
A company like Google, which receives billions of website visitors a day, will need a lot of servers to serve all these users. Therefore, there will be a need for them to set up a load balancer to ensure that some of the servers are not overburdened while others are being underutilized.
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. The particular server chosen will depend on the type of load balancing algorithm implemented.
Web server
A web server is a computer program that is responsible for handling requests for web pages from clients (such as a browser trying to access google.com). When a client sends a request for a web page to a web server, the server processes the request and returns the appropriate response to the client.
This means that when trying to access google.com, Google's server will receive a request from the load balancer.
The web server would then process the request and generate a response, which would typically include the HTML, CSS, and JavaScript files that make up the web page.
The web server would then send this response back to the load balancer, which would forward it on to the browser. The browser would then use the HTML, CSS, and JavaScript files to render the web page for the user.
Application server and database (if applicable)
Unlike the web server, the application server handles dynamic content. When using "google.com", the application server will be responsible for generating the search results (which change based on the query you put into the search engine).
When you submit a search query to Google, the request is first sent to the load balancer, which forwards it to one of the web servers in the Google server network. The web server then sends the request to the application server, which processes the request and generates the search results.
Depending on the complexity of the search query, the application server may need to make a request to a database in order to retrieve the necessary data.
For example, if you are searching for a specific product on an e-commerce website, the application server may need to retrieve information about the product from a database.
Once the application server has obtained the necessary data, it sends it back to the web server, which includes it in the response that is sent back to the the browser. The browser then uses this information to display the search results to you.
Rendering the page
When a browser receives a response from a web server, it processes the HTML, CSS, and JavaScript files that are included in the response in order to render the web page.
The rendering process involves interpreting the HTML and CSS code, rendering any images or other media that are included on the page, and executing any JavaScript code that is present on the page.
In your case, your browser would receive the response from the web server, which includes the HTML, CSS, and JavaScript files that make up the Google web page.
The browser would then use these files to render the page and display it to you. This process typically involves the following:
displaying the text and images on the page in the appropriate positions
formatting the text and layout according to the CSS styles
executing any JavaScript code that is present on the page
Once the page has been fully rendered, you can now interact with it by clicking links, entering text, or interacting with other elements on the page.
Conclusion
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" into your browser.