Cloudflare 选择 QuePaxa:一种不寻常的共识算法
Choosing QuePaxa, an unusual consensus algorithm
The Cloudflare Blog
以下为原文逐段中文翻译,保留图表与说明。AI 翻译并经 AI 对照复核,仍可能存在错误;核对数据和引用时请同时查看原文。译文发布:2026年11月12日 07:34(北京时间)。
Cloudflare 最近发布了 Meerkat,这是一个实验性的分布式共识服务,旨在管理我们的内部全球控制平面。它由研究人员 Tennage 与 Băsescu 等人于 2023 年发表的名为 QuePaxa 的新共识算法驱动。
QuePaxa 是一个不寻常的选择;大多数共识系统使用成熟可靠的共识算法,如 Raft、(Multi-)Paxos 或 Viewstamped Replication。这些算法已被充分理解,拥有成熟的实现,并且通常运行良好。
遗憾的是,常见的共识算法在连通性和延迟波动很大的广域网络(即像互联网这样的网络,Meerkat 正是运行于其上)中往往表现不佳。这些算法依赖于一个单一的领导者进程保持可用并具有可预测的延迟。如果领导者宕机、出现比平时更高的延迟,或与集群断开连接,整个共识系统就会变慢或变得不可用,直到领导者被替换为止。这对 Meerkat 来说是不可接受的。
Meerkat 的全球部署环境促使我们采用一种更新的共识算法 QuePaxa,它承诺在波动环境下保持更好的稳定性,这在很大程度上是因为它不依赖领导者来推进。在本文中,我们将解释为什么选择 QuePaxa,以及 QuePaxa 算法是如何工作的。
我们所构建的以及它为何独特
Meerkat 是一个分布式系统,其中的副本就一个有序的事件日志达成一致,其中每个事件都由共识算法决定。
共识算法让一组机器能够对单一的共享真相达成一致,即使其中某些机器崩溃或断开连接。共识算法提供了一个重要保证:机器永远不会决定相互冲突的值。这确保了 Meerkat 副本的日志永远不会分歧。
Meerkat 利用其共识驱动的日志对外提供诸如键值存储之类的应用,其中日志中的每一项都是一个 get 或 put 操作。由于共识算法保证副本的日志永远不会分歧,它们都构建出相同的键值(KV)状态。类似的共识驱动系统包括 Consul、etcd 和 Apache ZooKeeper。
然而,与类似系统不同的是,Meerkat 是为全球规模而设计的。一个 Meerkat 集群可能横跨多个大陆分布,并由通常表现出高且多变延迟的链路连接。这对共识系统来说是一种不寻常的部署方式,因为共识系统通常部署在更小、更本地的网络中,并且有着严格的延迟要求。
全球规模下共识所面临的挑战
尽管所有共识算法都确保副本对同一个值达成一致,但当网络状况恶化(但机器并未崩溃)时,其中许多算法会变得不成比例地不可用或缓慢。我们曾亲眼目睹这种情况:2020 年,Cloudflare 一个核心网络交换机的部分故障导致一个共识驱动的系统性能下降,仪表盘的运行速度比平时慢了 80 倍,持续了六个小时。关键的是,系统没有丢失任何数据。但在问题解决之前,它变得无法写入,这是不可接受的。
理想情况下,共识算法应该能够在延迟突增和连接中断的情况下依然推进,而不仅仅是能够应对副本故障。这在全球规模下尤其成问题,因为故障更可能源自网络,而非我们自己的服务器。
让我们考察共识算法的两个常见特性,它们会在恶劣的网络条件下导致性能下降:破坏性干扰和故障检测。稍后,我们将看到 QuePaxa 是如何规避这两个问题的。
破坏性干扰与领导者
以 Paxos 为例,它是绝大多数共识算法名副其实的鼻祖。许多共识算法都继承了 Paxos 的结构——既有好的一面,也有不那么好的一面。
略去大量细节,Paxos 的工作原理如下。有两种进程:提议者(proposers)和接受者(acceptors)。抽象地说,系统的目标是让多数接受者就某个提议者提出的值达成一致。它有两个阶段:准备(Prepare)阶段和接受(Accept)阶段。在准备阶段,任何提议者都可以向多数接受者发送一个选票编号(ballot number)。这个选票编号相当于一个承诺——接受者只会接受带有该选票编号或更高编号的提案。然后,在接受阶段,提议者将其提案连同选票编号再次发送给多数接受者。如果多数接受者仍然持有该提案的选票编号,多数方就接受它,提议者就可以安全地决定该提案。

当两个或多个提议者同时提交提案时,就会出现问题。具体而言,另一个提议者可以在两个阶段之间插入自己更高的选票编号,从而阻塞任何更低的选票。两个提议者会反复阻止彼此推进——实际上是在竞争被接受。

当提议者以这种方式相互竞争并彼此阻塞时,我们说它们发生了破坏性干扰。随着越来越多提议者提出自己的选票,破坏性干扰会变得更严重。并发的提议者越多,系统陷入反复提案而无法推进的可能性就越大。即使没有任何副本崩溃或不可用,多个提议者和行为异常的网络也能阻塞 Paxos。严格地说,我们说 Paxos 无法保证活性(即提案最终会被决定),除非假设在某个时刻所有消息都会在有限的时间内到达——这一假设被称为部分同步(partial synchrony)。
为了避免多个提议者不断竞争,大多数已部署的共识算法(如 Raft、Multi-Paxos 和 Viewstamped Replication)都增加了一个特殊的领导者提议者。领导者是唯一可以提出提案的副本。将提案权集中在一个副本上,可以为并发请求强制确立一个顺序,避免相互竞争的提案,并且还带来一个额外的好处:决策只需一次最优的网络往返即可完成,而不是两次。在领导者健康且网络表现良好的情况下,基于领导者的协议速度很快。

