...

/

Client-Server Communication Protocols

Client-Server Communication Protocols

Understand different client-server communication protocols essential for frontend System Design.

The internet is a global network of interconnected computers that enables communication and data exchange using standardized protocols like TCP/IP. The World Wide Web (WWW) is a system of interlinked documents and resources accessed via the internet using protocols like HTTP and HTTPS. The interconnected computers over the WWW are broadly divided into two categories–clients and servers. The clients request resources from the server, and the server entertains the requests based on certain conditions. This communication between the client and server is carried out with the help of an APIApplication programming interface. One might use many technologies for client-server communication, but we’ll focus on the HTTP, RPC, and WebSocket protocols.

We’ll start with the HTTP protocol, which is the primary use case in most applications. The other two (RPC and WebSockets) are used extensively in different use cases. We believe these three collectively cover the major concepts of client-server communications.

Web protocols

In frontend System Design, well-defined web protocols ensure seamless interoperabilityInteroperability here means that different browsers, devices, and frontend applications can communicate with backend services regardless of their underlying implementations. between the browser (client) and server, allowing smooth data exchange and user interactions.

Web protocols operate over TCP/IP, where a user clicks a link on a web page, and the browser uses DNS to resolve the domain name to its corresponding IP address before connecting to the server. It then establishes a TCP connection, initiates a TLS handshake (if using HTTPS), and requests the web page and any related resource. Finally, the browser renders the page, closing the TCP connections. This information flow between clients and servers is facilitated by a hypertext transfer protocol (HTTP) protocol, as shown below:

Press + to interact
A bird’s eye view of client-server communication using HTTP protocol
A bird’s eye view of client-server communication using HTTP protocol

Application-layer protocols such as the file transfer protocol (FTP), simple mail transport protocol (SMTP), HTTP, and so on use lower-layer protocols like transmission control protocol (TCP), user datagram protocol (UDP), and internet protocol (IP) to provide services to end users.

Let’s explore how HTTP protocol works and enables client and server communication.

Hypertext transfer protocol (HTTP)

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 for distributed and hypermedia information systems. It’s the foundation of data communication and is considered the de facto standard for client-server resource sharing. Web servers and client applications (browsers) must adhere to the message formats and transmission methods provided ...