Synchronous vs. Asynchronous Communication in Microservices

Arpit Bhayani

Arpit Bhayani

May 04, 2022 • 9 min read

Play

In a monolithic architecture, inter-component communication is simple: one component invokes a function in another component within the same process. It executes on the same thread stack, completes in microseconds, and is guaranteed to run unless the entire process crashes.

In a microservices architecture, boundaries shift across the network. A single user action—such as liking a post on a social network—often requires multiple distinct services (e.g., a Reaction Service and a Notification Service) to coordinate over a network. Networks introduce latency, transient drops, packet routing failures, and network partitions.

Choosing the right communication pattern between microservices is fundamental to building scalable, resilient, and responsive distributed systems. Microservice communication falls into two primary categories: Synchronous and Asynchronous.


1. Synchronous Communication

Synchronous communication is a model where the calling service initiates a request and blocks its execution context, waiting for the target service to process the request and return a response before proceeding.

sequenceDiagram
    autonumber
    actor User
    participant ReactionService as Reaction Service
    participant DB as Database
    participant NotificationService as Notification Service

    User->>ReactionService: POST /reaction (Like)
    activate ReactionService
    ReactionService->>DB: Write Reaction Record
    ReactionService->>NotificationService: POST /notify (Synchronous Call)
    activate NotificationService
    NotificationService-->>ReactionService: 200 OK (Notification Sent)
    deactivate NotificationService
    ReactionService-->>User: 200 OK (Success)
    deactivate ReactionService

Implementation Protocols

Most synchronous communication in modern architectures runs on top of TCP-backed application protocols:

  • REST over HTTP/1.1 or HTTP/2: JSON payloads exchanged over standard HTTP verbs (GET, POST, PUT, DELETE).
  • gRPC over HTTP/2: High-performance RPC framework using Protocol Buffers (Protobuf) for compact binary serialization and multiplexed streams.
  • GraphQL: Query-driven data fetching over HTTP, allowing clients to specify precise data requirements.

Advantages of Synchronous Communication

  1. Intuitive Mental Model and Simplicity: Synchronous request-response flows mimic traditional programming logic (result = callService()). Debugging, local testing, and step-through reasoning are straightforward.
  2. Immediate Feedback and Strong Consistency: The caller receives an immediate, definitive status. If the downstream operation fails, the caller knows immediately and can reject the client’s request or execute an immediate rollback.
  3. Real-Time Data Access: When fresh, non-stale data is strictly required before the user can proceed (such as querying an account balance or validating inventory availability), synchronous calls provide an immediate guarantee.

Disadvantages of Synchronous Communication

  1. Cumulative Blocking Latency: Because the caller waits, the end-to-end latency seen by the user is the sum of every synchronous hop in the call graph: Latencytotal=Latencynetwork+LatencyService A+LatencyService B+\text{Latency}_{\text{total}} = \text{Latency}_{\text{network}} + \text{Latency}_{\text{Service A}} + \text{Latency}_{\text{Service B}} + \dots Any degraded service in the chain inflates the caller’s response time, exhausts thread pools, and risks client-side timeouts.

  2. Proactive Over-Provisioning for Traffic Spikes: In a synchronous chain, if Service A receives an unexpected surge of 10,000 requests per second, Service B must also immediately handle 10,000 requests per second. Every downstream dependency must be scaled and provisioned proactively for peak traffic. If downstream infrastructure cannot scale immediately, requests hit TCP connection backlogs, timeout, or get dropped with HTTP 503 Service Unavailable errors.

  3. Cascading Failures: When downstream services degrade, upstream services stall waiting for responses. Connection pools, memory, and CPU threads become saturated, causing the failure to propagate upstream until the entire platform goes down.

graph LR
    User --> ServiceA[Service A]
    ServiceA --> ServiceB[Service B]
    ServiceB --> ServiceC[Service C]
    ServiceC --> ServiceD[Service D - DOWN]
    
    classDef down fill:#ff4d4d,stroke:#333,stroke-width:2px,color:#fff;
    classDef degraded fill:#ffa500,stroke:#333,stroke-width:2px,color:#fff;
    class ServiceD down;
    class ServiceC,ServiceB,ServiceA degraded;

