0
0
Microservicessystem_design~12 mins

Circuit breaker pattern in Microservices - Architecture Diagram

Choose your learning style9 modes available
System Overview - Circuit breaker pattern

The circuit breaker pattern helps microservices handle failures gracefully. It prevents a service from repeatedly calling a failing service, avoiding cascading failures and improving system stability.

Key requirements include detecting failures, stopping calls temporarily, and retrying after a cooldown period.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Circuit Breaker
  |
  v
Service B
  |
  v
Database

Cache (optional) connected to Service B
Components
User
client
Initiates requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Entry point for client requests, routes to services
Circuit Breaker
circuit_breaker
Monitors service calls, stops calls to failing services temporarily
Service B
service
Handles business logic and data retrieval
Database
database
Stores persistent data for Service B
Cache
cache
Stores frequently accessed data to reduce database load
Request Flow - 12 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayCircuit Breaker
Circuit BreakerService B
Service BCache
CacheService B
Service BDatabase
DatabaseService B
Service BCircuit Breaker
Circuit BreakerAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Service B
Impact:Circuit breaker detects repeated failures and opens circuit, stopping calls to Service B. Users receive fallback or error responses quickly.
Mitigation:Circuit breaker opens to prevent overload, retries after cooldown. Cache can serve stale data if available. Alerts notify engineers to fix Service B.
Architecture Quiz - 3 Questions
Test your understanding
What component decides to stop calls to a failing service?
AAPI Gateway
BLoad Balancer
CCircuit Breaker
DCache
Design Principle
The circuit breaker pattern protects the system from cascading failures by stopping calls to unhealthy services. It improves resilience by quickly failing fast and allowing fallback strategies like caching or retries after cooldown.