The Life of a Web Request: How Websites Speak to Servers

Before diving into the journey of a web request, familiarize yourself with this tech jargon.

  • Client: A device or software that sends requests to a server.

  • Server: A system that processes requests and sends responses to clients.

  • Request-Response Model: The communication pattern where the client sends a request, and the server responds.

  • Protocol: A set of rules for communication between devices (e.g., HTTP, TCP/IP).

  • Packet: A unit of data transmitted over a network.

  • IP Address: A unique identifier for a device on a network.

  • Port: A communication endpoint used by protocols to route data (e.g., port 80 for HTTP).

  • Latency: The delay between sending a request and receiving a response.

  • Throughput: The amount of data transmitted successfully over a network in a given time.

The journey of a web request is more complex than it may seem to most people. It’s not just about sending a request to the server and getting a response back; several important steps happen along the way

  1. Domain Name Lookup (DNS)

  2. Connection Establishment (Handshake)

  3. Data Segmentation

  4. Protocol Selection

  5. Routing

  6. Server Processing

  7. Packet Reassembly

  8. Rendering the Response

The request-response model is a fundamental concept in network communication, particularly in web development. It describes the interaction between a client and a server over a network.

DNS Resolution

Before sending a request to the server, the browser doesn’t know where to send it or what is the server's IP address is. This is where DNS (Domain Name System) comes into play. When you enter a URL in the browser, it sends the domain name (the human-readable website address) to DNS, asking, "Please provide me with the IP address for this site."

The DNS query is then sent to a root server (there are only 13 root servers globally). This root server responds by providing the address of the top-level domain (TLD) server. For example, if you're searching for google.com, the root server will return the address of the .com TLD server.

Next, DNS forwards the request to the authoritative name server—the server that manages the domain records. This server holds a list of all the domains within its category. It checks which specific server the domain is pointing to and returns the correct IP address of the server where the domain is hosted.

Finally, DNS sends the IP address back to the browser, allowing it to proceed with requesting the server for the website's content.

Handshake

A handshake is a process that occurs at the beginning of a communication session between two devices (such as a client and a server) to establish a connection and ensure that both parties are ready to exchange data

The most common example is the three-way handshake used by TCP to establish a connection between a client and a server. Here’s how it works:

  1. SYN (Synchronize):

    • The client sends a SYN message to the server, indicating it wants to start a connection.
  2. SYN-ACK (Synchronize-Acknowledge):

    • The server responds with a SYN-ACK message, acknowledging the client's request and indicating that it's ready to communicate.
  3. ACK (Acknowledge):

    • The client sends an ACK message to the server, confirming that the connection is now established.

Data segmentation

Data segmentation is the process of breaking down larger pieces of data into smaller, more manageable units called packets for transmission over a network.

Imagine you're sending a large file over the internet. Instead of sending the entire file as one big block, the file is divided into smaller packets. Each packet contains part of the file's data and is labeled with information such as its sequence number, so it can be reassembled correctly at the destination.

In the TCP/IP protocol, this segmentation process occurs at the Transport Layer, where data is broken into packets, each of which is sent over the network, potentially through multiple routes, and finally reassembled at the destination.

Packet Structure:

Each packet typically contains:

  • Header: Information about the packet, such as the source and destination addresses, sequence number, and other routing information.

  • Payload: The actual data being sent in the packet.

  • Footer (optional): Error checking information (e.g., checksums) to ensure the integrity of the data.

Segmentation of data into packets Algorithm 1 describes the proposed... |  Download Scientific Diagram

Protocol Selection

Choosing the appropriate protocol is critical because different protocols serve different purposes. Depending on the type of data, the need for reliability, speed, or error handling, the selected protocol will determine how efficiently and securely the communication happens.

Common Protocols:

Here are a few common protocols used in data transmission:

  1. HTTP (Hypertext Transfer Protocol)

  2. HTTPS (Hypertext Transfer Protocol Secure)

  3. TCP (Transmission Control Protocol)

  4. UDP (User Datagram Protocol)

  5. FTP (File Transfer Protocol)

  6. SMTP (Simple Mail Transfer Protocol)

  7. DNS (Domain Name System)

Routing

Routing is the process of selecting paths in a network along which data packets are sent from the source (like your computer or a server) to their destination (like a website or another device)

When data is divided into packets and transmitted over a network, each packet needs to travel through multiple devices and network links before reaching its destination. Routing determines the path these packets should take.

Server processing

Server processing refers to the series of actions that a server performs when it receives a request from a client (such as a web browser or application).

Let’s say a user visits a website by entering a URL in their browser:

  1. Request: The browser sends an HTTP request to the server for a webpage (e.g., GET /index.html).

  2. Authentication: If the page requires a login, the server checks the session or cookies to ensure the user is logged in.

  3. Database Query: The server queries a database to fetch the latest blog posts or user-specific data.

  4. Generate Response: The server generates the HTML content for the webpage, including the blog posts, and adds the necessary CSS and JavaScript.

  5. Send Response: The server sends the HTML response back to the browser, which displays the page for the user.

  6. Logging: The server logs the request for monitoring and analysis.

Packet reassembly

Packet reassembly is the process of reconstructing the original data from smaller packets that have been transmitted over a network. When data is sent over a network

Packet reassembly is a crucial process in networking that reconstructs data from smaller packets that were sent over a network. It ensures that data is accurately reassembled, even when packets arrive out of order or some are lost. This process is essential for maintaining the integrity of data transmission, particularly in reliable protocols like TCP.

Rendering a response

Rendering a response is the process of transforming processed data (like HTML, JSON, or any other format) into a viewable or usable format for the client. In web development, this typically means generating and displaying a webpage, while in other contexts, it might involve sending structured data or preparing files for download. It is a key part of the server-client communication process that ensures the client receives the appropriate output after a request is made.

Client-Server Overview - Learn web development | MDN

Understanding these steps helps you appreciate how data travels across the web. From DNS resolution to server processing, every part of the journey is crucial in ensuring a smooth and successful interaction between clients and servers.

If you notice any mistakes, please provide your feedback.😊🙏