📡Key Takeaways
- 1Synchronous (REST/gRPC): simple, immediate response — but creates temporal coupling
- 2Asynchronous (events/queues): decoupled, resilient — but harder to debug and eventually consistent
- 3API Gateway: single entry point for external clients — handles auth, rate limiting, routing
- 4Backend 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
| Style | Protocol | Latency | Coupling | Best For |
|---|---|---|---|---|
| Sync Request-Response | REST (HTTP/JSON) | Low | High | Simple CRUD, real-time queries |
| Sync RPC | gRPC (HTTP/2 + Protobuf) | Very low | High | Internal services, high-perf |
| Async Messaging | Kafka, SQS, RabbitMQ | Higher | Low | Commands, events, workflows |
| Async Event-Driven | Kafka, SNS/SQS | Higher | Lowest | Notifications, 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
When should you prefer async messaging over sync REST?