其代价是,领导者必须保持运行且可达。当它发生故障、变得过于缓慢或与集群断开连接时,系统就会停滞。唯一的解决办法是让剩余的副本检测到领导者已经失效,并选举一个新的来替代它。
当领导者恢复不稳定时
当领导者失效时,系统必须通过选举新的领导者来恢复。有趣的是,领导者恢复往往是破坏性干扰悄悄重新潜入基于领导者的系统的途径。
以 Raft 为例。出于安全原因,Raft 通过多数投票来选举新的领导者。一个怀疑领导者已失效的副本会宣布自己成为领导者候选人,并向其他副本请求投票。如果超过半数的副本同意投票给该候选人,它就成为新的领导者。如果没有,则再次发起选举,候选人重新尝试。
多个副本都可能成为候选人——它们只需要检测到领导者已下线即可。随后这些候选人可能同时尝试获得多数票。问题在于候选人会竞争多数票,这意味着 Raft 的选举会遭受我们刚才在 Paxos 中看到的破坏性干扰:两个副本可能相互阻止对方获得多数支持并成为领导者。选举失败的次数越多,就会有越多的副本试图让自己当选领导者。

即使领导者不再有故障,选举仍会持续干扰本应正常的系统运行。这被称为亚稳态故障(metastable failure):一种即使最初的故障原因已被消除仍会自我延续的故障模式。两秒钟的网络中断——或者一个短暂故障的网络交换机——可能让领导者看起来有故障,从而强制发起一次领导者选举;而这次选举可能失败,进而强制进行更多次选举。中断在两秒钟内就会结束,但只要候选人继续相互阻塞,选举就可能持续更久。
理想情况下,共识算法根本不需要任何恢复过程,因为恢复过程复杂、容易产生干扰,并且会引入另一个导致停机的因素。
当故障检测出错时
领导者选举中的破坏性干扰问题,因过度敏感的故障检测而更加严重,尤其是在广域网络中。为了让基于领导者的共识算法选出一个新的领导者,副本必须首先检测出领导者已经失效。然而,如果副本对领导者失效的检测不准确,系统就可能在恢复中耗费过多时间,而无法处理请求。
在机器通过网络相互分离的分布式系统中,故障检测最终依赖于预期。一个进程无法直接观察到远程进程已经失效;它只能观察到预期的消息是否到达。我们需要一种可预测的通信模式,例如心跳或确认,来告诉我们某台机器是健康的。如果预期的消息没有在预期时间内到达,我们就怀疑发生了故障。难点在于管理这些预期。
在真实的网络中,尤其是广域网络中,消息并不总是如预测般准时到达。消息到达所需的时间没有保证的上限。这并不是说网络很慢,或者说它不可靠——大多数消息都会在我们预期的时间内到达。相反,延迟的突然爆发和连接的丢失可能毫无预警地、瞬时地增加任何消息穿越网络所需的时间。我们将此类网络称为异步网络。
异步网络的一个大问题是,如果某个服务器在给定时间内没有回复,我们其实无法知道是服务器已失效,还是网络只是很慢——这两者在网络上是无法区分的。任何实用的故障检测器都不得不根据其等待时间相对于预期时间的长短做出猜测,而这样的猜测有时是错误的。

在基于领导者的算法中,这个猜测正是触发领导者选举的原因。有时领导者确实宕机了;有时只是它的消息延迟了,或者连接被悄然断开。协议在做出反应之前无法知道发生的是哪一种情况。如果猜测是错误的,而某个副本认为领导者有故障而实际上它并没有,那么选举就会开始,整个系统必须停止。在领导者被替换之前,系统无法推进——而正如我们刚才所见,这可能会持续一段时间。
在异步网络中,故障检测从根本上就容易出错,而当检测器犯错时,我们就会遭遇停机。
当故障检测很慢时
即使故障检测器猜测正确,也仍然存在问题。故障检测器通过观察网络上的消息来响应故障,因此它们的响应时间必须与网络延迟成比例——检测器的超时不能低于网络延迟。这就是为什么 Raft 通常部署为选举超时时间等于网络往返时间的五到十倍。它必须足够高,以便给领导者发出存活信号的机会,并避免错误地触发选举。选举超时也可以设得比这更低,但由于领导者选举会完全停止系统,超时通常被保守地设得较高。
粗略地说,半个地球往返一次的往返时间是以数百毫秒来衡量的。如果选举超时是若干个往返时间,那么检测到一个失效的协调者可能需要大约一秒。即使故障检测完全准确,它也很慢,并且在高延迟的全球网络中最为缓慢。在检测器做出反应之前,系统都处于停机状态。
为什么 QuePaxa 是合适的选择
我们意识到,任何依赖严格领导者或精确超时的算法,在一个运行于互联网之上的共识系统中都不可避免地会停滞。我们寻找那些为异步环境设计的共识算法——即不依赖表现良好的网络或精确时序就能运作的协议。这让我们找到了 2023 年由 Tennage 与 Băsescu 等人发表的 QuePaxa。
QuePaxa 最显著的一点在于,它能在有利的网络条件下通过单次往返高效地达成共识,同时还能在延迟突增、连接问题和服务器故障时优雅地降级性能。QuePaxa 通过解决我们刚才讨论的那些确切问题来实现这一点,具体依靠三个关键设计选择:引入一个可选的领导者、彻底消除对故障检测的依赖,以及为提议者之间的建设性干扰而设计。
在 QuePaxa 中,与 Paxos 非常相似,有两种角色:提议者(proposers)和记录者(recorders)。提议者提交待决定的提案,而记录者充当提议者之间的中介,记录它们看到的每一个提案。

