← Back to list

Understanding Asynchronous Communication: The Backbone of Distributed Systems

Most beginners start backend development with synchronous APIs where one service calls another and waits for a response. It feels simple…

Rounakk Raaj Sabat · 2025-10-31 18:15 · 0 claps · 3.3 min read
#asynchronouscommunication #synchronous-communication #pub-sub #distributed-systems
Open on Medium ↗
Wiki topics: 🌐 · Web Development

Understanding Asynchronous Communication: The Backbone of Distributed Systems

Most beginners start backend development with synchronous APIs where one service calls another and waits for a response. It feels simple and direct.

But as your system grows say you have 10+ microservices, this “wait-and-see” approach becomes a bottleneck. One slow service can bring everything to a halt.

This is where asynchronous communication comes in. It’s the secret ingredient behind scalable, fault-tolerant, and real-time systems from Netflix to Uber to Amazon.

In this post, we’ll go deep into:

  • Synchronous vs Asynchronous communication
  • Why Async is crucial in distributed systems
  • What are Message Brokers (RabbitMQ, Kafka, Redis Streams)
  • Pub/Sub model explained simply
  • Event-Driven Architecture (EDA)
  • Practical snippets with Express + RabbitMQ

1. Synchronous Communication

Definition: In synchronous systems, one service directly calls another and waits for a response. It’s like calling someone and not hanging up until they answer.

// Service A calls Service B
const response = await axios.get("http://service-b/api/data");
console.log(response.data);

This is the traditional Request → Response pattern used by REST APIs and HTTP-based services.

Problem?

  • If Service B is slow, Service A is blocked.
  • If Service B crashes, Service A fails.
  • This creates tight coupling between services.

Good for: Small apps, simple synchronous flows (like authentication, CRUD APIs). Bad for: High-scale, interdependent systems.

2. Asynchronous Communication

Definition: Services communicate without waiting for an immediate response. It’s like sending a message on WhatsApp — you continue your work; the other person replies when they can.

Instead of direct calls, services emit messages or events into a Message Broker, which handles delivery and storage.

Example Flow:

  • Service A publishes an event → “UserCreated”
  • Service B (email service) subscribes and reacts → sends welcome email
  • Service C (analytics) subscribes and logs activity

All this happens independently, no waiting involved.

3. Message Brokers — The Heart of Async Systems

Message Brokers are middleware systems that help services talk asynchronously. They receive, queue, store, and distribute messages across multiple consumers.

Popular message brokers:

  • RabbitMQ — reliable queuing and routing
  • Kafka — high throughput, stream-based, used for massive data pipelines
  • Redis Streams — lightweight, great for smaller real-time setups

Example Workflow (RabbitMQ)

  1. Producer sends a message → “Order Created”
  2. Broker stores it in a queue
  3. Consumer reads it and processes the order

Example Code: Async Communication using RabbitMQ (Express + Node.js)

Publisher (Service A)

import amqp from "amqplib";

const publishOrder = async (orderData) => {
  const connection = await amqp.connect("amqp://localhost");
  const channel = await connection.createChannel();
  const queue = "orderQueue";

  await channel.assertQueue(queue, { durable: true });
  channel.sendToQueue(queue, Buffer.from(JSON.stringify(orderData)));

  console.log("Order sent:", orderData);
  await channel.close();
  await connection.close();
};

publishOrder({ orderId: 101, item: "Laptop", price: 899 });

Consumer (Service B)

import amqp from "amqplib";

const consumeOrders = async () => {
  const connection = await amqp.connect("amqp://localhost");
  const channel = await connection.createChannel();
  const queue = "orderQueue";

  await channel.assertQueue(queue, { durable: true });
  console.log("📩Waiting for orders...");

  channel.consume(queue, (msg) => {
    if (msg) {
      const order = JSON.parse(msg.content.toString());
      console.log("Received Order:", order);
      channel.ack(msg);
    }
  });
};

consumeOrders();

Note: Service A doesn’t wait for Service B. It just publishes the message and moves on. That’s asynchronous magic.

4. Pub/Sub Model — Decoupling at Its Best

Pub/Sub (Publish–Subscribe) is a pattern where:

  • Publishers emit events (like “UserRegistered”)
  • Subscribers listen to the events they care about

They never talk to each other directly. This creates loose coupling and massive scalability.

Example:

  • Auth service publishes “UserRegistered”
  • Email service subscribes → sends welcome email
  • Analytics service subscribes → logs signup metrics

Each service does its own work independently.

5. Event-Driven Architecture (EDA)

EDA is where your entire system revolves around events “something happened.”

Instead of chaining API calls, services react to events.

Example (E-commerce)

  • OrderPlaced → triggers → ( Payment Service, Inventory Service, Notification Service )

Each service consumes the event and performs its job asynchronously.

Benefits:

  • High scalability
  • Resilience (if one service fails, others continue)
  • Easy feature extension (just subscribe to an event)

Why Asynchronous Communication Wins?

When to Use Async?

Use Asynchronous Communication when:

  • You have microservices that shouldn’t depend on each other.
  • You’re handling high traffic or batch events.
  • You want resilient systems (no single point of failure).
  • You’re building stream processing, notifications, or real-time analytics.

Summary

  • Synchronous = Wait for a response
  • Asynchronous = Fire and continue
  • Message Brokers decouple communication
  • Pub/Sub enables flexibility
  • Event-Driven Architecture makes systems reactive, scalable, and resilient

This mindset shift from “call-and-wait” to “emit-and-react” is what separates small systems from large-scale distributed architectures.

Further Reading: Distributed Systems

  1. **Breaking the Monolith: A simple guide to Microservices**
  2. **RPCs, gRPC, and tRPC: The Backbone of Modern Distributed Systems**
  3. **Understanding GraphQL: From Basics to Advanced**

메타데이터
post_id
89c6faeb89c4
slug
understanding-asynchronous-communication-the-backbone-of-distributed-systems-89c6faeb89c4
url
https://medium.com/@rounakkraajsabat/understanding-asynchronous-communication-the-backbone-of-distributed-systems-89c6faeb89c4
canonical_url
https://medium.com/@rounakkraajsabat/understanding-asynchronous-communication-the-backbone-of-distributed-systems-89c6faeb89c4
author_url
https://medium.com/@rounakkraajsabat
status
ok
fetched_at
2026-07-20 16:49:03