关于「失败后的自动恢复:幂等键、指数退避加抖动、重试预算与熔断」,《零传令兵调度母典》给出的定量结论是什么?

结论:第五章说明盲目重试在一万次操作里造成 532 次重复,每秒重试在一场三十秒故障里发出 147,693 次调用,四道护栏缺一不可。

数据口径:在四卷一批的示意模拟里,改用意图编译器加调度器之后,每批人工介入均值为 9.951 次,比人工传话的 58.4 次下降 0.830;但不可逆与对外动作必须由人签字,仅签字一项就占旧口径的 0.137,是永远降不到零的地板。 书中参数为示意,全部计算由书中程序生成;全书只写调度原理与公开流程形态,不含服务器、端口、账户、密钥与任何部署命令;本书是非个人化经营分析,不构成经营、法律或运维建议。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 532

policyonceduplicatedlostextra_rowsattempts
never9,8070193010,000
blind9,468532055010,756
keyed10,00000010,756
chance an attempt runs but its reply is lost 0.049
expected duplicated ops, blind, first retry 480.2
查看完整验算程序
# Chapter 5. p51: duplicate side effects with and without idempotency.
# Model (illustrative): 10,000 operations that each append one row to a
# shared ledger. An attempt is lost on the way in with chance 0.02; a
# delivered attempt runs the append; its reply is lost with chance
# 0.05; the caller then times out and retries, up to 3 retries. Three
# policies: never retry; retry blindly; retry with an idempotency key
# that the store remembers, so a repeated key returns the first reply.
import random

N = 10000


def run(policy):
    rng = random.Random(40751)
    once = dup = lost = extra = attempts = 0
    for _ in range(N):
        effects, seen_key = 0, False
        for attempt in range(4):
            attempts += 1
            if rng.random() < 0.02:
                ok = False
            else:
                if policy == "keyed" and seen_key:
                    pass
                else:
                    effects += 1
                    seen_key = True
                ok = rng.random() >= 0.05
            if ok or policy == "never":
                break
        once += effects == 1
        dup += effects > 1
        lost += effects == 0
        extra += max(0, effects - 1)
    return once, dup, lost, extra, attempts


if __name__ == "__main__":
    print("policy        once   duplicated  lost  extra_rows  attempts")
    for name in ("never", "blind", "keyed"):
        once, dup, lost, extra, att = run(name)
        print("{:<12} {:>6,} {:>11,} {:>5} {:>11} {:>9,}".format(
            name, once, dup, lost, extra, att))
    p = 0.98 * 0.05
    print("chance an attempt runs but its reply is lost {:.3f}".format(p))
    print("expected duplicated ops, blind, first retry {:.1f}".format(
        N * p * 0.98))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《总司令自然语言意图编译、有向无环任务自动拆解与零传令兵自治调度母典》第 5 章「失败后的自动恢复:幂等键、指数退避加抖动、重试预算与熔断」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-407 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026407,
  author    = {Fan, Yafu},
  title     = {Commander Intent Compilation, Automated DAG Task Decomposition and Zero-Courier Multi-Agent Dispatch},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论