Design: Circuit Breaker Pattern Implementation in Microservices
Design the circuit breaker component integrated with microservices communication. Out of scope: detailed microservice business logic, deployment infrastructure.
Functional Requirements
FR1: Prevent cascading failures when a dependent microservice is down or slow
FR2: Detect failures and stop requests to the failing service temporarily
FR3: Automatically retry requests after a cooldown period
FR4: Provide fallback responses when the dependent service is unavailable
FR5: Monitor and log circuit breaker state changes for observability
Non-Functional Requirements
NFR1: Handle up to 10,000 requests per second
NFR2: Fail fast with p99 latency under 100ms for circuit breaker checks
NFR3: Ensure 99.9% availability of the overall system
NFR4: Minimal added latency when circuit breaker is closed (normal operation)