Day 1: Microservices Communication Types and Styles

logo

Virtual Assistant, Web Design and bookkeeping services

Microservices architecture relies on two fundamental communication types: synchronous and asynchronous.

Synchronous Communication: In synchronous communication, reminiscent of traditional monolithic applications, the client initiates a request and awaits a response from the server. Typically, this involves the client communicating with the API gateway using HTTP/HTTPS protocols, adhering to a request/response pattern. Even within the microservices ecosystem, synchronous communication can persist, with the client sending a request to the API gateway, which further routes it to the intended service. This mode can extend to inter-service communication, where one service directly communicates with another, akin to placing a request and awaiting a response or queuing the request for later processing.

Synchronous communication

Asynchronous Communication: Contrary to synchronous communication, asynchronous communication allows the client to continue with other tasks after initiating a request, without waiting for an immediate response. This method often employs event-driven or message queue systems like Kafka or RabbitMQ, using protocols such as AMQP. In this scenario, the client dispatches a request to relevant services or queues, and the response, if necessary, is handled separately or at a later time. Asynchronous communication can be one-to-one or one-to-many, facilitating efficient distribution of messages across multiple recipients.

Asynchronous communication

Communication Styles:

  1. Request/Response Synchronous Communication for Live Queries and Updates: In this style, clients issue HTTP/HTTPS requests to the API gateway and await immediate responses. It is suitable for scenarios where real-time data retrieval or updates are necessary, maintaining a synchronous exchange between clients and services.
    • Request/Response Communication
  2. Push and Real-time Communication Based on HTTP: Push-based communication involves the backend actively sending messages to multiple consumers. For instance, push notifications delivered to users subscribed to specific events exemplify this style. This approach supports one-to-many communication, utilising HTTP or web sockets, enabling real-time updates and notifications.
    • Push and real-time communication
  3. Asynchronous Event-Driven Communication: Primarily geared towards inter-service communication, this style leverages events as triggers for communication. When a microservice publishes an event via the event bus, other microservices listening for that event receive the data asynchronously. This decoupled architecture fosters scalability and resilience, enabling efficient communication without direct dependencies between services.
    • Asynchronous event driven communication

By understanding and effectively leveraging these communication types and styles, microservices architectures can achieve robustness, scalability, and agility in distributed systems.

You May Also Like…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *