Microservices Guide
Communication patterns, resilience strategies, and operational patterns for microservices architecture.
When to Use What
External APIs→ API Gateway + REST
Svc-to-Svc sync→ gRPC + Circuit Breaker
Svc-to-Svc async→ Kafka/RabbitMQ + Events
Multi-svc txn→ Saga Pattern
50+ services→ Service Mesh (Istio)
Debug latency→ Distributed Tracing
Client
│
▼
┌────────────────────┐
│ API Gateway │ Auth, Rate Limit, SSL
│ (Kong / Envoy) │ Routing, Logging
└──┬─────┬─────┬─────┘
│ │ │
▼ ▼ ▼
Users Orders Payments
Svc Svc SvcHow It Works
- Client sends all requests to a single endpoint (gateway)
- Gateway authenticates the request (JWT validation, API key check)
- Gateway routes to the correct backend service based on URL path
- Handles cross-cutting: rate limiting, logging, request transformation
- Can aggregate responses from multiple services (BFF pattern)
Pros
- + Single entry point simplifies client code
- + Centralizes auth, logging, and rate limiting
- + Can transform/aggregate responses
- + Hides internal service topology from clients
Cons
- - Single point of failure (need redundancy)
- - Can become a bottleneck if not scaled
- - Added latency for every request (1-5ms)
- - Complex routing rules can be hard to maintain
Say This in Interview
"Always include an API Gateway in your design. Say: 'The API Gateway handles authentication, rate limiting, and routes to internal services. We'll use Kong or AWS API Gateway with auto-scaling.'"