Skip to content

Smart retry/prototype - #12

Open
louiscrc wants to merge 157 commits into
mainfrom
smart-retry/prototype
Open

Smart retry/prototype#12
louiscrc wants to merge 157 commits into
mainfrom
smart-retry/prototype

Conversation

@louiscrc

Copy link
Copy Markdown
Collaborator

RL retry budget: prototype adaptation to fit the in-cluster RL controller & new sustained-recovery metric to evaluate it

Summary

Adds an RL-driven retry-budget policy (rb-rl) to the Online Boutique Kubernetes/Istio prototype, alongside the harness needed to train, deploy, benchmark, and analyze it against some of the existing baselines (no-control, envoy-retry-budget, arolla).

The controller observes per-service retry pressure from Envoy sidecar stats, maps it onto an observation space aligned with the discrete-event simulator, and self-tunes the Istio retryBudget at runtime. A new sustained-recovery metric replaces the old first-crossing.

All RL implementation lives under prototype/experiments/rl/. The pre-existing sweep/fairness tooling on main is retained unchanged so existing paper figures and sweeps still run.

What's new

RL controller (prototype/experiments/rl/)

  • rl_controller.py — agent that tunes the policy; runs as an in-cluster Kubernetes Job.
  • rl_obs_envoy.py / rl_obs_schema.py — Envoy /stats scraper and the
    observation schema shared with the loader's /buckets endpoint.
  • rl_configs/v1v5 — versioned training configs and trained models.
  • rl_controller_image/ — Dockerfile + build/distribute scripts for the
    in-cluster image.
  • ensure_rl_configmaps.sh — idempotent ConfigMap setup.

Sustained-recovery metric

  • sustained_recovery.py — recovery counted only when goodput and success
    rate hold above their thresholds continuously for a window (default 30 s).
  • Wired into analyze.py and classify_runs.py (Recovered / Metastable /
    Ambiguous labelling).
  • Unit tests: tests/test_sustained_recovery.py, tests/test_classify_decision.py.

30-scenario sweep

  • run_full_sweep.sh — drives all 30 scenarios in scenarios/sweep_scenarios.csv across
    all four policies, with per-row RL callee/caller-label retargeting.
  • run_rl.sh — single-scenario dev/debug runner + comparison plots.
  • plot_rl_comparison.py — multi-policy RL comparison figures (adapted for run_full_sweep.sh output).

Overhead analysis

  • measure_overhead.sh + resource_sampler.py — CPU/memory overhead of the
    controller via kubectl top sampling.
  • bench_decision_diff.py / bench_summarize.py — comparises differences of RL
    decision traces across runs.

Manifests

  • manifests/online-boutique/rl-controller/{job,rbac}.yaml — in-cluster
    controller Job + RBAC.
  • manifests/istio/telemetry-rl-profile.yaml — promotes the loader's
    x-rl-profile header to an Envoy rl_profile metric dimension.

yazhuo and others added 30 commits February 25, 2026 22:16
…ion control

Level 1: GoodputCoupledRetryBudget gates retries at alpha * goodput using
asymmetric EWMA (fast decay, slow growth) with per-tenant isolation.
Level 2: EndToEndRetryBudgetMiddleware stamps each request with budget B,
bounding total retries across multi-hop chains.

Includes 17 experiment configs (8 SYSNAME + 9 baselines), 22 unit tests,
and paper figure generation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…budget

Track per-window request rate and cap the retry budget at
max_retry_ratio * request_rate to prevent initial burst overshoot
when the goodput EWMA is stale at fault onset.
Add /api/param_compare endpoint that sweeps a shared parameter across
all strategies, computing fault-phase-only metrics. Frontend renders
grouped bar charts (Success Rate, Goodput, Amplification, Retry
Efficiency, P99) for side-by-side strategy comparison.
Adds admission counters in LoadLimiterMiddleware and ServiceRuntime's
pre-queue check; exports to admission_stats.json (run) and
admission_summary.json (sweep).
yazhuo and others added 23 commits April 24, 2026 10:53
Adds two new models :
- v2: 10 s observation, 10 s decision interval
- v3: 10 s observation, 2 s decision interval

Both configs reuse the May-3 v1-a sweep as their primary baseline.

Script to analyse the new models:
- plot_rl_comparison.py: align the decision plot's x-axis with the
  success-rate / latency plots via timeline.json (new `t_ref` arg in
  `read_decisions`), shade the fault window on the decision plot, and
  add `plot_resource_comparison` overlaying per-policy CPU / memory
  alongside the RL controller's own process footprint.
- resource_sampler.py: finally land the file `run-experiment.sh` has
  been calling since the v1 implementation, with an optional `--pid`
  flag (psutil) so the controller's local process can be sampled
  alongside the cluster-side pod metrics.
- run_rl_v1.sh → run_rl.sh: script is the generic RL-experiment runner
  (it dispatches whichever config you pass via --config, not just v1).
Wall-clock breakdown of every RL controller tick into the five existing
phases — observation fetch / parse / build, model inference, and DR
patch — written one record per tick to a new rl-timings.jsonl alongside
rl-observations.jsonl. No behavioural change; no relocation. Becomes
the baseline to compare optimization against.
Move the RL controller off the laptop and into the cluster. The
controller now runs as a per-policy Kubernetes Job, observations come
from a tiny aiohttp /window endpoint on each loader shard, and patches
go through the in-cluster apiserver via a service-account token. The
laptop is out of the hot loop entirely.
Move the controller's observation path from per-attempt JSON rows
(~10k/tick) to per-second pre-aggregated buckets (~40/tick) served
from a new /buckets aiohttp endpoint on the loader.

Cuts controller-tick total_ms p50 from 488ms to 24ms (but p95 still high
because it doesn't handle spikes well).
Move the in-cluster controller's observation source from the loader's
/buckets endpoint to each caller-pod's Envoy sidecar. The controller
fans out parallel HTTP fetches to pilot-agent's /stats/prometheus
endpoint on port 15020, parses the prom text, and reconstructs the
same 18-feature vector previously derived from the loader buckets.
Converts the design to HTML, drops all plot-viewer changes, and adds a
standalone HTML report builder writing to outputs/proto-report. Sets the
4-policy set (no-control, envoy-retry-budget, arolla, rb-rl-v5) and a two-phase
plan: Phase A desk-analysis of existing full-sweep + v5 data to validate the
metric/report, Phase B a 30-scenario x 4-policy x 3-repeat re-run with
across-run averaging.

Co-authored-by: Cursor <cursoragent@cursor.com>
@louiscrc
louiscrc requested a review from yazhuo June 25, 2026 17:22
@louiscrc
louiscrc force-pushed the smart-retry/prototype branch from ac334b2 to 0f07d96 Compare June 25, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants