Spring Boot & Microservices (50 Qs)•Part 3: Microservices, Distributed Systems & Observability (25 - 35)
Resilience4j: Circuit Breakers and Bulkheads in Spring Boot.
senior LevelSystem DesignMicroservices
In Simple Words: Resilience4j protects services from cascading downstream failures:
- Circuit Breaker (
@CircuitBreaker(name = "payment", fallbackMethod = "fallback")): If error rate exceeds 50%, the circuit transitions to OPEN, failing fast without making network calls to allow the downstream system to recover. - Bulkhead: Limits concurrent calls to a downstream service (e.g. max 20 threads) to prevent one slow dependency from exhausting all server resources.