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    Svc

How It Works

  1. Client sends all requests to a single endpoint (gateway)
  2. Gateway authenticates the request (JWT validation, API key check)
  3. Gateway routes to the correct backend service based on URL path
  4. Handles cross-cutting: rate limiting, logging, request transformation
  5. 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.'"