Summary

Rajesh Bhojwani’s reference guide to common microservices design patterns, organized by category: decomposition (by business capability, subdomain/DDD, strangler pattern), integration (API gateway, aggregator, client-side composition), and reliability (circuit breaker, saga, event sourcing).

Rajesh Bhojwani 關於常見微服務設計模式的參考指南,按類別組織:分解(按業務能力、子域/DDD、絞殺者模式)、集成(API 網關、聚合器、客戶端組合)和可靠性(斷路器、Saga、事件溯源)。

Key Points

  • Decompose by business capability: split services around what the business does (sales, underwriting, claims) not technical layers
  • Decompose by subdomain (DDD): use bounded contexts to handle “God Classes” (like Order) that span multiple services; each service owns its bounded context
  • Strangler pattern: for brownfield monoliths — intercept calls to old system and gradually route to new microservices; don’t big-bang rewrite
  • API gateway: single entry point for all clients; handles routing, auth, rate limiting, response aggregation; prevents N×M client-service coupling
  • Circuit breaker: stop cascading failures; after N failures, open circuit and fail-fast with fallback instead of blocking threads on timeouts
  • Saga pattern: manage distributed transactions across services; choreography (event-driven) vs. orchestration (central coordinator) variants
  • Event sourcing: store state as sequence of events rather than current state; enables replay, audit, temporal queries

Insights

These patterns are the vocabulary for microservices architecture discussions. The strangler pattern is the most practically important for most teams since >80% of microservices work involves extracting from monoliths, not greenfield. The circuit breaker pattern addresses the most dangerous failure mode in distributed systems — cascading failures — by treating upstream timeouts as a signal to back off. The DDD/bounded context decomposition principle is theoretically correct but hard to apply in practice: domain boundaries require deep business understanding and organizational alignment, not just technical analysis.

Connections

Raw Excerpt

The Strangler pattern solves the challenge of migrating legacy monolithic applications to microservices by gradually routing requests to new services while keeping the existing system running, avoiding a risky big-bang rewrite.