Metadata Card
- Prerequisites: Chapter 2 (RPC), Vol 6 Software Engineering (CI/CD, Testing)
- Estimated Time: 45 minutes
- Core Difficulty: Intermediate
- Reading Mode: High focus
- Completion Milestone: Design a microservice architecture with service discovery, config center, API Gateway, circuit breaker, and Saga; understand what each component solves
Your Progress
You've built a distributed computing system handling 3PB of logs, but your deployment structure is still "all-in-one big package." User service, intelligence analysis, map rendering, report generation — all in the same process.
General Lin looks at your architecture diagram: "If intelligence analysis crashes, the whole system goes down? One module's bug takes everything offline?"
You nodded.
He continued: "Split. Each fortress handles one thing, they fight independently, coordinate together. This is formation."
This is microservices. Your Task
Understand core microservice patterns and components. Service discovery, config management, API Gateway, circuit breaker, Saga.
Service Discovery: Service instances register on startup, deregister on shutdown. Other services query for available instances.
Client-side discovery: Client queries registry → picks instance → calls. Server-side discovery: Client calls load balancer → forwards to instance (K8s model).
Config Center: Services pull config on startup. Config changes push notifications for hot reload. Config cached locally for resilience.
API Gateway: Single entry point → routes to backend services. Also handles auth, rate limiting, request aggregation, protocol translation.
Circuit Breaker: Monitor remote call failure rate. Three states: CLOSED (normal) → OPEN (failures exceed threshold) → HALF_OPEN (probe). Degradation: serve cached/stale data instead of error.
Saga: Global transaction split into local transactions with compensating actions on failure. Choreography (event-driven, no coordinator) or Orchestration (central coordinator).
Common Pitfalls: Over-splitting (micro, not "service"). No monitoring before splitting. Sharing databases across services. Believing microservices improve development speed (they improve deployment independence and scalability, not speed).
Traveler's Notes
Microservices trade operational complexity for independent deployment, independent scaling, and independent failure boundaries. Service discovery, config center, API Gateway, circuit breakers, Saga — these aren't "Spring Cloud things," they're questions every microservice architecture must answer.
Next: Containerization & Orchestration (Chapter 7).