Skip to content
Veltoryx Technologies
ProLesson 11.2Intermediate4 min readUpdated 31 October 2026

Resilience4j Circuit Breaker Deep Dive

Master Resilience4j internal state machines, sliding window metrics, failure rate calculation, and automatic self-healing recovery in Spring Boot 3.

Netflix originally pioneered the Circuit Breaker pattern with Hystrix. However, Hystrix relied heavily on Archaius, rx.Observable, and thread context switching, and was officially put into maintenance mode in 2018.

Resilience4j is the modern, lightweight, functional fault tolerance library designed specifically for Java 17/21 and Spring Boot 3.

01The Circuit Breaker State Machine

A Resilience4j Circuit Breaker operates as a finite state machine with three core states and two special states:

Resilience4j Sliding Window and State Transitions
Fig. 1 · Resilience4j Sliding Window and State Transitions

The 3 Core States:

  1. CLOSED (Healthy):
    • All outgoing requests flow directly to the downstream service.
    • The circuit breaker records the outcome of each call (SUCCESS, FAILURE, or SLOW) into an in-memory Sliding Window.
    • If the failure rate or slow call rate exceeds the configured threshold, the breaker transitions to OPEN.
  2. OPEN (Failing Fast):
    • All calls fail instantly with a CallNotPermittedException.
    • The protected remote service is completely shielded from traffic, allowing it room to recover or reboot.
    • Fallback methods are executed immediately in 0ms.
    • The breaker starts a sleep timer (waitDurationInOpenState, e.g. 10s).
  3. HALF-OPEN (Trial Probing):
    • Once the sleep timer expires, the breaker transitions to HALF-OPEN.
    • It allows a configurable number of trial calls (permittedNumberOfCallsInHalfOpenState, e.g. 5).
    • If the failure rate of these trial calls is below the threshold, the breaker resets to CLOSED.
    • If any trial call fails or is slow, it trips back to OPEN for another sleep duration.

Loading the rest of the lesson…