Bird
Raised Fist0
HLDsystem_design~12 mins

Circuit breaker pattern in HLD - Architecture Diagram

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

The Circuit Breaker pattern helps protect a system from repeated failures when calling external services. It detects failures and stops requests temporarily to avoid overloading the failing service, improving system stability and user experience.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Circuit Breaker
  |
  +-------------------+
  |                   |
  v                   v
Service A          Fallback Service
  |
  v
Database
  |
  v
Cache
Components
User
client
Initiates requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly across API Gateway instances
API Gateway
api_gateway
Handles client requests and routes them to services
Circuit Breaker
circuit_breaker
Monitors service health and stops requests to failing services temporarily
Service A
service
Processes business logic and queries database/cache
Fallback Service
service
Provides default or cached responses when Service A is unavailable
Database
database
Stores persistent data for Service A
Cache
cache
Stores frequently accessed data to reduce database load
Request Flow - 13 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayCircuit Breaker
Circuit BreakerService A
Service ACache
CacheService A
Service ADatabase
DatabaseService A
Service ACache
Service ACircuit Breaker
Circuit BreakerAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Service A
Impact:Circuit Breaker detects failures and opens circuit, stopping requests to Service A. Requests are routed to Fallback Service instead. Database and cache remain unaffected but new data cannot be processed.
Mitigation:Circuit Breaker opens to prevent overload. Fallback Service provides default or cached responses. Circuit Breaker periodically tests Service A to close circuit when healthy again.
Architecture Quiz - 3 Questions
Test your understanding
What component decides to stop sending requests to a failing service?
ACircuit Breaker
BLoad Balancer
CAPI Gateway
DCache
Design Principle
The Circuit Breaker pattern protects the system from cascading failures by detecting service health and temporarily stopping requests to failing components. This improves system resilience and user experience by routing requests to fallback services and avoiding overload.