关于「热备:共因失效、超时预算与幂等」,《收单风控阶跃与准备金生存》给出的定量结论是什么?

结论:第五章算出两条收单通道在共因份额下的可用性上界,并用同键重试、状态查询与一单一成的订单账,把每十万笔支付中 1,640 笔重复扣款降到日终零未处理。

数据口径:书中参数为示意,全部计算由书中程序生成。 本书是非个人化的经营与风险分析,不构成法律、融资或投资建议,不向任何人承诺收入。

English version

对照数据表

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

per 100,000 payments, timeout 4 s
policydouble chargesopen at end of day
A naive1,6401,640
B retry-key483483
C query4646
D C + ledger460
查看完整验算程序
# Chapter 5. p53: double charges after failover, with and without keys.
# 100,000 payments; client timeout 4 s, so from p52 a timeout happens
# with probability 0.02763 and a timed-out call has still charged the
# card with probability 0.6. The backup gateway charges with
# probability 0.97. Four policies (same seed for each):
#   A naive     : on timeout, charge the backup at once;
#   B retry-key : retry the primary once with the same idempotency key
#                 (answers with probability 0.7, never double charges),
#                 then fail over as in A;
#   C query     : B, then ask the primary for the order's status (the
#                 status call answers with probability 0.9); fail over
#                 only when the answer is "not charged" or no answer;
#   D C + ledger: C, and the order ledger accepts one success per order
#                 key; a second success is voided the same day, and the
#                 end-of-day reconciliation refunds what is left.
# Reported: double charges made, and double charges still open at the
# end of the day. All numbers illustrative.
import random

N = 100000
P_TO, P_LATE_OK, P_BACKUP = 0.02763, 0.6, 0.97
P_RETRY_ANS, P_STATUS = 0.7, 0.9


def run(policy):
    rng = random.Random(39753)
    made = open_end = 0
    for _ in range(N):
        if rng.random() >= P_TO:
            continue
        charged_primary = rng.random() < P_LATE_OK
        if policy in "BCD" and rng.random() < P_RETRY_ANS:
            continue
        if policy in "CD" and rng.random() < P_STATUS:
            if charged_primary:
                continue
        if rng.random() < P_BACKUP and charged_primary:
            made += 1
            if policy != "D":
                open_end += 1
    return made, open_end


def main():
    names = {"A": "naive", "B": "retry-key", "C": "query", "D": "C + ledger"}
    print("per {:,} payments, timeout 4 s".format(N))
    print("policy        double charges   open at end of day")
    for p in "ABCD":
        made, left = run(p)
        print("{} {:<11} {:>10,}       {:>10,}".format(p, names[p], made,
                                                   left))


if __name__ == "__main__":
    main()

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《数字商品收单风控阶跃模型、多网关热备切换与防冻卡滚动准备金母典》第 5 章「热备:共因失效、超时预算与幂等」(版本 1.0.0). 5D Library. DOI 待发布

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

BibTeX
@book{fan2026397,
  author    = {Fan, Yafu},
  title     = {Payment-Acquirer Risk Step-Functions, Multi-Gateway Hot Failover and Rolling-Reserve Survival for Digital Fleets},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论