Resilience4j
Lightweight fault tolerance library for Java 8+ and Kotlin — the modern replacement for Netflix Hystrix (deprecated). Resilience4j provides composable resilience decorators: CircuitBreaker (auto-open on failure threshold), RateLimiter (token bucket or fixed window), Retry (exponential backoff, configurable predicates), Bulkhead (concurrent call limiting), TimeLimiter (timeout), and Cache (memoization). Designed for functional composition — decorators wrap functions (Supplier, Callable, Function). Integrates with Spring Boot (spring-cloud-starter-circuitbreaker-resilience4j), Micrometer metrics, and RxJava.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
No network exposure. Resilience patterns prevent cascade failures that could be exploited. Circuit breaker prevents resource exhaustion from malicious slow endpoints. No credentials needed.
⚡ Reliability
Best When
You're building Java/Kotlin services that call external APIs or databases and need circuit breaker, retry, rate limiting, and bulkhead patterns — especially in Spring Boot where auto-configuration simplifies setup.
Avoid When
Your resilience needs are met by Spring Retry, you need distributed (cross-pod) rate limiting, or you're not in a JVM environment.
Use Cases
- • Protect agent external API calls with circuit breakers — CircuitBreaker.decorateSupplier() wraps LLM API calls; auto-opens after N failures; fallback to cached responses during open state
- • Implement exponential backoff retry for flaky agent dependencies — Retry.of(config).executeSupplier(() -> apiCall()) with IntervalFunction.ofExponentialBackoff()
- • Rate-limit outbound agent API calls to respect third-party API quotas — RateLimiter.decorateSupplier limits calls per second to OpenAI, Anthropic, or external data APIs
- • Limit concurrent agent requests to expensive operations using Bulkhead — SemaphoreBulkhead limits concurrent agent inference calls to prevent GPU/CPU saturation
- • Add timeout protection to agent long-running operations — TimeLimiter wraps CompletableFuture with configurable timeout; prevents agent hung operations from blocking thread pools
Not For
- • Non-JVM stacks — use Polly (.NET), tenacity (Python), or Tokio retry (Rust) for resilience patterns in other languages
- • Distributed rate limiting — Resilience4j's RateLimiter is JVM-local; for distributed rate limiting across pods, use Redis + bucket4j or API gateway rate limiting
- • Teams on Spring Boot already using Spring Retry — Spring Retry covers basic retry cases; Resilience4j adds circuit breaker and bulkhead; evaluate if Spring Retry is sufficient before adding Resilience4j
Interface
Authentication
Resilience library — no auth concepts. Decorates existing service calls; auth is the underlying service's responsibility.
Pricing
Resilience4j is Apache 2.0 licensed. Free for all use.
Agent Metadata
Known Gotchas
- ⚠ CircuitBreaker state is JVM-local — in multi-instance deployments (Kubernetes), each pod has independent circuit state; one pod may open circuit while others are still closed; use Redis-backed Resilience4j or API gateway for cluster-wide circuit breaking
- ⚠ Retry with exponential backoff and jitter — configure IntervalFunction.ofExponentialRandomBackoff() not ofExponentialBackoff(); without jitter, all retrying agents synchronize retry storms to the same moment (thundering herd)
- ⚠ RateLimiter period vs timeout — periodInNanos is the window size; timeoutDuration is how long to wait for a permit; setting timeoutDuration=0 returns RequestNotPermitted immediately when limit exceeded; positive timeout allows waiting for next window
- ⚠ Bulkhead type matters: Semaphore vs ThreadPool — SemaphoreBulkhead limits concurrent calls in calling thread; ThreadPoolBulkhead uses separate thread pool; mixing sync and async code requires matching bulkhead type to execution model
- ⚠ Spring Boot auto-configuration requires annotations — @CircuitBreaker, @Retry annotations need spring-cloud-starter-circuitbreaker-resilience4j; manual Resilience4j without Spring uses CircuitBreaker.of() directly; both approaches configure differently
- ⚠ Fallback method signature must match decorated method — @Fallback method must have same parameters plus a Throwable as last param; signature mismatch causes runtime BeanCreationException not compile error
Alternatives
Full Evaluation Report
Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for Resilience4j.
AI-powered analysis · PDF + markdown · Delivered within 30 minutes
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-07.