Search⌘ K
AI Features

Different Ways of Client-Server Communication

Understand the foundational client-server communication models including HTTP, RPC, and WebSocket protocols. Learn how each method functions, their benefits and limitations, and their roles in building efficient, real-time, and scalable APIs. Master HTTP versions evolution and practical usage for API design.

The World Wide Web and client-server foundations

The internet is a global network of computers that communicate via standardized protocols. The World Wide Web (WWW) refers to interlinked resources stored across these machines, which are broadly accessed by clients (requesting resources) and servers (providing them). This communication relies on APIs built atop foundational protocols. Three protocols cover the major abstractions of client-server communication: HTTP, RPC, and WebSockets.

The WWW is a hypertext-based information system that interlinks documents across millions of machines. Launched at CERN in 1989 from Tim Berners-Lee's proposal, its first text-based prototype led to Marc Andreessen's Mosaic graphical browser in February 1993, catalyzing the web's transformation of information sharing and networking.

1.

What is the difference between the internet and the web?

Show Answer
Did you find this helpful?

Core web concepts

The web rests on four foundational ideas:

  • Client-server model: The client requests a resource; the server provides it. For example, a browser (client) queries a DNS server for the IP address of www.educative.io, and receives 104.18.3.119.

  • Resource identifiers: A unique identifier locates resources (files, documents) over the internet. For example, https://www.educative.io/courses/grokking-modern-system-design-software-engineers-managers/g7EwEyNnR6D points to a specific lesson.

  • Hypertext and hypermedia: Hypertext contains nonlinear links between documents. Hypermedia extends this with multimedia content (graphics, video, audio, and interactive elements).

  • Markup language: A set of symbols inserted in a text document to define its structure, formatting, and connections between parts (e.g., HTML).

HTML
<html>
<head>
<style>
h2 {text-align: center;}
p {text-align: center;}
div {text-align: center;}
</style>
</head>
<body>
<h2>This is heading 2 center aligned.</h2>
<p>A simple text that is center aligned. </p>
<div> This is a section </div>
</body>
</html>

Note: Browsers render web pages by parsing markup languages, such as the one described above.

Web protocols

The client-server model requires well-defined protocols for interoperable communication. The client (typically a browser) displays data received from the server as a web page, with information flow governed by the Hypertext Transfer Protocol (HTTP).

Application-layer protocols like FTP, SMTP, and HTTP rely on lower-layer protocols (TCP, UDP, and IP) to deliver services to end users.

How the web works

From a user's perspective, the web is a collection of pages containing links to objectsText, images, audio, videos, advertisements, and tracking scripts. stored across the internet. ClientsClients are not limited to web browsers; they can also make requests through terminals and other applications. run browser software, while servers run web server software to respond to requests. Web servers operate on clusters of commodity machines (or high-end machines), giving each user the illusion of dedicated service while drawing on backend services like databases, blob storage, and application servers.

A bird’s-eye view of the working of World Wide Web
A bird’s-eye view of the working of World Wide Web

Every device is identified by an Internet Protocol (IP) address. When a client sends a request, the server responds to the same client, identified by a five-tuple (source IP, source port, protocol number, destination IP, and destination port). The browser then renders the received data as a web page.

Client-side process

Resources are identified using a Uniform Resource Identifier (URI) consisting of three parts:

A URI of a web page for the domain www.educative.io
A URI of a web page for the domain www.educative.io
  • Protocol: e.g., HTTPS, used to fetch the web page.

  • Domain name: The DNS name that indicates where the resource is located.

  • Unique path: Determines the specific resource within a domain.

The browser fetches a web page through the following sequence:

  1. The browser determines the URL, e.g., www.educative.io.

  2. It queries the DNS server for the corresponding IP address.

  3. The DNS server returns the web server's IP address.

  4. The browser establishes a TCP connection with that IP address.

  5. The browser sends an HTTPS request for the web page.

  6. The server responds. If the page contains URLs for additional objects, the browser fetches them using the same process.

  7. The browser renders the web page.

  8. TCP connections are terminated after all resources are fetched.

The client clicks on a link
1 / 8
The client clicks on a link

Server-side process

Servers constantly listen for client requests. Upon receiving one, the server retrieves the resource from a database or cache and returns it:

  1. Accept a TCP connection from the client.

  2. Receive the request for a resource identified by a unique URI.

  3. Populate the web page from the database or cache.

  4. Send the content back as an HTTP response.

  5. Terminate the TCP connection.

1.

What’s the difference between static and dynamic web pages?

Show Answer
Did you find this helpful?

Hypertext Transfer Protocol (HTTP)

With the web's client-server model established, the protocol governing their communication deserves closer examination. The Hypertext Transfer Protocol (HTTP) is a statelessA stateless protocol is one in which each request is considered independent of any other request. This makes it simple to implement. application-layer protocol and the foundation of data communication for the World Wide Web. Web servers and browsers must adhere to HTTP's message formats and transmission methods.

HTTP operates on a request-response model: the client sends HTTP commands, and the server responds with documents. These commands are structured by different API architecture styles discussed in later chapters. As long as a request conforms to HTTP standards, the server responds regardless of client type, enabling cross-platform interoperability.

The request and response behavior of HTTP
The request and response behavior of HTTP

HTTP message flow

HTTP communication begins ...