Wednesday, July 17, 2024

What Happens When You Type https://www.google.com in Your Browser and Press Enter

 

What Happens When You Type https://www.google.com in Your Browser and Press Enter
What happens when you type Google in a web browser address bar and press  enter? - Quora

Understanding the process that takes place when you enter a URL into your browser is crucial for any software engineer. This post will walk you through the journey of a web request from your browser to the server and back, covering key components like DNS, TCP/IP, Firewalls, HTTPS/SSL, Load Balancers, Web Servers, Application Servers, and Databases.

1. DNS Request
DNS servers: what they are and how they ...

Domain Name System (DNS) is like the phonebook of the internet. When you type https://www.google.com, the browser needs to translate this human-readable domain into an IP address that machines understand.

  1. Browser Cache: First, the browser checks its cache to see if it has recently visited https://www.google.com and stored the corresponding IP address.
  2. OS Cache: If the browser cache is empty, the browser asks the operating system, which also has a DNS cache.
  3. Router Cache: If the OS cache is empty, the request moves to your router, which might also have a cache.
  4. ISP DNS Server: If the router doesn’t have the record, the request goes to the ISP’s DNS server.
  5. Recursive Search: If the ISP’s DNS server doesn’t know, it starts a recursive search, querying other DNS servers until it finds the authoritative DNS server for google.com, which provides the IP address.

2. TCP/IP
TCP/IP Model - GeeksforGeeks

Once the IP address is found, the browser needs to establish a connection to the server using the Transmission Control Protocol (TCP) and Internet Protocol (IP).

  1. TCP Handshake: A TCP connection is established using a three-way handshake:
    • SYN: The browser sends a SYN (synchronize) packet to the server to initiate the connection.
    • SYN-ACK: The server responds with a SYN-ACK (synchronize-acknowledge) packet.
    • ACK: The browser sends an ACK (acknowledge) packet back to the server, and the connection is established.
  2. IP Routing: Data packets are routed through various intermediate routers to reach the destination server.

3. Firewall
How Firewalls Work | HowStuffWorks

Firewalls are security systems that monitor and control incoming and outgoing network traffic based on predetermined security rules. Both your device and the server have firewalls.

  1. Client-side Firewall: Ensures that only authorized outgoing requests are allowed from your device.
  2. Server-side Firewall: Protects the server from malicious incoming traffic by allowing only legitimate requests.

4. HTTPS/SSL
SSH using TCP tunneling over HTTP ...

HTTPS (Hypertext Transfer Protocol Secure) ensures that data transmitted between your browser and the server is encrypted using SSL/TLS (Secure Sockets Layer/Transport Layer Security).

  1. SSL Handshake: Establishing a secure connection involves:
    • ClientHello: The browser sends a ClientHello message to the server, initiating the SSL handshake.
    • ServerHello: The server responds with a ServerHello message, providing its SSL certificate.
    • Certificate Verification: The browser verifies the server’s certificate against its trusted Certificate Authorities (CAs).
    • Key Exchange: Both parties generate session keys for encryption.
  2. Secure Connection: Data is encrypted and decrypted using the session keys, ensuring secure communication.

5. Load Balancer
What is a load Balancer and its Types ...

Load Balancers distribute incoming network traffic across multiple servers to ensure no single server becomes overwhelmed, improving availability and reliability.

  1. Traffic Distribution: The load balancer receives the request and decides which server to forward it to based on various algorithms (e.g., round-robin, least connections).
  2. Health Checks: Continuously monitors the health of servers to ensure requests are sent only to healthy servers.

6. Web Server

The Web Server (e.g., Apache, Nginx) handles the incoming request and serves static content (HTML, CSS, JavaScript, images).

  1. Request Handling: Receives the HTTP request from the load balancer.
  2. Static Content: Serves static files directly if the request is for static content.
  3. Forward Request: If dynamic content is needed, forwards the request to the application server.

7. Application Server
Web Server and Its Type - GeeksforGeeks

The Application Server (e.g., Node.js, Django, Ruby on Rails) processes dynamic content, executes business logic, and interacts with the database.

  1. Processing Request: Executes the server-side code to generate dynamic content.
  2. Business Logic: Performs necessary computations, logic, and decision-making based on the request.
  3. Database Interaction: Queries the database for any required data.

8. Database
Database Design Bad Practices | Toptal®

The Database (e.g., MySQL, PostgreSQL, MongoDB) stores and retrieves data as requested by the application server.

  1. Query Execution: The application server sends SQL or NoSQL queries to the database.
  2. Data Retrieval: The database fetches the requested data and sends it back to the application server.
  3. Data Storage: Stores any new or updated data as requested by the application server.

Conclusion

The process that occurs when you type https://www.google.com in your browser and press Enter involves multiple steps and components working together seamlessly. Understanding this workflow not only helps you appreciate the complexity of web interactions but also prepares you for technical interviews and real-world problem-solving in software engineering.

No comments:

Post a Comment

Car Collision Game: My Journey as a Developer

  Car Collision Game: My Journey as a Developer Project: Car Collision Game Developer & Designer: Amira Sayed Mohamed Ali The Road to ...