重试风暴实验室
Retry Storm Lab

原始链接: https://github.com/telemetry-sh/retry-storm-lab

**重试风暴实验室 (Retry Storm Lab)** 是一个确定性的 Python 模拟器,旨在直观展示重试策略在服务中断期间如何影响系统稳定性。虽然重试可以在短暂的故障期间提高可靠性,但在持续性故障中,它们往往会适得其反,导致请求同步、流量放大,并阻碍服务恢复。 该模拟器允许开发人员在可配置的故障窗口内模拟请求流,并对比四种不同的退避策略:立即重试、固定延迟、指数退避和全抖动 (full-jitter)。通过衡量请求放大系数、峰值需求和恢复时间等指标,用户可以观察到将恢复尝试转化为服务过载“重试风暴”的反馈循环。 主要功能包括: * **确定性建模:** 使用相同的场景和随机种子,以实现精确的策略比较。 * **易于检查:** 提供基于 Streamlit 的实时可视化界面,以及用于程序化测试的稳健 Python API。 * **极简设计:** 专注于排队动态而非复杂的生产环境,是理解分布式系统权衡的理想教学工具。 需要 Python 3.11+。该工具为开源项目 (MIT),并支持可选的、以隐私为中心的聚合分析遥测。

Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Retry Storm Lab (github.com/telemetry-sh) flurly 发布于 3 小时前,5 点 | 隐藏 | 过往 | 收藏 | 讨论 | 帮助 考虑申请 YC 2026 年秋季班!申请截止日期为 7 月 27 日。 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系方式 搜索:
相关文章

原文

A retry is not free. See when your recovery policy becomes the outage.

Retry Storm Lab is a deterministic Python simulator for partial dependency failures. It models fresh requests and retries competing for the same capacity, then compares immediate, fixed, exponential, and full-jitter backoff policies.

Retry Storm Lab showing a dependency outage simulation

Retries improve reliability when failures are brief and spare capacity exists. During a sustained partial outage, synchronized clients can instead amplify demand, starve fresh requests, and keep a recovering service overloaded.

The simulator makes that feedback loop visible:

  • Generate a steady stream of fresh requests.
  • Reduce successful capacity during a configurable failure window.
  • Reschedule failed and over-capacity attempts using the selected policy.
  • Measure amplification, peak demand, abandoned requests, and recovery time.
  • Compare all four policies against the exact same scenario and random seed.

This is an intentionally small queueing model, not a production capacity planner. It omits network latency distributions, client timeouts, autoscaling, circuit breakers, and correlated downstream failures. Its job is to make retry dynamics easy to inspect and discuss.

Python 3.11 or newer is required.

python -m venv .venv
source .venv/bin/activate
pip install -e .
streamlit run app.py

Open http://localhost:8501, choose a preset, and adjust the workload from the sidebar.

retry-storm-lab --preset "Rate-limit spiral" --compare
retry-storm-lab --preset "Slow recovery" --policy full_jitter --json

Example comparison:

immediate    amplification=1.11x peak=2720 rps success=97.2% recovery=1s
fixed        amplification=1.08x peak=1600 rps success=99.9% recovery=3s
exponential  amplification=1.07x peak=1600 rps success=100.0% recovery=3s
full_jitter  amplification=1.10x peak=1651 rps success=99.9% recovery=3s

Exact values depend on the selected preset and seed.

Use the simulation engine

from retry_storm_lab import BackoffPolicy, SimulationConfig, simulate

result = simulate(
    SimulationConfig(
        baseline_rps=800,
        server_capacity_rps=1_000,
        outage_failure_percent=80,
        policy=BackoffPolicy.FULL_JITTER,
    )
)

print(result.amplification_factor)
print(result.peak_rps)
print(result.recovery_seconds)

The engine uses aggregate 100 ms buckets. Full jitter distributes retries individually with a seeded pseudo-random generator, so the same configuration always produces the same result.

Optional aggregate telemetry

The lab works entirely offline. To record aggregate usage bands with Telemetry, install the optional dependency and provide a project API key:

pip install -e '.[telemetry]'
export TELEMETRY_API_KEY=your_project_api_key
streamlit run app.py

Only the selected policy, broad capacity/amplification bands, and whether the run recovered are sent. Raw workload values and timeline data are not logged.

python -m unittest discover -s tests -v
python -m compileall app.py retry_storm_lab

MIT

联系我们 contact @ memedata.com