When Online Adaptation of Resilience Policies Hurts: Safe Exploration and Measurement Pitfalls in Resilience4j

Rajat M. Barot, Arjun S. BorkhatariyaarXiv 2026

TL;DR

Letting an online learning algorithm automatically tune microservice fault-tolerance settings sounds like a great idea—until its "exploration" phase accidentally rejects almost all your live user traffic. This paper shows how simple guardrails turn a disastrously naive learner into one that reliably beats static configurations, while sharing a cautionary tale of how a subtle measurement bug hid a 97% user failure rate behind "excellent" system metrics.

What Problem Does This Paper Address?

Modern backend systems rely on fault-tolerance libraries like Resilience4j to survive shaky dependencies. Developers configure three main patterns: Retries (try failed calls again), Circuit Breakers (stop calling a failing service altogether so it can recover), and Bulkheads (cap concurrent requests so one slow service doesn't exhaust all threads).

Because these knobs interact—retries can overwhelm a struggling service, while hair-trigger circuit breakers turn minor hiccups into full outages—getting them right is tricky. Usually, engineers pick static numbers in a YAML file and hope for the best, even though the ideal configuration depends on whether a downstream service is currently healthy, sluggish, or throwing errors. While prior work has tuned individual knobs or external service meshes, this paper asks: can an online learning algorithm safely swap entire Resilience4j configurations inside a live Java application at runtime?

Methods

The authors built AdaptR4j, a system that dynamically updates Resilience4j policies in Spring Boot 3. Because Spring Boot cannot natively hot-swap these registry instances at runtime, AdaptR4j wraps the active (CircuitBreaker, Retry, Bulkhead) triple behind an atomic reference—allowing instantaneous, thread-safe swaps while in-flight requests finish on old instances.

Every 60 seconds, a controller scrapes six telemetry signals from Prometheus (such as edge p99 latency, error rate, and retry amplification). It feeds these into LinUCB, a standard contextual bandit algorithm that balances exploring untested policies with exploiting high-scoring ones. The reward function incentives keeping p99 latency under a 500 ms Service Level Objective (SLO) and errors under 5%.

Crucially, after an unconstrained "naive" version failed, the authors introduced key safeguards:

  • Safe Policy Menu: Filtering out overly aggressive policies before deployment (keeping only circuit breakers with failure thresholds $\ge 45\%$ and slow-call limits $> 500\text{ ms}$, trimming 30 candidate policies down to 14).
  • Safe Exploration & Bounded Reward: Placing poorly performing policies on a 30-minute "rest" cooldown before re-testing, and capping the minimum reward at $-2$ so a single terrible minute doesn't permanently skew averages.

Datasets

Not discussed in the paper. Instead of static datasets, the authors evaluate their system on a live microservice testbed driven by Locust synthetic user traffic (50 concurrent users) across five injected fault scenarios: S1 moderate faults (50 ms latency, 4% errors), S2 severe faults (200 ms, 10%), S3 pure unwinnable latency (500 ms, 0%), S4 error storm (0 ms, 30%), and S5 alternating latency spikes ($0 \leftrightarrow 500\text{ ms}$ every 5 minutes).

Key Insights and Ideas

  • Unconstrained exploration hurts more than doing nothing: In live systems, exploring bad configurations carries a real cost. On a 30-item menu, 16 policies had strict circuit breakers that choked traffic—causing the naive bandit to lose to the static default policy in three of four winnable scenarios.
  • The guardrails matter more than the AI: When the authors swapped their context-aware LinUCB learner for a much simpler, context-free UCB1 bandit on the same safe menu, performance was statistically indistinguishable. Pre-filtering dangerous configurations does the heavy lifting, not clever contextual math.
  • Metrics can lie spectacularly: In an early version of their test harness, a unit mismatch (passing 0.50 instead of 50 for percentages) made circuit breakers 100$\times$ too strict, tripping on the first error. Worse, metrics were recorded inside the resilience chain—meaning rejected calls never registered as errors and logged near-zero latency. The controller celebrated 106 ms latency and 0.06% errors while 97.4% of actual users got HTTP 500s.
Controller view vs. actual user failures before and after fixing measurement bugs.

Key Results

Evaluated across 80-minute runs on the corrected harness, the safeguarded AdaptR4j design delivers strong, reproducible results (standard deviation $\le 0.026$ across runs):

  • Beats the default everywhere possible: AdaptR4j significantly outperforms the balanced static default (p01) in all four winnable scenarios ($p < 0.001$). For example, in error storms (S4), p01 scores $-2.000$ with 32.5% user failures, whereas AdaptR4j reaches $-0.315$ overall ($-0.035$ in the second half) with 9.4% user failures.
  • Outperforms static oracles during changing faults: When latency spikes alternate every five minutes (S5), no single static policy fits both phases. AdaptR4j adapts on the fly, scoring $-0.451$ and beating the best hindsight fixed policy ($-0.763$, $p = 0.011$).
  • Cuts user-visible failures: Compared to the naive bandit design, safeguards slash user-facing failures by up to $3.7\times$ (dropping from 31.4% to 9.4% in S4, and from 8.5% to 2.3% in S5).

Limitations and Future Work

  • Post-hoc menu rules: The 45% / 500 ms safe-menu rule was derived from observing the same sweeps used for evaluation; it needs validation on entirely new services and fault types.
  • Cold-start exploration tax: Trying every safe policy once still costs 15–20 minutes of suboptimal performance at startup. Seeding the learner with offline sweeps or default policy baselines is an obvious next step.
  • Reward trade-offs: In S2 and S5, the static default actually served more requests successfully—just very slowly—whereas AdaptR4j's reward formula preferred fast partial failures over breaching latency SLOs.
  • Testbed scale: All experiments ran on a single laptop with synthetic workloads, and baselines were only run once per scenario.

Summary updated

BibTeX
@misc{barot2026when,
  author = {Rajat M. Barot and Arjun S. Borkhatariya},
  title = {{When Online Adaptation of Resilience Policies Hurts: Safe Exploration and Measurement Pitfalls in Resilience4j}},
  year = {2026},
  eprint = {2611.32015},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.32015},
}
Figure