What happens when you type google.com in your browser and press Enter?
When we type google.com in our browser and press Enter, The Browser initiates TCP connection with the server. Browser sends the HTTP request to the server. Server processes request and sends back a response.
This may look or sound so easy, but there is a complex process that brings about the response we receive and i am going to share that with you in this post.
1. DNS request
The journey begins with a DNS request when you type “https://www.google.com" in your browser. The browser sends this request to a DNS resolver, which acts as a translator by converting the human-readable domain name, “www.google.com," into an IP address. The resolver first checks its cache for the IP address associated with the domain name. If it doesn’t find the IP address, it contacts other DNS servers to locate the information. The resolver starts with the root server, which knows the location of the Top-Level Domain (TLD) server. In this case, the TLD is “.com.” If the TLD server doesn’t have the IP address, it points the resolver to the Authoritative Name Servers for the domain name. These name servers, which are attached to the domain name, hold the IP address information. Once the resolver obtains the IP address, it sends it back to the browser. The browser can now perform the request to the corresponding server, using the IP address (e.g., 23.172.4.190) obtained from the resolver.
2. TCP/IP
Once the browser obtains the IP address, it utilizes TCP/IP protocols to establish a reliable connection with the destination server. TCP breaks the data into smaller packets, ensuring their reliable transmission, while IP handles the addressing and routing of these packets across the internet. This combined functionality of TCP/IP enables the efficient and accurate transfer of data between the browser and the server, forming the foundation of modern network communication.
3. Firewall
Before reaching the destination web server, the browser’s request may encounter a firewall. Firewalls are software-based security measures that monitor and control network traffic based on predefined rules. In our example, when the browser sends a request to the IP address 23.172.4.190, it is processed by a server-side firewall. The firewall evaluates the request to ensure it adheres to allowed protocols, ports, and security policies. Additionally, the browser itself may have a firewall to detect potential threats by analyzing the IP address obtained from the DNS request. If the request passes the firewall’s security checks, it proceeds to the next step in the process, allowing legitimate traffic while blocking unauthorized or malicious activity.
4. HTTPS/SSL
Now that the browser has the IP address, it focuses on the “https://” prefix in the URL. HTTPS is the secure version of HTTP and is the primary method for transferring data securely between a browser and a website. It encrypts the requests and responses, ensuring that user data is protected and inaccessible to unauthorized parties. This encryption safeguards sensitive information like credit card details, preventing it from being stored in plain text.
Websites use SSL certificates (also known as TLS certificates) to establish secure communication. These certificates are issued by trusted Certificate Authorities, such as Let’s Encrypt, which provides free SSL certificates. When a website has an SSL certificate, users see a lock icon next to the website name in the search bar, and in some cases, the bar turns green. This indicates a secure connection and verifies the website’s identity.
In the case of “https://www.google.com," the connection is encrypted using HTTPS. The browser and the web server perform an SSL/TLS handshake to establish a secure encrypted connection. This involves verifying the server’s identity, exchanging encryption keys, and negotiating the encryption algorithm for the session. By utilizing HTTPS and SSL/TLS, users can trust that their data is protected during the communication between the browser and the website.
5. Load-balancer
To handle high traffic and ensure availability, websites use load-balancers. Load-balancers distribute network requests across multiple servers, preventing a single point of failure. They use algorithms like round-robin or least-connection to evenly distribute requests. Google’s infrastructure, for example, consists of multiple servers to handle user requests. A load-balancer receives requests from browsers and routes them to available web servers, ensuring even workload distribution and optimal performance. Load-balancers are crucial for scalability and allow websites to efficiently handle high traffic volumes.
6. Web server
When a user requests a web page, the request is first distributed to a group of web servers. Each web server then retrieves the requested files, such as HTML, CSS, JavaScript, or images, and prepares them to be sent back to the browser. The web server may also handle any server-side scripting, such as PHP, Python, or Node.js, to dynamically generate content based on the request.
Web servers are responsible for serving static and dynamic content to users who request it.
7. Application server
A web server is responsible for serving static content to users who request it. However, most web applications require more than just static content. They may need to interact with databases, process complex calculations, or perform other tasks that are beyond the capabilities of a web server. In these cases, a web server will need to communicate with an application server.
An application server is a software program that provides a platform for running web applications. It handles complex processing tasks, interacts with databases or external systems, and performs calculations or manipulations on the data. For example, when you perform a search on Google, the application server processes your query, retrieves relevant search results, and sends them back to the web server.
A web server and an application server work together to deliver dynamic web applications to users. The web server serves the static content, while the application server handles the dynamic content.
8. Database
A database management system (DBMS) is a software program that is used to store, retrieve, and manage data in a database. A database is a collection of data that is organized so that it can be easily accessed and used.
There are two main types of database models: relational and non-relational. Relational databases are the most common type of database model. They store data in tables, which are made up of rows and columns. Each row represents a single record, and each column represents a single piece of data about that record.
Non-relational databases are a newer type of database model. They store data in a more flexible way than relational databases. This makes them well-suited for storing large amounts of data or for storing data that does not fit neatly into a relational schema.
When a user requests a web page, the application server interacts with the database server to retrieve the data that is needed to render the page. The database server then returns the data to the application server, which then sends it to the user’s browser.
The choice of database model depends on the specific needs of the web application. For example, a web application that needs to store a large amount of data may be better suited for a non-relational database model.