在 QuePaxa 中,提议者不会相互竞争以让自己的提案被决定,而是会协作地朝着一个所有人都支持的提案努力。QuePaxa 通过为提案分配一个以随机数形式表示的优先级来实现这一点。可选的领导者拥有独占的最高优先级。在执行过程中,提议者将它们的提案提交给记录者,记录者再将提案传播给其他活跃的提议者。当提议者从记录者处收到一个优先级高于自身的提案时,它们就会把新提案当作自己的提案来采纳,即转而开始广播这个更高优先级的提案。一般而言,QuePaxa 中的提议者会协同工作,以决定它们集体所知的最高优先级提案。这意味着提议者无法无限期地将彼此排除在决定提案之外。

需要注意的一点是,可能无法把提案传播得足够充分以就某个提案达成一致,因此提议者必须再次尝试,每一次尝试构成一个轮次(round)。然而,随着提交提案的提议者增多,它们就越有可能收敛到最高优先级的提案上。这正是 QuePaxa 成为随机化算法的缘由:非领导者提议者随机生成的优先级很可能——但并不能保证——在一轮中促成对已知最高优先级的共识。不过,只要经过足够多的轮次,提议者就必定能就某个提案达成一致。
有一个提议者被指定为领导者。领导者是唯一能够在单次往返中完成决定的提议者。领导者总是以最高优先级提出提案;如果领导者知道自己先于任何其他提议者传播了自己的提案,那么它就可以立即决定。客户端并不被强制向领导者发起请求——任何提议者都可以提出提案。如果领导者宕机,客户端可以继续向其他提议者发起请求。领导者是完全可选的。领导者无非是比其他任何提议者更有可能、并且能更快地通过单次往返来完成决定。
然而,由于领导者是唯一能在单次往返中完成决定的角色,我们希望尽可能使用它。为了利用这条快速路径而又不制造单点故障,向系统发送提案的客户端会采取对冲策略(hedge):它们将提案请求发送给每一个副本,而非领导者的副本会等待一个短暂的超时,以便领导者能够自行提出并决定。在我们自己的 QuePaxa 实现中,我们实际上偏离了论文的做法,让客户端而不是副本来等待对冲超时,以减少我们在网络上发送的消息数量,但总体结果是相同的。
这种对冲超时与 Raft 或 Multi-Paxos 中使用的超时截然不同。它不是故障检测,因此不受网络延迟的约束;它由副本在本地决定,可以想设多小就设多小。在 Raft 中,在延迟为 100 毫秒的网络里使用 5 毫秒的超时,会完全冻结系统。但在 QuePaxa 中,5 毫秒的对冲超时只是增加了活跃提议者的数量。
然而,对冲并非没有代价:提议者越多,被广播的提案就越多,副本在某一轮中无法决定的可能性也就越大。相反,对冲提供了一种权衡:我们可以通过降低对冲超时来更快地响应领导者的变更,但会承担额外的带宽成本,并且可能需要更长时间来决定。这是一个我们非常乐意做出的权衡。
如果 QuePaxa 的领导者宕机,我们可以以我们想要的速度进行恢复——我们不受网络延迟的束缚。这正是 QuePaxa 规避故障检测的方式:由于任何人都可以提出提案,而不仅仅是领导者,QuePaxa 可以通过对冲主动应对领导者失效,而不是对失效做出被动反应。
QuePaxa 的内部工作原理
为了理解 QuePaxa 是如何赋予我们所有这些优良特性的,让我们看看 QuePaxa 实际是如何运作的。
QuePaxa 以由四个阶段组成的轮次运作。如果在最后一个阶段中某个提案尚未被决定,就会启动一个新的轮次,QuePaxa 重新开始。在每个阶段开始时,提议者将当前采纳的提案广播给所有记录者。一旦提议者收到来自多数记录者的回复,它们就进入下一个阶段。以下是各阶段的总体概览:
- 阶段 0(提议与采纳):提议者随机选择一个优先级,将它们的提案发送给记录者,并采纳它们从多数记录者处收到的最高优先级提案。如果是第一轮,且领导者知道自己的提案最先到达了多数记录者,领导者就会立即决定。
- 阶段 1(传播):提议者将已采纳的提案传播给多数记录者。
- 阶段 2(检查与决定):提议者向多数记录者询问上一阶段中所见到的最高优先级提案。如果它与自己采纳的提案一致,它们就决定采纳该提案。
- 阶段 3(延续):任何未能决定的提议者,通过采纳它们从多数记录者处所见的最优提案,为下一轮做好准备。

让我们走查几个示例执行过程,并拆解每个阶段是如何促成我们希望 QuePaxa 表现出的整体行为的。每个执行过程将有两个提议者(其中一个是领导者)和三个记录者。
领导者快速路径(阶段 0):第一阶段做三件重要的事:它将优先级随机化(这是它必须为规避 FLP 不可能性定理而做的),检查领导者是否最先获得多数支持,并在领导者未获多数支持时帮助提议者收敛。领导者的提案不做随机化,并且将始终拥有尽可能最高的优先级。

