What happens when you type google.com in your browser and press "Enter"

What happens when you type google.com in your browser and press "Enter"

Every time we start a web browser (Chrome, Firefox, Safari, etc.) and type in a domain name like "google.com," typically, the browser returns a webpage in a matter of seconds. The question is, do we understand what occurs in the background? How is it possible to enter a website on a web browser and instantly get results?

The technical or more unified term, to describe what goes on behind the scene when we type in google.com is known as the web infrastructure.

The purpose of this article is to provide a detailed explanation of what occurs when we enter the domain name "google.com", or any other domain name, into a web browser.

What is a web infrastructure?

Website Infrastructure means the servers, networks, and other underlying infrastructure supporting the Website.

Although website and domain names are used interchangeably, they are not the same. A website is a collection of related web pages that are typically hosted on a single web server, while a domain name is a human-friendly label used to identify a particular website.

I would like to point out that "google.com" is a domain name used to access the google website(collection of related pages) that is stored on a server, and these server/servers are located with IP addresses. This IP address is what computers and devices use to communicate with each other on the internet. An IP address (192.168.1.1) is the address of the computer/server where a website is stored.

Therefore to access the "google.com" website, the browser has to first find the IP address of the server "google.com" is hosted on, so it can then connect to the server and retrieve the web pages that make up the website. The browser can use a DNS (Domain Name System) server to look up the IP address associated with "google.com".

Yes, this might look a little complex, hang in there! To better understand this process, we would break down web infrastructure into smaller concepts, to holistically understand web infrastructure and how it works.

DNS request

When a user types "google.com" on their browser they are submitting a DNS request. This DNS request maps a domain name to an IP address. Each computer or device connected to the Internet has a unique IP address that they use to locate or communicate with themselves. Humans cannot remember IP addresses hence the need for domain names.

This mapping is done through several recursive steps that end once the IP address of the website is found. The first step to map a domain name to its IP address is;

  1. The browser first searches its cache to see if the website has been visited before. (see this link on How caching works )

  2. If the website is not stored in the browser's cache, the browser searches the operating system for the IP address.

  3. If not found in the OS, the browser sends a request to four DNS servers that recursively search until the IP address is found. This cartoon gives a fun and in-depth explanation of how DNS works How DNS works

HTTPS/SSL

Once the IP address is found from the DNS request, the browser needs to send requests to the server where the website is stored, this is done by sending an HTTP/HTTPS request to the server.

Kindly note that before an HTTP request can be sent some prerequisites have to be in place, which we would discuss ahead.

HTTPS (HTTP Secure) is a protocol for secure communication over the internet. It is essentially the same as HTTP (the regular, unsecured version of the protocol), but with an added layer of security provided by SSL (Secure Sockets Layer). The browser sends an HTTP/HTTPS request to the server. If the server approves the request, the server sends the client a "200 OK" message, which means "Yes! The client can look at that website". And then the server starts sending "google.com" files to the client’s browser as a series of small chunks called data packets that appear to clients as web pages.

HTTPS and SSL work together to provide a secure communication channel for exchanging data between a client and a server. To ensure an HTTPS request, SSL has to be in place. How this works is that when the client sends a request to a server using HTTPS, the server responds by sending back a digital certificate. The certificate contains the server's public key, as well as information about the identity of the server and the organization that runs it. The client verifies the certificate to make sure that it is valid and issued by a trusted source (such as a trusted certificate authority) and then uses the public key in the certificate to establish an encrypted connection with the server. Once the connection is established, the client and server can exchange data securely.

TCP/IP

TCP/IP is one of the prerequisites necessary for an HTTP/HTTPS request to be established. HTTP/HTTPS requests are sent over the TCP/IP connection. TCP/IP stands for Transmission Control Protocol and Internet Protocol. It is a set of rules that govern how computers communicate with each other over a network, such as the internet. TCP is responsible for ensuring that data (data packets) shared between the computer and server are delivered reliably and in the correct order.

Firewall

Another prerequisite for secure communication between server and client is the firewall. To protect the client's connection to the server from being intercepted by cyberattacks or malware, there needs to be a firewall. A firewall is a security device that is typically used to control incoming and outgoing network traffic between the computer and the server. It is often placed at the border of a computer network, between the internal network and the Internet. It is used to control access to the web server by only allowing incoming traffic to the web server from specific IP addresses or ranges of addresses. It is also used to protect other devices on the network by blocking incoming traffic that is known to be malicious.

Server (Web server, Application server, Database Server)

A server is a computer or group of computers, configured to handle requests made over the internet or a local network. When you as a client make an HTTP/HTTPS request for a webpage or other resource, the request is sent to a server, which then processes the request either as a web server, or application server, and sends back the appropriate response.

Different types of servers can be used in web infrastructure, some of them are web servers, application servers, file servers, and database servers. Servers are typically configured to be any of these types of servers. We would be discussing the web, application, and database server.

Web server

These servers are used to host and deliver web pages. They receive requests from client browsers and respond with the requested HTML, CSS, and JavaScript files (also called static files) that are used to render the web page to the browser. Common types of web servers are Apache, Nginx, and IIS. The HTTP/HTTPS request goes to the web server. When a client, sends an HTTP request to a web server, the web server looks up the requested file in its file system and sends it back to the client in an HTTP response. If the requested file is not found, the server will typically return a "404 Not Found" error.

Application server

While web servers respond with static content, application servers are responsible for delivering dynamic web pages to the client. Dynamic content refers to the functionality of a website/ web application. Application servers provide an environment to run code such as java or PHP to implement business logic such as authorization and authentication, transactions, business rules, and data processing. The application server handles the communication between the client and the database server and also provides a wide range of services to the web application. Application servers can run any kind of application, it can be in form of a web application, mobile application, or even a desktop application.

Database server

A database server is typically the bottom tier in a three-tier architecture, with the client as the top tier, the application server as the middle tier, and the database server as the bottom tier. The application server communicates with the database server to perform operations such as retrieving data or saving data. A database server is a computer program that provides access to a database. It is the backbone of any database-driven application and is responsible for storing, managing, and retrieving data. Popular database servers are MySQL, PostgreSQL, SQL Server, Oracle, MongoDB, etc. A database server is a central component of most data-driven applications and is responsible for managing large amounts of data and ensuring data integrity and consistency.

Load balancer

Websites like googlle.com have more than one server so they can offer a higher level of reliability and availability to clients than a single-server environment.

If one server in a multi-server environment goes down, the other servers can continue to provide access to the services and applications that users need.

A load balancer is a system that distributes incoming traffic from the client to multiple servers. This helps prevent any single server from becoming overwhelmed with too much traffic, which can lead to slow performance or even crashes. Instead, the load balancer spreads the traffic across multiple servers, allowing them to work together to handle the increased demand. Thousands, even millions of people want to access google.com at a time, the load balancer is what helps distribute the traffic to the servers hosting google.com. It helps ensure that the overall system stays up and running, even if one server goes down. It also helps to improve the overall performance and responsiveness of the system.

Here is an image that depicts how the web infrastructure works.

In conclusion, we now know that when we type in “google.com” and press enter, the web browser goes through several steps to deliver the result to us. The seemingly instant task of typing “Google.com” on your browser pressing Enter and seeing the result in seconds isn’t so instant after all. It takes several steps which to render web pages, follow specified protocols to render the web page, and maintain the servers rendering the web pages. Hopefully the next time you type in google.com or any domain name, you can appreciate the beauty of web infrastructure.