What happens when you type google.com in your browser and press Enter
Have you ever wondered what happens behind the scenes when you type “https://www.google.com" into your web browser? It’s like a magic show, except instead of pulling rabbits out of hats, you’re pulling websites out of the internet. In this blog, we’ll take a peek behind the curtain and uncover the technical details of how your web browser communicates with Google’s servers to retrieve the search engine’s homepage. So sit back, relax, and get ready to be amazed by the inner workings of the internet.
DNS Request
The first step is to resolve the domain name “www.google.com" into an IP address. This is done through a DNS (Domain Name l, which acts as a distributed database for translating human-readable domain names into machine-readable IP addresses. Your browser sends a DNS request to a DNS server, which looks up the IP address associated with the domain name and sends it back to your computer.
TCP/IP
With the IP address in hand, your computer initiates a connection to Google’s servers using a protocol called TCP/IP (Transmission Control Protocol/Internet Protocol). This involves a three-way handshake. The three-way handshake is a sequence that allows your computer and Google’s servers to establish a reliable connection. Here’s how it works:
- SYN: When your computer wants to establish a TCP connection with Google’s servers, it sends a SYN (synchronize) packet to the server. This packet includes a random sequence number that will be used to identify the connection.
- SYN-ACK: When Google’s servers receive the SYN packet, they respond with a SYN-ACK (synchronize-acknowledge) packet. This packet includes an acknowledgement number confirming receipt of the SYN packet and a new random sequence number for the connection.
- ACK: When your computer receives the SYN-ACK packet, it returns an ACK (acknowledge) packet to Google’s servers. This packet includes the acknowledgement number from the SYN-ACK packet, confirming that the connection has been established.
Firewall
Before the connection is established, it passes through a firewall. The firewall is a network security device that monitors and filters incoming and outgoing network traffic based on predefined rules. Its job is to protect your computer and network from unauthorised access and malicious attacks. The firewall inspects each packet of data transmitted between your computer and Google’s servers, filters out any traffic not allowed by the predefined rules, and logs all network traffic that passes through it.
HTTPS/SSL
Once the connection is established, your browser sends an HTTPS request to Google’s server. HTTPS (Hypertext Transfer Protocol Secure) is a secure version of the standard HTTP protocol that encrypts data between your browser and the webserver to prevent eavesdropping, tampering, and data theft. HTTPS uses a protocol called SSL/TLS (Secure Sockets Layer/Transport Layer Security) to establish a secure connection. The SSL/TLS protocol involves a handshake where your browser and the web server exchange digital certificates and negotiate an encryption algorithm to use for the session.
Load-balancer
Google’s servers are likely to be spread across multiple data centres to balance the load between them; a load-balancer is used. A load balancer distributes incoming network traffic across multiple servers to prevent one server from becoming overwhelmed. The load balancer also performs health checks on the servers to ensure they operate correctly.
Web Server
The HTTPS request is received by a web server responsible for serving up web pages to clients like your browser. The web server processes the request, retrieves the requested resources, and generates an HTTP response that includes the requested web page and any other resources needed to render it, like images, scripts, and stylesheets.
Application Server
Sometimes, the web server passes the request to an application server, which performs additional processing before returning the HTTP response. For example, an application server might handle requests for dynamic content like user authentication or database queries.
Database
If the web page requires data from a database, the application server queries the database to retrieve the necessary data. The database returns the data to the application server, which generates the final HTTP response.
Retrieving a web page from a server involves many components and protocols, including DNS, TCP/IP, firewalls, HTTPS/SSL, load-balancers, web servers, application servers, and databases. By understanding these components and how they work together, you can better understand how the Internet works and how web applications are built.