resilience-patterns

Implement Resilience4j bulkheads, circuit breakers, timeouts, and fallbacks for distributed service stability.

Updated Jun 25, 2026
One-click install
npx skills add https://github.com/oriddd/ai-toolkit --skill resilience-patterns-oriddd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: resilience-patterns
Source: https://github.com/oriddd/ai-toolkit/tree/main/copilot/public/skills/resilience-patterns
Command: npx skills add https://github.com/oriddd/ai-toolkit --skill resilience-patterns-oriddd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Distributed services fail when a single slow or broken dependency cascades through shared thread pools and unbounded retries. This Skill provides concrete patterns to isolate failures, fail fast, and degrade gracefully so one unstable dependency cannot take down the entire service. ## Core Features & Use Cases - Bulkheads & Circuit Breakers: Configure Resilience4j thread-pool/semaphore bulkheads and circuit breakers with sliding windows, half-open probing, and failure-rate thresholds. - Timeouts, Fail-Fast & Fallbacks: Enforce connect/read/request timeouts, reject calls when a circuit is OPEN, and serve cached values, static defaults, or meaningful 503 errors. - Observability & Idempotency: Emit metrics and logs for every resilience event via Resilience4j's EventPublisher, and use X-Idempotency-Key headers to make retries of write operations safe. - Use Case: Your Spring Boot service calls a flaky payment provider. Apply a semaphore bulkhead limiting concurrent calls, a circuit breaker that opens at 50% failure rate, and a cached-value fallback so checkout stays responsive during the outage. ## Quick Start Apply the resilience-patterns skill to add a circuit breaker, bulkhead, and fallback to my external service client.

Frequently Asked Questions about resilience-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure a Resilience4j circuit breaker in Spring Boot?

Define the circuit breaker in YAML under resilience4j.circuitbreaker.instances with slidingWindowSize, failureRateThreshold, waitDurationInOpenState, and permittedNumberOfCallsInHalfOpenState. Calls fail fast with CallNotPermittedException while the circuit is OPEN.

What is the difference between thread pool and semaphore bulkheads?

A thread pool bulkhead isolates dependencies on separate thread pools, while a semaphore bulkhead limits concurrent calls on the calling thread. Both prevent one slow dependency from exhausting your service's resources.

How do I make retries safe for POST and PUT requests?

Use idempotency keys: the client sends an X-Idempotency-Key header, and the server records the first call's result and replays it for repeated keys. This makes retries of write operations safe without duplicate side effects.

When should I use fail-fast instead of retries?

Fail fast when a dependency is known to be down, such as when its circuit breaker is OPEN. This preserves your service's threads and resources instead of blocking on long-running retries during an outage.

How do I monitor circuit breaker state changes in Resilience4j?

Use the circuit breaker's EventPublisher to subscribe to state transitions and emit a metric and log entry for each event. For example, onStateTransition can log a warning whenever the breaker opens or closes.