Updated July 2026. Refreshed for current microservices best practices.
Why Resilience Patterns Matter
In microservices, one slow or failing dependency can cascade across the system. The Circuit Breaker pattern stops calling a failing service, giving it time to recover while your API returns fast fallbacks instead of hanging.
Circuit Breaker States
- Closed — normal operation; failures counted.
- Open — calls fail immediately; no load on downstream.
- Half-open — trial requests to test recovery.
Resilience4j with Spring Boot 3
@CircuitBreaker(name = "paymentService", fallbackMethod = "paymentFallback")
@Retry(name = "paymentService")
@Bulkhead(name = "paymentService", type = Bulkhead.Type.THREADPOOL)
public PaymentResult charge(PaymentRequest req) {
return paymentClient.charge(req);
}
public PaymentResult paymentFallback(PaymentRequest req, Exception ex) {
return PaymentResult.pending("Payment temporarily unavailable");
}
Bulkhead Pattern
Isolate thread pools per dependency so one slow service cannot exhaust all threads. Combine with timeouts and rate limiters for defense in depth.
Configuration Tips
- Set failure rate threshold (e.g., 50% over 10 calls → open).
- Wait duration in open state: 30–60 seconds before half-open.
- Expose circuit state via Actuator metrics for alerting.
- Test with chaos engineering (Litmus, Toxiproxy).
Related: Saga Pattern · Microservices Introduction
Want live microservices classes? Join Alkademy for instructor-led microservices architecture courses with hands-on projects.
Go deeper with the book: Practical Microservices Design Using CQRS and Event Sourcing by Kindson Munonye.
Kindson Munonye is a software engineer and technical author specializing in microservices, CQRS, event sourcing, and distributed systems. He publishes free step-by-step tutorials and live classes on Alkademy.