在上面的示例中,领导者的提案先于任何其他提案到达多数记录者,并收到了确认它的回复。领导者可以安全地立即决定。这看起来可能有些冒险,但由于一个名为多数交集(majority intersection)的特性,它完全安全:任意两个记录者多数集总是至少共享一个记录者。因为领导者到达了多数集,任何查询多数集的其他提议者都不可避免地会遇到领导者的提案并采纳它。由于领导者的提案拥有最高优先级,任何其他提议者都会采纳领导者的提案。因此不可能决定任何其他提案。

并发慢速路径(阶段 0-3):然而,当存在并发提议者时,并不能保证领导者会立即决定。领导者可能未能最先到达多数记录者,或者它可能只收到一个支持其他提议者的回复。让我们看看当另一个提议者向领导者发起竞争时会发生什么。
阶段 0:如下图所示,第二个提议者(以红色显示)最先到达第二和第三个记录者。快速路径被阻塞。提议者不会相互竞争,而是采纳它们从多数集收到的最高优先级提案,并进入第二阶段。两个提议者本可以在这一阶段都收敛到领导者的提案上。出于说明目的,我们的示例将通过延迟领导者的消息来阻止收敛。

阶段 1:提议者将在阶段 0 中刚刚采纳的提案传播给多数记录者。记录者会记录它们所观察到的最高优先级提案。这是一个简单但关键的步骤:它可以防止协议随后决定一个较低优先级的提案。这同样要归功于多数交集:在下一阶段中被查询的任意多数集,必然至少包含一个在本阶段见到过该已采纳提案的记录者。出于说明目的,我们通过延迟领导者发送给第三个记录者的消息来阻止本阶段的收敛,从而使该记录者不采纳领导者的提案。

阶段 2:现在,可以做出决定了。每个提议者通过向多数记录者询问在阶段 1 中观察到的最高优先级提案,来判断是否有更高优先级的提案获得了足够的支持来超越自己的提案。如果返回的最高提案仍然是它们自己所采纳的提案,它们就决定。在我们的图示中,领导者看到多数记录者返回了它自己的提案,于是安全地做出了决定。另一个提议者收到了相互冲突的摘要,因此它还无法决定。与阶段 1 类似,记录者会记录它们所收到的最高优先级提案。

阶段 3:如果某个提议者在阶段 2 中没有决定,它就会进入最后的清理阶段,为下一轮做准备。提议者再次传播它们的提案,并采纳它们在多数记录者中找到的最优提案。在这里,剩余的提议者发现了已被决定的提案并采纳它,从而进入下一轮。

这是刻意为之的——如果在前一阶段中已经有了某个决定,那么多数记录者都会持有该提案,任何剩余的提议者都必然会采纳它。我们在这里看到了提议者之间协作的又一个例子——即使某一轮失败了,提议者仍会尝试收敛到同一个进入下一轮的提案上。
进入下一轮:在第四个阶段之后,提议者进入下一轮。此时,不再有领导者快速路径,决定的唯一方式是在第三阶段中收敛。重要的是,由于提案采纳机制,随着轮次推进,做出决定会呈指数级地变得更容易。QuePaxa 论文预测每一轮有 50% 的决定概率,但在实践中,由于收敛效应,这个概率要高得多。
将全部四个阶段结合起来,我们就能看出 QuePaxa 的韧性从何而来。第一阶段为领导者提供了单往返的快速路径。如果该快速路径失败,随机优先级和提案采纳会帮助提议者收敛而非竞争。第二和第三阶段借助多数交集使得决定变得安全,而第四阶段则将提议者所学到的内容带入下一轮,以防提议者未能决定。
没有任何提议者需要在推进之前先检测出领导者已经失效,而某一轮的失败也不会丢弃已经完成的工作。当网络表现良好时,QuePaxa 速度很快。当网络表现不佳时,QuePaxa 仍在继续前进。
QuePaxa 如何成就 Meerkat
在我们自己对 Meerkat 的评估中(我们的服务器几乎遍布所有大陆),我们直接体验到了 QuePaxa 对系统整体性能和可用性的影响。即使领导者崩溃、断开连接或只是变得缓慢,Meerkat 也会持续处理请求。我们从未见过它完全停滞。这正是我们想要的。

