Why this matters
- When the payment service takes 30 seconds to respond, every checkout thread blocks — thread pools exhaust and the catalog API goes down too, even though catalog itself is healthy.
- Circuit breakers trip after repeated failures, returning a fallback immediately instead of waiting for timeouts on every request.
- Retries with exponential backoff recover from transient blips; rate limiters protect your own services from being overwhelmed by retries from callers.
Circuit breaker
L1 · FresherStop calling a failing payment service after thresholds — fail fast and protect BookStore threads.
Resilience4j
L2 · IntermediateConfigure circuit breaker, retry, rate limiter, and bulkhead via annotations or functional APIs.
Retry with backoff
L3 · AdvancedRetry only idempotent operations with jittered backoff — never retry POST without idempotency keys.
Bulkhead isolation
L4 · ExpertSeparate thread pools for catalog vs checkout so one slow dependency cannot exhaust all workers.
ClosedNormal traffic
OpenFail fast
Half-openProbe request
Resilience4j patterns in Spring Boot
- Circuit Breaker — opens after failure threshold; short-circuits calls while upstream recovers.
- Retry — re-attempts failed calls with configurable backoff and max attempts.
- Rate Limiter — caps requests per time window to protect downstream services.
- Bulkhead — isolates thread pools so one slow dependency cannot starve others.
- Time Limiter — enforces a maximum duration on any call, including async ones.
Dependencies and configuration
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
</dependency>
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 3 sections
- Circuit breaker with fallback
- Declarative resilience with annotations
- Bulkhead isolation
Test yourself
Answer these before moving on — recall is what makes it stick.