Introduction to Backend Communication Protocols(Software Development)

Keith OwiraKeith Owira
4 min read

When it comes to software development and server side rendering in particular , the communication protocol in use is of high importance and will heavily influence the application architecture and speed as well. The choice of a communication protocol is equally determined by the specific app requirements such as the need for real-time communication, efficiency, scalability, and the nature of the data being exchanged. For instance amount of data required and retreived can drive the difference between GraphQL and REST (Representational State Transfer) as a choice of communication protocol used.

The communication protocols are defined by the communication design pattern that they follow. Communication design patterns in software development refer to the ways in which different components or systems interact and exchange data. The choice of the design pattern depends on the specific requirements of the application. Some of the common design paterns include :

  • Request-Response Pattern: A client sends a request to a server, and the server responds with the requested data or performs the requested action. — Protocols: HTTP, HTTPS, REST, gRPC.

  • Publish-Subscribe Pattern: A publisher sends messages to multiple subscribers without knowing who or what they are. Subscribers express interest in certain types of messages. Commonly used in IOT system implementations — Protocols: MQTT, AMQP, WebSocket.

  • Peer-to-Peer Pattern: Direct communication between equal peers without a central server. — Protocols: BitTorrent, some aspects of WebSocket.

  • Remote Procedure Call (RPC) Pattern: Allows a program to cause a procedure (subroutine) to execute in another address space (common in distributed systems). — Protocols: gRPC, XML-RPC, JSON-RPC.

  • Streaming Pattern: Continuous flow of data in real-time, enabling applications to consume or produce data as it becomes available. — Protocols: WebSocket, gRPC with streaming, Server-Sent Events (SSE).

Lets do a brief discussion on some of the common communication protocols used in most applications and use cases on each. All communication protocols ride under the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) which are communication standards that enables application programs and computing devices to exchange messages over a network.

  • HTTP/HTTPS (Hypertext Transfer Protocol/Secure)

HTTP and its secure version, HTTPS, are communication protocols used for transferring hypertext and other data between a client and a server over a network. HTTP is stateless, meaning each request from a client to a server is independent and not affected by previous requests, the application works on layer 7 of the OSI model. They are used by web browsers as the foundation of data transfer on the world wide web. Web browsers use it to retreive web pages from the server. Commonly used data formats include json and xml.

  • Web-sockets

Web-sockets provide a full-duplex communication channel over a single, long-lived connection between a client (typically a web browser) and a server. Unlike traditional request-response communication models, where the client sends a request and the server responds, WebSockets enable bi-directional communication, allowing both the client and server to send messages independently at any time.The connection is persistent and remains open, enabling real-time bidirectional communication.They are commonly used by real-time applications, such as chat applications, online gaming, collaborative editing, live streaming, social media platforms or news websites, where users want to be instantly notified of new messages or updates. They are commonly used where low latency and instant updates are crucial.

  • REST (Representational State Transfer)

REST is an architectural style that uses standard HTTP methods (GET, POST, PUT, DELETE) for communication. It relies on stateless communication and typically uses JSON or XML for data exchange. RESTful APIs are common in web development.

  • GraphQL

GraphQL is a query language for APIs and a runtime for executing those queries with existing data. It allows clients to request only the data they need, which can lead to more efficient and flexible communication between the frontend and backend. It typically uses JSON for data exchange. Clients define the structure of the response, reducing over-fetching or under-fetching of data.GraphQL APIs typically have a single endpoint for all queries and mutations, making it more flexible than REST in terms of data retrieval.

  • gRPC

It provides a powerful and efficient mechanism for communication between distributed systems. gRPC uses HTTP/2 as the transport protocol and Protocol Buffers (protobuf) as the interface definition language. gRPC is particularly well-suited for microservices architectures, where services need to communicate efficiently and reliably.

  • RPC: Remote Procedure Call is a protocol that one program can use to request a service from a program located on another computer in a network.

  • gRPC Implementation: gRPC facilitates communication between client and server applications using RPC, enabling them to invoke methods on each other as if they were local.

  • HTTP/2: gRPC uses HTTP/2 as its underlying transport protocol, which provides features like multiplexing, header compression, and bidirectional streaming. To read more on gRPC you can acces its documentation form the official website through this link -> https://grpc.io/docs/

  • MQTT (Message Queuing Telemetry Transport)

MQTT is a lightweight, publish-subscribe network protocol designed for small sensors and mobile devices. It is commonly used in Internet of Things (IoT) applications for efficient and low-bandwidth communication.

This is an overview introductory on the various communication protocols and a sample of their various use cases.

0
Subscribe to my newsletter

Read articles from Keith Owira directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Keith Owira
Keith Owira