Meerkat 处理请求的速率也大体上可预测。大多数决定——高达 95% 以上——都由领导者在第一阶段做出,这使我们的吞吐量相当稳定。在第一阶段未能达成决定的一些情况下,吞吐量会暂时下降,降至通常速率的三分之一以内,这表明需要三次往返——即三个阶段——才能做出决定,而非仅仅一次。系统会变慢,但不会彻底陷入停顿。
QuePaxa 还让我们能够在集群运行时自信地切换由哪个副本担任领导者。由于领导者并非决定背后的唯一驱动者,且提议者之间是协作的,一个暂时非最优的领导者并不像在其他算法中那样具有限制性——在其他算法中,领导者的错误配置可能导致系统完全停滞。我们可以动态地调整由哪个提议者担任领导者,而无需过于担心影响 Meerkat 集群的稳定性。
我们将在接下来展示的内容
为全球网络设计 Meerkat 迫使我们重新评估我们处理分布式共识的方式。我们没有固守那些并不完全符合我们约束的熟悉默认值,而是求助于学术界和工业界数十年来积累的研究成果。这一探索将我们引向了 QuePaxa。
选择 QuePaxa 意味着选择一条少有人走的路。它尚未像 Raft 或 Paxos 那样经过广泛的实战检验,而且我们还在对原始的崩溃停止(crash-stop)设计进行扩展,以支持崩溃恢复。这比通常的系统需要更谨慎的工程实现和更有力的正确性证据。
正因如此,我们正在对 QuePaxa 的实现以及整个 Meerkat 进行形式化验证,同时进行广泛的仿真和故障注入测试。本系列的后续文章将解释我们如何验证 Meerkat 和 QuePaxa 的 Rust 实现、我们如何测试那些在生产环境中难以复现的故障、基准测试结果,以及我们在将一个学术协议转变为生产系统过程中的所学所得。
请持续关注 Cloudflare Blog 上更多关于 Meerkat 的更新;如果你想了解更多关于 Cloudflare 的研究工作,可以查看我们在 Cloudflare Research 的成果。
展开英文原文 · 与中文逐段对应
Choosing QuePaxa, an unusual consensus algorithm
Cloudflare recently announced Meerkat , an experimental distributed consensus service designed to manage our internal global control plane. It is powered by a new consensus algorithm published by researchers Tennage & Băsescu et al. called QuePaxa (2023).
QuePaxa is an unusual choice; most consensus systems use well-established consensus algorithms like Raft, (Multi-)Paxos or Viewstamped Replication. These algorithms are well understood, have mature implementations, and usually work well.
Unfortunately, common consensus algorithms often suffer in wide-area networks with volatile network connectivity and latency, i.e., networks like the Internet, which is where Meerkat runs. These algorithms rely on a single leader process being available and having predictable latency. If the leader goes down, experiences higher latency than usual, or is disconnected, the entire consensus system slows down or becomes unavailable until the leader is replaced. This is unacceptable for Meerkat.
Meerkat’s global deployment environment led us to a newer consensus algorithm, QuePaxa, which promises better stability despite volatility, in large part by not relying on a leader to make progress. In this post we’ll explain why we chose QuePaxa and how the QuePaxa algorithm works.
What we’re building and why it’s unique
Meerkat is a distributed system in which replicas agree upon an ordered log of events, where each event is decided by a consensus algorithm.
Consensus algorithms allow a group of machines to agree on a single shared truth, even if some of those machines crash or disconnect. Consensus algorithms provide an important guarantee: machines never decide conflicting values. This ensures Meerkat replicas’ logs never diverge.
Meerkat uses its consensus-powered log to expose applications like a key-value store, where each entry in the log is a get or a put . Because the consensus algorithm guarantees replicas’ logs never diverge, they all construct the same key-value (KV) state. Comparable consensus-powered systems include Consul, etcd, and Apache ZooKeeper.
Unlike similar systems, however, Meerkat was designed for global scale . A Meerkat cluster may be distributed across continents and connected by links that often exhibit high and variable latency. This is an unusual setup for consensus systems, which are usually deployed in smaller, more local networks, and have strict latency requirements .
The challenges of consensus at a global scale
While all consensus algorithms ensure that replicas agree on the same value, many of them become disproportionately unavailable or slow when network conditions degrade (but machines do not crash). We have seen this happen firsthand: in 2020, the partial failure of a core Cloudflare network switch caused a consensus-powered system to degrade and the dashboard to operate 80x slower than usual, for six hours. Critically, the system lost no data. But it became unavailable for writes until the issue was resolved, which is unacceptable.
Ideally, a consensus algorithm should be able to make progress despite latency spikes and broken connections, not just replica failures. This is particularly a problem at global scale, where faults are more likely to originate in the network, and not our own servers.
Let’s examine two common traits of consensus algorithms that can lead to degradation under hostile network conditions: destructive interference and fault detection. Later, we’ll see how QuePaxa sidesteps both of these issues.
Destructive interference and leaders
Consider Paxos, the veritable grandfather of most consensus algorithms. A lot of consensus algorithms inherit the structure of Paxos – both the good and the not-so-good bits.
Leaving an egregious amount of detail out, here’s how Paxos works. There are two kinds of processes: proposers and acceptors. Abstractly, the goal of the system is for a majority of acceptors to agree on a value proposed by some proposer. There are two phases: the Prepare phase, and the Accept phase. In the Prepare phase, any proposer can send a ballot number out to a majority of acceptors. This ballot number serves as a promise – acceptors will only accept proposals with that ballot number or higher. Then, in the Accept phase, the proposer sends its proposal along with the ballot number to a majority of acceptors again. If a majority of acceptors still hold the ballot number of the proposal, the majority accepts it, and the proposer can safely decide the proposal.

Challenges arise when two or more proposers submit proposals at the same time. Specifically, another proposer can interleave its own higher ballot number in between the two phases, blocking any lower ballots. Two proposers can repeatedly block each other from progressing – effectively competing for acceptance.

