关于「扩展收缩式迁移:可回滚性图与把不可逆步骤推到最后」,《单机零停机热迁与十秒止血》给出的定量结论是什么?
结论:第二章把迁移画成可回滚性图:观察期 24 小时时,扩展收缩式的回滚失败率比一步到位低 10.39 倍;两份容器并存时 560 种交错中只有 8 种安全。
数据口径:书中只讲通用的数学模型,例子用虚构的 app-blue、app-green 与 db;参数为示意,全部计算由书中程序生成,程序不连接任何服务器;本书是非个人化的经营与工程参考,生产变更须按运维协议人工放行。 书中以标注框区分已发表的证据、可运行的 Python 计算(22 段程序)、原典与作者的假说。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 10.39, 24
expand-contract: bake B (hours) before each contract step
B P(fast) P(ok) E[time] s
0 0.0000 0.8802 3909.0
1 0.3645 0.9364 1999.7
6 0.7086 0.9741 763.0
24 0.8930 0.9904 242.8
72 0.9634 0.9957 78.5
168 0.9866 0.9972 31.7
720 0.9984 0.9979 11.3
big-bang: every rollback is a restore of 3600 s
restore success 0.50 -> P(ok) 0.5000
restore success 0.70 -> P(ok) 0.7000
restore success 0.90 -> P(ok) 0.9000
restore success 0.99 -> P(ok) 0.9900
B = 24 h against big-bang at 0.90: failure 0.0096 vs 0.1000, ratio 10.39查看完整验算程序
# Chapter 2. p22: rollback success against the bake period before the
# contract steps (a dose-response sweep).
# Model: a migration carries a latent fault. Once the new read path is
# live, the fault is noticed after a time X, lognormal with median 2 h
# and spread 2 (most faults show within hours, a few after weeks).
# Expand-contract waits a bake period B before step F (stop old
# write) and another B before step G (drop old column). The rollback
# cost then depends on where X falls (times and success from p21):
# X < B fast undo, 9 s, success 0.998
# B <= X < 2B undo with reverse backfill, 309 s, success 0.978
# X >= 2B restore from backup, 3909 s, success 0.8802
# Big-bang is irreversible from the start: restore with success r.
# All figures are illustrative.
import math
MED_H = 2.0
SPREAD = 2.0
TIERS = ((9.0, 0.998), (309.0, 0.978), (3909.0, 0.8802))
BAKES = (0.0, 1.0, 6.0, 24.0, 72.0, 168.0, 720.0)
def cdf(x_h):
if x_h <= 0.0:
return 0.0
z = (math.log(x_h) - math.log(MED_H)) / SPREAD
return 0.5 * (1.0 + math.erf(z / math.sqrt(2.0)))
def expand_contract(bake):
p1 = cdf(bake)
p2 = cdf(2.0 * bake) - p1
p3 = 1.0 - p1 - p2
w = (p1, p2, p3)
succ = math.fsum(wi * s for wi, (_, s) in zip(w, TIERS))
time = math.fsum(wi * t for wi, (t, _) in zip(w, TIERS))
return p1, succ, time
print("expand-contract: bake B (hours) before each contract step")
print("%8s %10s %10s %12s" % ("B", "P(fast)", "P(ok)", "E[time] s"))
for b in BAKES:
p1, s, t = expand_contract(b)
print("%8.0f %10.4f %10.4f %12.1f" % (b, p1, s, t))
print("big-bang: every rollback is a restore of %.0f s" % 3600.0)
for r in (0.5, 0.7, 0.9, 0.99):
print(" restore success %.2f -> P(ok) %.4f" % (r, r))
_, s24, _ = expand_contract(24.0)
print("B = 24 h against big-bang at 0.90: failure %.4f vs %.4f,"
" ratio %.2f" % (1.0 - s24, 0.10, 0.10 / (1.0 - s24)))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《单机多容器零停机热迁与回滚、共享隧道架构生产库无损演进与十秒止血契约母典》第 2 章「扩展收缩式迁移:可回滚性图与把不可逆步骤推到最后」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-269 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026269,
author = {Fan, Yafu},
title = {Zero-Downtime Hot Migration and Rollback on Multi-Container Single Hosts: Lossless Schema Evolution behind a Shared Tunnel and a Ten-Second Stop-the-Bleeding Contract},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}