Intermediate → Advanced20 min read· Topic 8.3

Inter-service communication

Sync vs async communication, service mesh, API gateway, Backend for Frontend

📡Key Takeaways

  • 1
    Synchronous (REST/gRPC): simple, immediate response — but creates temporal coupling
  • 2
    Asynchronous (events/queues): decoupled, resilient — but harder to debug and eventually consistent
  • 3
    API Gateway: single entry point for external clients — handles auth, rate limiting, routing
  • 4
    Backend for Frontend (BFF): separate API layer per client type (mobile, web, internal)

How Services Talk to Each Other

In microservices, services must communicate frequently. The communication style you choose affects reliability, latency, coupling, and complexity. Most systems use a mix: synchronous for queries that need immediate responses, asynchronous for commands and events.

Communication Styles

StyleProtocolLatencyCouplingBest For
Sync Request-ResponseREST (HTTP/JSON)LowHighSimple CRUD, real-time queries
Sync RPCgRPC (HTTP/2 + Protobuf)Very lowHighInternal services, high-perf
Async MessagingKafka, SQS, RabbitMQHigherLowCommands, events, workflows
Async Event-DrivenKafka, SNS/SQSHigherLowestNotifications, analytics, fan-out

Gateway Patterns

Single entry point for all external API calls. Handles cross-cutting concerns: authentication, rate limiting, SSL termination, request routing, response caching.

Implementations: Kong, AWS API Gateway, Envoy, Nginx.

Risk: can become a bottleneck and single point of failure. Keep gateway logic thin — routing and auth only, no business logic.

Advantages

  • Sync is simple and familiar
  • Async provides loose coupling and resilience
  • API Gateway centralizes cross-cutting concerns

Disadvantages

  • Too many sync calls create fragile call chains
  • Async debugging is significantly harder
  • API Gateway can become a bottleneck

🧪 Test Your Understanding

Knowledge Check1/1

When should you prefer async messaging over sync REST?