When proposers compete and block each other in this way, we say that they destructively interfere. Destructive interference gets worse as more proposers propose their own ballots. The more concurrent proposers there are, the more likely it is that the system gets stuck repeatedly proposing. Even if none of the replicas have crashed or are unavailable, multiple proposers and misbehaving networks can block Paxos. Formally, we say that Paxos does not guarantee liveness (i.e., that proposals are eventually decided) without assuming that, at some point, all messages arrive within a bounded amount of time — an assumption known as partial synchrony.
To avoid multiple proposers constantly competing, most deployed consensus algorithms, like Raft, Multi-Paxos, and Viewstamped Replication, add a special leader proposer. The leader is the only replica that can make proposals. Centralizing the proposing power in one replica forces an order on concurrent requests, avoids competing proposals, and has the added benefit of getting decisions done in an optimal single network round-trip, instead of two. While the leader is healthy and the network is well-behaved, leader-based protocols are fast.

The trade-off is that the leader must remain operational and reachable. When it fails, becomes too slow, or is disconnected from the cluster, the system stalls. The only solution is for the remaining replicas to detect that the leader has failed, and elect a new one in its place.
When leader recovery is unstable
When a leader fails, the system must recover by electing a new one. Interestingly, leader recovery is often how destructive interference sneaks right back into a leader-based system.
Consider Raft. For safety reasons, Raft elects a new leader using a majority vote. A replica that suspects that the leader has failed announces itself as a candidate for leadership and requests a vote from other replicas. If more than half of the replicas agree to vote for the candidate, it becomes the new leader. If they don’t, then a new election is called, and the candidates try again.
Multiple replicas can become candidates — all they need to do is detect that the leader is down. The candidates may then all try to acquire a majority vote simultaneously. The problem is that the candidates will compete for the majority vote, which means Raft’s elections suffer from the destructive interference we just saw in Paxos: two replicas can mutually prevent each other from getting support from a majority and becoming the leader. The more elections fail, the more replicas will try to get themselves elected leader.

Even if the leader stops being faulty, elections continue to disrupt what could have been normal system functioning. This is known as a metastable failure : a failure pattern that perpetuates itself even when the initial cause of failure is removed. A two-second network outage — or a momentarily faulty network switch — can make the leader appear to be faulty and force a leader election, which can fail, and force further elections. The outage will be over in two seconds, but the election can continue for much longer as candidates continue to block each other.
Ideally, consensus algorithms wouldn’t need any recovery process, as they are complicated, prone to interference, and introduce another source of downtime.
When fault detection goes awry
The problem of destructive interference in leader elections is compounded by trigger-happy fault-detection, especially in wide-area networks. In order for leader-based consensus algorithms to choose a new leader, replicas must first detect that the leader has failed. However, if replicas detect leader-failures inaccurately, the system may spend an inordinate amount of time in recovery, not handling requests.
In a distributed system, where machines are separated over a network, fault detection will ultimately depend on expectations. A process cannot directly observe that a remote process has failed; it can only observe that an expected message has or hasn’t arrived. We need a predictable pattern of communication, such as heartbeats or acknowledgements, to tell us that a machine is healthy. If an expected message does not arrive within the expected time, we suspect a fault. The difficulty lies in managing those expectations.
In real networks, especially wide-area networks, messages don’t always arrive when predicted. There is no guaranteed upper bound on the time that it takes for messages to arrive. That’s not to say that the network is slow, or that it is unreliable — most messages arrive within the time we expect them to. Instead, sudden bursts of latency and losses in connectivity can, momentarily, and without warning, increase the time it takes for any message to traverse the network. We call such networks asynchronous.
The big issue with asynchronous networks is that if some server doesn’t reply in a given amount of time, we don’t really know if the server has failed or if the network is just slow — the two are indistinguishable over the network. Any practical fault detector has to make a guess based on how long it has been waiting compared to its expectation, and sometimes that guess will be wrong.

In leader-based algorithms, that guess is exactly what triggers leader elections. Sometimes the leader is down; sometimes its messages are late, or the connection is silently broken. The protocol cannot know which one happened before it reacts. If the guess is wrong, and a replica thinks the leader is faulty when it actually isn’t, then an election begins and the entire system must stop . Until the leader is replaced, no progress is made — and as we just saw, that can take a while.
Fault detection is fundamentally error-prone in asynchronous networks, and when the detector makes a mistake, we get downtime.
When fault detection is slow
Even when a fault detector guesses correctly, there are issues. Fault detectors react to failures by observing messages on the network, and so their response time has to scale with network latency — the detector’s timeout can’t be below the network latency. This is why Raft is commonly deployed with an election timeout of five to ten times the network round-trip time. It has to be high enough to give a chance for the leader to signal that it is alive, and avoid falsely triggering elections. The election timeout can be much lower than that, but since leader elections completely stop the system, timeouts are usually set conservatively high.
Roughly speaking, a round trip halfway across the world is measured in hundreds of milliseconds. If an election timeout is several round trips, detecting a failed coordinator can take around a second. Even when fault detection is completely accurate, it is slow, and it is slowest in high-latency global networks. Until the detector reacts, the system is down.
Why QuePaxa is the right fit
We realized that any algorithm relying on a strict leader or accurate timeouts was inevitably going to stall in a consensus system that runs over the Internet. We searched for consensus algorithms designed for asynchronous environments — protocols that didn't rely on a well-behaved network or precise timing to function. This led us to QuePaxa , published in 2023 by Tennage & Băsescu et al.
The most notable thing about QuePaxa is how it can efficiently reach consensus in a single round trip under favorable network conditions, but also gracefully degrades performance during latency spikes, connectivity issues, and server failures. QuePaxa achieves this by solving the exact problems we just discussed through three key design choices: having an optional leader, completely removing the reliance on fault detection, and designing for constructive interference between proposers.
In QuePaxa, much like in Paxos, there are two roles: proposers and recorders . Proposers submit proposals to be decided on, and recorders serve as intermediaries between proposers, recording every proposal they see.