Mitigation: Preventing cascading failures in synchronous architectures requires resilient patterns like timeouts, retries with exponential backoff and jitter, and circuit breakers (e.g., tripping open when downstream failure rates cross a threshold).

  1. Tight Architectural Coupling: Both services must agree on strict API schemas, endpoint URLs, and serialization protocols. Breaking schema changes require versioning policies (/v1, /v2), and planned maintenance or downtime in a downstream service directly impacts the availability of upstream callers.

2. Asynchronous Communication

In an asynchronous model, services communicate indirectly via messages or events using an intermediary Message Broker. The caller produces a message, publishes it to the broker, receives an immediate acknowledgement that the broker accepted the message, and returns. Downstream consumers read and process messages independently.

sequenceDiagram
    autonumber
    actor User
    participant ReactionService as Reaction Service
    participant DB as Database
    participant Broker as Message Broker (Queue/Topic)
    participant NotificationService as Notification Consumer

    User->>ReactionService: POST /reaction (Like)
    activate ReactionService
    ReactionService->>DB: Write Reaction Record
    ReactionService->>Broker: Publish (User A liked User B's post)
    activate Broker
    Broker-->>ReactionService: ACK (Message Persisted)
    deactivate Broker
    ReactionService-->>User: 200 OK (Success)
    deactivate ReactionService

    Note over Broker,NotificationService: Decoupled / Independent Execution
    Broker->>NotificationService: Consume Message
    activate NotificationService
    NotificationService->>NotificationService: Deliver Push Notification
    NotificationService-->>Broker: ACK (Processed)
    deactivate NotificationService

Implementation Technologies

  • Distributed Commit Logs: Apache Kafka, AWS Kinesis (high-throughput, partitioned event streaming with replay capability).
  • Traditional Message Queues: RabbitMQ, ActiveMQ (advanced routing via exchanges, AMQP support).
  • Cloud-Managed Pub/Sub Services: AWS SQS/SNS, Google Cloud Pub/Sub, Azure Service Bus.

Advantages of Asynchronous Communication

  1. Decoupled User-Facing Latency: The client-facing service performs only the minimal critical path operations (e.g., updating its local database and appending a message to a queue) before returning success. Heavy downstream tasks (e.g., sending emails, updating search indexes, pushing alerts) are offloaded to background workers.

  2. Load Leveling (Buffering Surges): The message broker acts as an elastic shock absorber. During high-traffic events, incoming requests simply accumulate as messages in the broker. Downstream consumers continue processing at their maximum sustainable capacity without being overwhelmed, eliminating dropped connections and system crashes.

  3. Elimination of Cascading Failures: If the downstream consumer crashes or becomes unreachable, the producer continues to function normally. Messages remain safely buffered on the broker until the consumer recovers.

  4. Infrastructure Simplification: Direct service-to-service synchronous calls often require internal application load balancers (ALBs) or service meshes for traffic routing, adding 3–5 ms of latency per network hop. In asynchronous messaging, consumers pull directly from the broker or receive pushed messages via persistent long-lived TCP connections, removing intermediate internal load balancers.

  5. Granular, Isolated Failure Handling & Retries: If an external notification provider (such as an SMS gateway or email service) experiences downtime, downstream consumers can retry processing using exponential backoff or route unprocessable messages to a Dead Letter Queue (DLQ) for manual inspection, all without failing the original user request.

  6. One-to-Many Event Fan-Out: Using a publish-subscribe model, a single produced event can be consumed by multiple independent subsystems simultaneously without changing the producer’s code:

graph LR
    BlogService[Blog Publishing Service] -->|Publish 'ArticlePublished'| Broker[(Message Broker)]
    Broker --> SearchConsumer[Search Indexing Service]
    Broker --> NotificationConsumer[Follower Alert Service]
    Broker --> AnalyticsConsumer[User Analytics Service]
    Broker --> FeedConsumer[Activity Feed Service]

Disadvantages of Asynchronous Communication

  1. Eventual Consistency: Because processing is deferred, the system state is not immediately unified across all services. There is a window of time where an action is confirmed to the user, but downstream services have not reflected the update. Architects must design client experiences to accommodate eventual consistency.

  2. Broker as a Single Point of Failure (SPOF): The message broker becomes the central nervous system of the architecture. If the broker cluster fails, inter-service communication stops. Brokers must be designed with clustering, multi-AZ replication, leader election, and high durability guarantees.

  3. Distributed Observability and Tracing Complexity: Tracking an asynchronous workflow across multiple decoupled queues and consumers is difficult. If a message fails, identifying where it stalled requires standardized distributed tracing infrastructure (e.g., passing correlation IDs via message metadata headers, OpenTelemetry, Jaeger).


3. Comparative Summary

Architectural AttributeSynchronous CommunicationAsynchronous Communication
Call SemanticsBlocking (Caller waits for result)Non-blocking (Fire-and-forget / Deferred execution)
Direct ProtocolsHTTP/REST, gRPC, GraphQLMessage Queues / Log Streams (Kafka, SQS, RabbitMQ)
Consistency ModelImmediate / Strong consistencyEventual consistency
Latency ImpactCumulative across downstream hopsConstant / Low (bounded by queue publish latency)
Failure PropagationHigh risk of cascading failure (needs circuit breakers)Isolated; broker acts as a buffer
Traffic Spike BehaviorTarget services must proactively over-provisionNaturally buffered; consumers process at sustained rates
Debugging & TracingStraightforward stack/call-tree tracingRequires distributed trace context / correlation IDs
CouplingTight contract and availability couplingLoose temporal and schema coupling

4. Decision Framework: When to Use Which Pattern

graph TD
    Start{Evaluate Service Interaction} --> Q1{Does caller require immediate<br/>data to continue execution?}
    Q1 -- Yes --> Sync[Use Synchronous<br/>gRPC / REST]
    Q1 -- No --> Q2{Is the operation<br/>long-running or compute-heavy?}
    Q2 -- Yes --> Async[Use Asynchronous<br/>Message Broker]
    Q2 -- No --> Q3{Do multiple services<br/>need to react to this event?}
    Q3 -- Yes --> Async
    Q3 -- No --> Q4{Is processing delay<br/>tolerable to the user?}
    Q4 -- Yes --> Async
    Q4 -- No --> Sync

When to Use Synchronous Communication

  1. Sequential Dependencies: When the calling service cannot execute the next line of code without the result of the call (e.g., executing a database query, validating credentials against an Auth service).
  2. Real-Time Interactive Feedback: Operations where users expect immediate, deterministic confirmation:
    • Financial Checkouts: Authorizing a payment transaction against a payment gateway.
    • Live Messaging: Immediate delivery confirmation in active chat sessions.
    • Time-Critical Verification: Validating and consuming a One-Time Password (OTP) during an authentication challenge.
  3. Low-Compute, Low-Latency Endpoints: Operations that execute in single-digit milliseconds and return immediately without heavy background computation.

When to Use Asynchronous Communication

  1. Tolerable Delay: Operations where sub-second delivery is not strictly required. A user expects a social media notification or transactional receipt within a few seconds, but will not notice a 3-second delay.
  2. Long-Running or Resource-Intensive Jobs: Tasks taking seconds, minutes, or hours must never hold open a synchronous HTTP connection:
    • Cloud infrastructure provisioning (e.g., provisioning a VM instance).
    • Database backup routines and data migrations.
    • Video transcoding, media compression, and batch PDF generation.
  3. Fan-Out Architectures: When a single state change triggers actions across multiple domain boundaries (e.g., an order placement triggering inventory reservation, shipment creation, notification dispatch, and fraud scoring).
  4. Workflows Requiring Resilient Retries: External integrations (third-party delivery services, vendor webhooks, SMS providers) that may fluctuate in availability and require non-blocking, automated retry policies with Dead Letter Queues.

5. Architectural Takeaway

Real-world systems rarely use only one pattern. Production microservice ecosystems combine both:

  • Synchronous edge interfaces handle incoming user requests, validate inputs, enforce business invariants, and commit transactions to storage.
  • Asynchronous internal backbones handle downstream side effects, analytics, third-party integrations, and notifications via durable event streams.

Understanding these trade-offs ensures you optimize for user experience and low latency at the edge while retaining resilience, scalability, and loose coupling in the core.

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses