# 指数退避

**指数退避**（exponential backoff）是一种重试策略：客户端对失败的操作反复重试，每次失败后把等待时间乘以一个固定系数，使间隔逐次拉长，通常拉到一个上限为止。在分布式系统中，它几乎总是与**抖动**（jitter）配合使用——即给每个延迟加上一点随机扰动——好让同一时刻失败的大量客户端不会步调一致地重试，把正在恢复的服务压垮。<sup>[1](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter//)</sup><sup> • </sup><sup>[2](https://stackpractices.com/patterns/retry-with-jitter-pattern/)</sup>

| 关键事实 | 细节 |
|---|---|
| 核心公式 | 带上限的指数窗口：`window(n) = min(cap, initial × multiplier^n)`；初始 100 毫秒、乘数 2、上限 10 秒时，窗口依次为 100 毫秒、200 毫秒、400 毫秒，直到 10 秒<sup>[3](https://oneuptime.com/blog/post/2026-08-14-full-equal-decorrelated-jitter/view)</sup> |
| 全抖动 | 在 `[0, min(cap, base × 2^attempt)]` 内取均匀随机值休眠；把重试摊到整个窗口上，在 AWS 的争用模拟中总工作量最小<sup>[4](https://grindengineer.com/p/exponential-backoff-and-jitter)</sup> |
| 等量抖动 | 休眠 `temp/2 + random(0, temp/2)`，保留一段最短停顿；期望休眠时长为名义延迟的四分之三<sup>[5](https://throttle.com/guides/exponential-backoff-and-jitter/)</sup> |
| 去相关抖动 | 休眠 `min(cap, random(base, sleep × 3))`，从上次的休眠时长而非重试计数出发增长<sup>[4](https://grindengineer.com/p/exponential-backoff-and-jitter)</sup> |
| AWS SDK 默认值 | 指数退避加全抖动；暂时性错误基础延迟 50 毫秒，限流错误 1,000 毫秒，单次延迟上限 20 秒<sup>[6](https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html)</sup> |
| Google 的指引 | 截断指数退避加抖动：等待 `min(2^n + random-fraction, maximum-backoff)` 秒，到截止时间即停止<sup>[7](https://docs.cloud.google.com/iam/docs/retry-strategy)</sup> |
| 网络领域的源头 | 二进制指数退避规定在以太网（IEEE 802.3）的 MAC 层和 IEEE 802.11 的分布式协调功能中；TCP 必须对其重传超时施加指数退避<sup>[8](https://nistdigitalarchives.contentdm.oclc.org/digital/api/collection/p16009coll6/id/78827/download)</sup><sup> • </sup><sup>[9](https://datatracker.ietf.org/doc/rfc9293/)</sup> |

## 为什么朴素重试会失败

请求失败后立刻重试，等于给一个可能已经因过载而濒临失败的系统再添负载。指数退避的做法是“惩罚”执拗：每失败一次就拉长等待，这样长时间故障不会遭遇毫不减弱的猛攻；同时延迟设有上限，等待时间不会无界增长。<sup>[10](https://aws.amazon.com/blogs/compute/building-well-architected-serverless-applications-building-in-resiliency-part-1/)</sup>

单靠退避解决不了第二个问题。如果 100 个请求在同一毫秒失败，各自精确地睡 2 秒再重试，那么 2 秒后的同一毫秒它们会一起重试。一次发布、一次依赖故障、一个限流窗口、一段网络恢复，都可能制造出同步的重试潮，也就是惊群问题。抖动通过在窗口内或窗口附近随机取点打破这种同步，把一阵阵重试脉冲抹成大致均匀的流量。<sup>[11](https://www.macropatternsconsortium.com/blog/retry-storms-backoff-jitter)</sup><sup> • </sup><sup>[3](https://oneuptime.com/blog/post/2026-08-14-full-equal-decorrelated-jitter/view)</sup><sup> • </sup><sup>[7](https://docs.cloud.google.com/iam/docs/retry-strategy)</sup>

## 抖动算法

三种标准的抖动算法由马克·布鲁克（Marc Brooker）2015 年在 AWS 架构博客上的一篇文章推广开来，它们的区别在于保留了多少固定的指数窗口。<sup>[1](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter//)</sup>

**全抖动**丢弃确定性时间表，在上限窗口内任取均匀随机点，即 `random(0, min(cap, base × 2^attempt))`。它把每次重试摊到完整的指数窗口上，除重试序号外不保存任何状态，对客户端之间的去相关最强，代价是任何单个调用方的时序最难预测。<sup>[4](https://grindengineer.com/p/exponential-backoff-and-jitter)</sup><sup> • </sup><sup>[3](https://oneuptime.com/blog/post/2026-08-14-full-equal-decorrelated-jitter/view)</sup>

**等量抖动**保留一半名义延迟固定，另一半随机化。名义延迟 2 秒时，实际范围为 1 到 2 秒，这比全抖动保留了更长的最短停顿，同时仍能打散唤醒时刻；期望延迟为名义值的四分之三。其直觉是避免过短的休眠，始终保留退避带来的一部分减速；但它把每次重试都推迟到窗口的后半段，可能让客户端不必要地保持同步并受到拖延。<sup>[5](https://throttle.com/guides/exponential-backoff-and-jitter/)</sup><sup> • </sup><sup>[1](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter//)</sup><sup> • </sup><sup>[3](https://oneuptime.com/blog/post/2026-08-14-full-equal-decorrelated-jitter/view)</sup>

**去相关抖动**完全不管重试计数，计算 `min(cap, random(base, sleep × 3))`，下一个区间取决于上一次随机后的延迟。服务器恢复后它能更快爬回正常速度，在某些负载下能缩短完成时间，代价是客户端要保存更多状态，序列也更难预测。<sup>[4](https://grindengineer.com/p/exponential-backoff-and-jitter)</sup><sup> • </sup><sup>[3](https://oneuptime.com/blog/post/2026-08-14-full-equal-decorrelated-jitter/view)</sup>

此外还有其他策略。百分比策略围绕名义延迟上下浮动，例如正负 20%；gRPC 的文档写的正是这个，施加 ±20% 抖动，使 `initialBackoff` 为 100 毫秒时实际延迟落在 `[80 ms, 120 ms]`。它的分布比全抖动窄，除非另设上限，否则可能超过名义值。<sup>[12](https://grpc.io/docs/guides/retry/?trk=article-ssr-frontend-pulse_little-text-block)</sup><sup> • </sup><sup>[5](https://throttle.com/guides/exponential-backoff-and-jitter/)</sup>

## 布鲁克的争用模拟

布鲁克那篇博文模拟了乐观并发控制：众多客户端反复尝试更新同一数据库行，网络平均延迟 10 毫秒、方差 4 毫秒。有 N 个客户端争用时，每轮只有一个能成功，因此完成时间线性增长，总工作量随 N² 增长。加入带上限的指数退避只有一点点帮助：调用频率降低了，但仍然成簇，争用并未减少多少。<sup>[1](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter//)</sup>

加入抖动消除了间隙，产生大致恒定的调用速率。100 个客户端争用时，抖动使调用次数减少一半以上，完成时间也比无抖动的退避显著改善。比较几种抖动变体，全抖动与等量抖动的调用次数大致相同，而等量抖动耗时多得多；全抖动比去相关抖动工作量更少，但耗时略多。朴素指数退避在两个维度上都输了，耗时多到只能从对比图上撤下。布鲁克的结论是，带抖动的退避“应被视为远程客户端的标准做法”。<sup>[1](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter//)</sup><sup> • </sup><sup>[4](https://grindengineer.com/p/exponential-backoff-and-jitter)</sup>

这些方法都没有改变争用下工作量的二次性质；它们只是在合理的争用水平上大幅减少工作量。<sup>[1](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter//)</sup>

## 共享介质网络中的起源

退避算法比分布式云系统出现得更早。1970 年，诺曼·艾布拉姆森（Norman Abramson）为 ALOHA 系统提出了广播信道的随机接入；多址接入的第一个退避算法出现在 1973 年一篇关于时隙 ALOHA 的全国计算机会议论文中，它把冲突分组的重传延迟一个在 K 个时隙上均匀选取的随机时间。<sup>[13](https://www.cs.utexas.edu/~lam/NRL/backoff.html)</sup> 随后[罗伯特·梅特卡夫](https://www.edgepedia.org/zh/robert-metcalfe)（Robert Metcalfe）和大卫·博格斯（David Boggs）为以太网提出了二进制指数退避：一个已经历 i 次失败尝试的处理器，在再次尝试前等待一个随机时间，即均值为 2^i 的几何随机变量；它的各种变体构成了以太网与 TCP/IP 的基础。<sup>[14](https://www.sciencedirect.com/science/article/pii/S0022000025000200)</sup> 在以太网传输算法中，对第 N 次传输（1 ≤ N ≤ 10），发送方随机选取满足 0 ≤ k < 2^N 的 k，于是同一分组每经历一次冲突，退避值的范围就翻一倍。<sup>[15](https://www.gti.bh/Library/assets/computernetworks75dfgcompressed.pdf)</sup>

二进制指数退避至今仍规定在以太网（IEEE 802.3）的 MAC 层和无线局域网标准 [IEEE 802.11](https://www.edgepedia.org/zh/ieee-802-11) 的分布式协调功能中。<sup>[8](https://nistdigitalarchives.contentdm.oclc.org/digital/api/collection/p16009coll6/id/78827/download)</sup> 它的理论行为已被大量研究：2003 年 NIST 的一项分析表明，按吞吐量定义的稳定性，指数退避是稳定的，随着提供负载增长，吞吐量收敛到非零常数；并求出一般情形下的最优退避因子为 r = 1/(1 − e⁻¹)，二进制指数退避是 r = 2 的特例。<sup>[16](https://www.nist.gov/publications/stability-exponential-backoff)</sup> 后来的工作更不客气：奥尔杜斯（Aldous）证明了在凯利（Kelly）模型下，二进制指数退避对任何正到达率都不稳定；2025 年的一篇论文则证明了更强的结论：没有任何退避协议对任何正到达率是稳定的。<sup>[17](https://arxiv.org/abs/2602.21315)</sup>

## TCP 中的指数退避

TCP 把同样的思路用于重传定时。RFC 1122 规定，对同一报文段的反复重传所使用的重传超时（RTO）值必须施加指数退避；RFC 9293 要求每个 TCP 端点都支持基本的拥塞控制算法——慢启动、拥塞避免和 RTO 指数退避——以防止导致拥塞崩溃的情形。RFC 6298 规定了 RTO 值如何按指数退避；在随后某个携带新数据的报文段被发出、并在未发生任何重传的情况下得到确认之前，退避后的值一直有效。<sup>[9](https://datatracker.ietf.org/doc/rfc9293/)</sup>

## 实现指引

**优先用 SDK。** 多数 AWS SDK 在标准或自适应模式下把指数退避与抖动作为重试行为的一部分，因此调用 AWS 服务时无需自写逻辑即可使用这一模式。<sup>[1](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter//)</sup> AWS SDK 的重试公式为 `delay = random(0, 1) × min(20,000 ms, base_delay × 2^retry)`，暂时性错误的基础延迟为 50 毫秒，限流错误为 1,000 毫秒，单次延迟上限 20 秒。<sup>[6](https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html)</sup> Google Cloud 客户端库同样实现了指数退避，参数可配置，包括重试次数、最大重试延迟、总超时、重试乘数、幂等策略和初始等待时间。<sup>[18](https://cloud.google.com/blog/topics/developers-practitioners/improving-availability-your-cloud-storage-automatic-retries-client-libraries)</sup> 在 SDK 之外再套一层重试循环可能造成嵌套重试；而关掉 SDK 的重试，则可能丢掉服务特有的错误分类和重试配额。<sup>[3](https://oneuptime.com/blog/post/2026-08-14-full-equal-decorrelated-jitter/view)</sup>

**只重试安全的东西。** 只重试看起来是暂时性的失败，例如网络超时、503 响应、连接重置和限流，并且只在重放操作安全时才重放。认证失败不应重试，应立即失败。Google Cloud Storage 把操作分为始终幂等（所有 get 和 list 请求、创建或删除存储桶）、条件幂等（由 `ifGenerationMatch` 之类前置条件保护的更新）和从不幂等（创建 HMAC 密钥或 Pub/Sub 通知），默认只重试前两类。<sup>[2](https://stackpractices.com/patterns/retry-with-jitter-pattern/)</sup><sup> • </sup><sup>[19](https://aws.amazon.com/blogs/database/building-resilient-applications-design-patterns-for-handling-database-outages/)</sup><sup> • </sup><sup>[20](https://docs.cloud.google.com/storage/docs/retry-strategy)</sup>

**给策略设界。** 配置最大重试次数或最长耗时，以免积压造成亚稳态故障；服务器返回 `Retry-After` 头时应遵照执行；把原始请求与重试分开计数，使尝试次数上限只有一种明确含义。共享的重试预算若被所有客户端同时耗尽，会导致同步放弃；一次成功应当重置或衰减时间表。<sup>[21](https://docs.aws.amazon.com/wellarchitected/latest/framework/rel_mitigate_interaction_failure_limit_retries.html)</sup><sup> • </sup><sup>[5](https://throttle.com/guides/exponential-backoff-and-jitter/)</sup>

**测试整个机群。** 因为典型的失效模式是同步抖动——每个客户端用同样的方式播种随机数，或使用同一个固定窗口——所以要测试整个机群的重试分布，而不只是单条随机序列。<sup>[3](https://oneuptime.com/blog/post/2026-08-14-full-equal-decorrelated-jitter/view)</sup>

## 如何选择策略

全抖动是自研分布式客户端重试循环的常见默认选择：它以极小的状态和复杂度把重试摊到整个带上限的指数窗口上，在 AWS 公布的模拟中表现良好。等量抖动适合这样的场景：被依赖的服务需要一段最短恢复窗口才值得再次探测；但需要证据来证明多等的价值。去相关抖动能改善某些长时运行或高争用的负载，代价是更多状态和更难预测的时序。这些是权衡，而非普遍排名；有成熟库或协议规范可依时，应优先于自己手搓的选择。<sup>[3](https://oneuptime.com/blog/post/2026-08-14-full-equal-decorrelated-jitter/view)</sup><sup> • </sup><sup>[4](https://grindengineer.com/p/exponential-backoff-and-jitter)</sup><sup> • </sup><sup>[22](https://letsbuildsolutions.com/blog/system-design/retry-patterns-in-distributed-systems-exponential-backoff-jitter-and-dead-letter-queues/)</sup>

## References

1. [Marc Brooker (2015). Exponential Backoff and Jitter. AWS Architecture Blog.](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter//)
2. [Retry with Jitter: Exponential Backoff and Random Jitter. Stack Practices.](https://stackpractices.com/patterns/retry-with-jitter-pattern/)
3. [Full Jitter, Equal Jitter, or Decorrelated Jitter? OneUptime Blog.](https://oneuptime.com/blog/post/2026-08-14-full-equal-decorrelated-jitter/view)
4. [What is Exponential Backoff and Jitter? Grind Engineer.](https://grindengineer.com/p/exponential-backoff-and-jitter)
5. [Exponential Backoff and Jitter. Throttle guide.](https://throttle.com/guides/exponential-backoff-and-jitter/)
6. [Retry behavior, AWS SDKs and Tools reference.](https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html)
7. [Retry failed requests, Google Cloud IAM documentation.](https://docs.cloud.google.com/iam/docs/retry-strategy)
8. [On the stability of exponential backoff, NIST digital archives.](https://nistdigitalarchives.contentdm.oclc.org/digital/api/collection/p16009coll6/id/78827/download)
9. [RFC 9293: Transmission Control Protocol (TCP). IETF.](https://datatracker.ietf.org/doc/rfc9293/)
10. [Building well-architected serverless applications: Building in resiliency, part 1. AWS Compute Blog.](https://aws.amazon.com/blogs/compute/building-well-architected-serverless-applications-building-in-resiliency-part-1/)
11. [Preventing Retry Storms: Exponential Backoff and Jitter Design. Macro Patterns Consortium.](https://www.macropatternsconsortium.com/blog/retry-storms-backoff-jitter)
12. [Retry, gRPC documentation.](https://grpc.io/docs/guides/retry/?trk=article-ssr-frontend-pulse_little-text-block)
13. [Simon S. Lam. Binary Exponential Backoff in Ethernet: Origin, University of Texas at Austin.](https://www.cs.utexas.edu/~lam/NRL/backoff.html)
14. [Instability of backoff protocols with arbitrary arrival rates. Journal of Computer and System Sciences / arXiv.](https://www.sciencedirect.com/science/article/pii/S0022000025000200)
15. [An Introduction to Computer Networks, Release 1.8.17.](https://www.gti.bh/Library/assets/computernetworks75dfgcompressed.pdf)
16. [Song, N.-O., Kwak, B.-J., Miller, L. E. (2003). On the Stability of Exponential Backoff. NIST Journal of Research.](https://www.nist.gov/publications/stability-exponential-backoff)
17. [The Instability of all Backoff Protocols. arXiv:2602.21315.](https://arxiv.org/abs/2602.21315)
18. [Improving the availability of your Cloud Storage: Automatic retries in client libraries. Google Cloud Blog.](https://cloud.google.com/blog/topics/developers-practitioners/improving-availability-your-cloud-storage-automatic-retries-client-libraries)
19. [Building resilient applications: design patterns for handling database outages. AWS Database Blog.](https://aws.amazon.com/blogs/database/building-resilient-applications-design-patterns-for-handling-database-outages/)
20. [Retry strategy, Google Cloud Storage documentation.](https://docs.cloud.google.com/storage/docs/retry-strategy)
21. [REL05-BP03 Control and limit retry calls. AWS Well-Architected Framework.](https://docs.aws.amazon.com/wellarchitected/latest/framework/rel_mitigate_interaction_failure_limit_retries.html)
22. [Retry Patterns in Distributed Systems: Exponential Backoff, Jitter, and Dead Letter Queues. Let's Build.](https://letsbuildsolutions.com/blog/system-design/retry-patterns-in-distributed-systems-exponential-backoff-jitter-and-dead-letter-queues/)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026; Oct 25, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Algorithms and computational methods

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/exponential-backoff

English original: https://www.edgepedia.org/exponential-backoff