Instead of having proposers compete to get their own proposals decided, in QuePaxa, proposers will cooperatively work towards a proposal that everyone supports. QuePaxa does this by assigning a priority to proposals, in the form of a random number. The optional leader gets an exclusive maximum priority. During execution, proposers submit their proposals to the recorders, who propagate the proposal to other active proposers. When proposers receive a proposal from a recorder with a higher priority than theirs, they adopt the new proposal as their own, i.e., begin broadcasting the higher priority proposal instead. In general, proposers in QuePaxa work together to decide on the highest priority proposal that they collectively know. This means proposers can’t lock each other out of deciding on a proposal, indefinitely.

The caveat is that it might not be possible to spread proposals around well enough to agree on a proposal, and so proposers have to try again, with each attempt constituting a round . However, as more proposers submit proposals, the more likely they are to converge on the highest priority proposal. This is what makes QuePaxa a randomized algorithm: the randomly generated priorities of non-leader proposers are likely — but not guaranteed — to lead to consensus on the highest known priority, in a round. Yet, given enough rounds, it is guaranteed that proposers agree on a proposal.
One proposer is designated the leader. The leader is the only proposer capable of deciding in a single round trip. The leader always proposes with the highest priority; if the leader knows it spread its proposal before any other proposer, then it can decide immediately. Clients aren’t forced to make requests to the leader — any proposer can propose. If the leader goes down, then clients can keep making requests to other proposers. The leader is completely optional . The leader is simply more likely to decide, than any other proposer, and do so faster, in a single round trip.
However, because the leader is the only one that can decide in a single round trip, we want to use it whenever possible. To exploit this fast path without creating a single point of failure, clients sending proposals to the system hedge their bets: they send their requests for proposals to every replica, and the non-leader replicas will wait for a small timeout, so the leader can propose and decide on its own. In our own implementation of QuePaxa, we actually deviate from the paper and have clients wait the hedge timeout instead of the replicas, to reduce the amount of messages we send over the network, but the overall result is the same.
This hedging timeout is very different from the timeouts used in Raft or Multi-Paxos. It is not fault detection, and so isn’t constrained by network latency; it is locally determined by replicas and can be as small as they want it to be. In Raft, having a five-millisecond timeout in a network with 100-millisecond latency would completely freeze the system. But in QuePaxa, a five-millisecond hedge timeout only increases the number of active proposers.
However, hedging isn’t free: the more proposers there are, the more proposals get broadcast, and the more likely it is that replicas fail to decide in a round. Instead, hedging provides a tradeoff: we can react faster to leader changes by lowering the hedge timeout, but we incur extra bandwidth costs and may take more time to decide. That’s a tradeoff we're more than willing to make.
If the QuePaxa leader goes down, we can recover as fast as we want — we’re not bound by network latency. This is how QuePaxa gets around fault detection: since anyone can propose, not just the leader, QuePaxa can proactively deal with leader failures by hedging, rather than reacting to failures.
How QuePaxa works under the hood
To understand how QuePaxa gives us all of these nice properties, let’s look at how QuePaxa actually works.
QuePaxa works in rounds made up of four phases. If a proposal hasn’t been decided on in the last phase, a new round is started, and QuePaxa starts over. At the start of each phase, proposers broadcast their currently adopted proposal to all recorders. Once a proposer receives a reply from a majority of recorders, they advance to the next phase. Here’s the general outline of the phases:
- Phase 0 (Propose and Adopt): Proposers randomly select a priority, send their proposals to recorders, and adopt the highest-priority proposal they receive from a majority of recorders. If it’s the first round and the leader knows its proposal reached a majority of recorders first, the leader decides immediately.
- Phase 1 (Spread): Proposers spread their adopted proposal to a majority of recorders.
- Phase 2 (Check and Decide): Proposers ask a majority of recorders for the highest-priority proposal seen in the previous phase. If it matches their own adopted proposal, they decide on it.
- Phase 3 (Carry Forward): Any proposer that failed to decide prepares for the next round by adopting the best proposal they see from a majority of recorders.

Let’s walk through a couple of example executions and unpack how each phase contributes to the overall behavior we want out of QuePaxa. Each execution will have two proposers (one of which is the leader) and three recorders.
The Leader Fast Path (Phase 0): The first phase does three important things: it randomizes priorities (which it must do to circumvent the FLP impossibility theorem ), checks if the leader reached a majority of support first, and helps proposers converge if the leader didn't. The leader’s proposal is not randomized, and will always have the highest possible priority.

In the example above, the leader's proposal reaches a majority of recorders before anyone else, and receives replies confirming it. The leader can safely decide right away. This might seem dangerous, but it is entirely safe thanks to a property called majority intersection : any two majorities of recorders always share at least one recorder. Because the leader reached a majority, any other proposer querying a majority will inevitably encounter the leader's proposal and adopt it. Since the leader’s proposal has the highest priority, any other proposer will adopt the leader’s proposal. It is impossible to decide on any other proposal.

Concurrent Slow Path (Phases 0-3) : When there are concurrent proposers, however, it is not guaranteed that the leader will immediately decide. The leader might fail to reach a majority of recorders first, or it might receive a single reply supporting another proposer. Let's look at what happens when another proposer contests the leader.
Phase 0: Pictured below, a second proposer (shown in red) reaches the second and third recorders first. The fast path is blocked. Instead of competing, proposers adopt the highest-priority proposal they receive from a majority and move to the second phase. The two proposers could both converge to the leader’s proposal in this phase. For illustrative purposes, our example will prevent convergence by delaying the leader’s messages.

Phase 1: Proposers spread the proposal they just adopted in Phase 0 to a majority of recorders. The recorders keep track of the highest-priority proposal they observe. It is a simple but critical step: it prevents the protocol from later deciding on a lower-priority proposal. This is once again thanks to majority intersection: any majority queried in the following phase must include at least one recorder that saw the adopted proposal, in this phase. For illustrative purposes, we prevent convergence in this phase by delaying the leader’s message to the third recorder, so the recorder does not adopt the leader’s proposal.

Phase 2: Now, a decision can happen. Each proposer determines if a higher-priority proposal gained enough support to overtake its own by asking a majority of recorders for the highest-priority proposal observed during Phase 1 . If the highest proposal returned is still their adopted proposal, they decide. In our diagram, the leader sees its own proposal returned by a majority and safely decides. The other proposer receives conflicting summaries, so it cannot decide yet. Like in Phase 1, recorders keep track of the highest priority proposal they received.

Phase 3: If a proposer doesn’t decide in Phase 2, it moves to the final cleanup phase to prepare for the next round. Proposers spread their proposals again and adopt the best they find among a majority of recorders. Here, the remaining proposer discovers the decided proposal and adopts it, heading into the next round.

This is deliberate — if there was some decision in the previous phase, then a majority of the recorders will have that proposal, and any remaining proposers are guaranteed to adopt it. We see here another instance of cooperation between proposers — even when a round fails, proposers try to converge on the same proposal heading into the next round.
Moving to the next round: After the fourth phase, proposers move on to the next round. At this point, there is no more leader fast path, and the only way to decide is by converging in the third phase. Importantly, due to proposal adoption, it becomes exponentially easier to decide as rounds progress. The QuePaxa paper predicts that each round has a 50% chance of deciding, but in practice, that probability is much higher, thanks to convergence.
Putting all four phases together, we can see where QuePaxa gets its resilience. The first phase gives the leader its one-round-trip fast path. If that fast path fails, random priorities and proposal adoption help proposers converge instead of compete. The second and third phases make it safe to decide, thanks to majority intersection, while the fourth carries what proposers learned into the next round, in case proposers don’t decide.
No proposer has to detect that the leader has failed before making progress, and a failed round doesn’t throw away the work already done. When the network behaves, QuePaxa is fast. When it doesn’t, QuePaxa keeps moving.
How QuePaxa makes Meerkat possible
In our own evaluations of Meerkat, where we had servers spanning nearly all continents, we’ve directly experienced the impact that QuePaxa has on the overall performance and availability of the system. Meerkat continuously processes requests, even when the leader crashes, disconnects, or just becomes slow. At no point have we ever seen it completely stall. This is exactly what we wanted.

The rate at which Meerkat handles requests has also been generally predictable. Most decisions — upwards of 95% — are made by the leader in the first phase, which keeps our throughput fairly stable. In the instances where a decision isn't reached in the first phase, the throughput drops momentarily, down to at most a third of the usual rate, signaling that three round trips — so three phases — were needed to decide instead of just one. The system slows down, but does not grind to a halt.
QuePaxa also allows us to confidently switch out which replica acts as leader while the cluster is running. Since the leader isn’t the exclusive driver behind decisions and proposers are cooperative, a temporarily non-optimal leader isn’t as limiting as in other algorithms, where a leader misconfiguration could stall the system completely. We can dynamically tune which proposer is the leader without worrying too much about impacting the stability of a Meerkat cluster.
What we’ll be showing next
Designing Meerkat for a global network forced us to re-evaluate how we approach distributed consensus. Instead of sticking to familiar defaults that didn't quite fit our constraints, we looked to the decades of research produced by academia and industry. That search led us to QuePaxa.
Choosing QuePaxa meant choosing a less-traveled path. It has not been battle-tested as extensively as Raft or Paxos, and we’re also extending the original crash-stop design to support crash recovery . This demands careful engineering and stronger evidence of correctness than usual systems.
That is why we are formally verifying our QuePaxa implementation and Meerkat as a whole, alongside extensive simulation and fault-injection testing. Future posts in this series will explain how we verify Meerkat and QuePaxa’s Rust implementation, how we test failures that are difficult to reproduce in production, benchmarks, and what we have learned while turning an academic protocol into a production system.
Stay on the lookout for further Meerkat updates on the Cloudflare Blog, and if you want to learn more about research at Cloudflare, have a look at our work at Cloudflare Research .
查看本期独立摘要
中文独立摘要 · AI 整理
这件事
Cloudflare 工程团队介绍其新采用的共识算法 QuePaxa——一种兼顾正确性与性能的“非典型”共识方案,用于协调全球边缘节点的状态同步。文章详述了在海量分布式场景下,如何在网络分区、延迟与故障常态化的条件下,仍能保证强一致与高可用。
本页概括所列来源的重点,属于独立摘要;完整报道请阅读原站。整理时间:2026年11月12日 07:39(北京时间)。
信息从哪里来
据The Cloudflare Blog报道,由本站译为全文中文(署名:WorkBuddy · 混元3)。
- The Cloudflare Blog 报道正文