▶ Cinematic fable · Watch on YouTube ▶ 影片版寓言 · 在 YouTube 观看

东海之外,有一片波诡云谲的水域,名唤沧澜群岛。

这片浩瀚汪洋中错落分布着九座险峰孤岛,每座岛上皆有一座石铸的古老议事亭,由一位白发苍苍、性情孤僻的隐老镇守。九岛之间没有长桥,没有悬索,唯有在怒涛骇浪中穿梭的快帆与风雨中容易迷航的信鸽。更要命的是,海雾常年弥漫,暗礁丛生,哪座岛突然被狂风暴雨阻绝十天半月、信使连人带船翻入海底,亦或是岛上长老闭关沉睡不理世事,都是寻常便饭。

可偏偏,沧澜群岛并非与世隔绝之所。每逢三年大汛,海潮倒灌,群岛必须推选出一位能够统御万舟的”镇海总督”,颁布一道不可更改的治水总令。

在早些年间,群岛推举总督的办法简单粗暴,唤作“临渊击鼓”。

沿海盘踞着数大望族令主——青木世家、赤羽兵寨、玄水督府。每当大汛将至,自负功高的令主们便急不可耐地遣出快船,向各岛分送加盖私印的黄绢诏书:”推举我族统领为总督,号令诸岛,速速盖印回复!”

这套法子很快酿成了惨痛的劫难。

大明嘉平年间的大汛前夕,青木世家向北面五岛送出快船,推举少主岳青;几乎同一瞬间,赤羽兵寨也向南面六岛发出了信鸽,推选老帅封烈。海面上狂风怒号,浪打千尺,两家船队在海雾中互不知晓。北面三座岛的长老接了青木绢书,依例盖了红印;南面四座岛的长老接了赤羽信鸽,同样盖印首肯;而中间的孤屿与雷鸣岛,更是先接了青木快船盖了印,半个时辰后又接了赤羽信鸽,稀里糊涂又盖了一次印!

待到汛期潮头如千军万马崩腾而至,岳青引着北线船队往东堵截,封烈领着南线水师往西分流,两支水师在惊涛骇浪中迎面相撞,旗号互斥,各执盖印信物怒斥对方谋逆篡权。混乱中巨舰相撞碎裂,大堤被狂澜冲垮,滔天巨浪吞没了万亩良田与千家渔舍。

事后九岛主事聚于古碑之前,痛定思痛:“各自遣使,必生两心;舟车阻隔,无从两全。若无一套天地神明亦不可篡改的立法之仪,沧澜九岛终将葬身鱼腹!”

危急之际,一位久居蓬莱、研习数术星象的老算师携一箱青铜令筹渡海而来。他在中军海坛前焚香祭告,为九岛立下了名震天下的“孤舟誓与二进神策”。

老算师立下的法则,字字如铁:

第一,令筹定尊卑,后至者为大(提案序号与准备阶段 Prepare / Promise)。 天下令主无论声威如何,若想立令,绝不可直接送出诏书,必须先铸造一批带有严密字号的青铜令筹。 令筹之上雕刻单调递增的刻度与令主独有的族徽(例如青木家第十七号、赤羽家第十九号)。凡号筹数值更高者,天地共尊,具有不可侵犯的优先权。 令主欲推总督,先遣快船向各岛送出“探筹令”,只问一句话:”我持第十九号令筹,敢问长老,可愿立誓——从今往后,绝不再听取任何小于十九号的令筹之言?”

镇守各岛的隐老,桌案前置一白玉册、一墨石盒。隐老见探筹令至,依律而行: 若来船的令筹小于案头白玉册上已记录的最大筹号,隐老当场挥袖闭门,视若无物; 若这枚令筹大于以往所见,隐老便当即提笔在白玉册上记下新筹号,并面海立誓:“九岛天鉴,老夫自此刻起,绝不再接纳任何筹号低于此号的使者!”

但更神妙的机锋还在后头。隐老立誓之后,必须打开身旁的墨石盒,翻看此生是否曾为哪位前人真正刻石盖印。若墨石盒内空空如也,便回书”未曾受命”;若盒内早有旧令(譬如在第七号筹时曾应允过岳青),隐老便必须如实抄录这道旧令的内容及其受命时的筹号,附在誓言之后,一同交还信使!

令主们大为不解:”我费尽周折派出快船,只为打听各岛愿否尊我,为何还要他们把陈年旧账翻出来给我看?”

老算师抚须冷笑,道出了全套法度最为精妙绝伦的命门:

第二,先古既立,虽贵必从(最高值采纳规则 Value Adoption Rule)。 一位令主只有收到过半数(九岛中至少五岛)长老的尊奉信誓,他才拥有立令的资格。 然而,在提起朱笔书写诏令的那一刻,令主必须将这五座岛回复的所有信筒统统倒在案头。 若五岛的信中全部回报”墨盒空空,未曾受命”,令主方可随心所愿,写下自己中意的总督名字; 但只要哪怕有一座岛的回信中附有旧令,令主便必须遵守神圣天则:顺从过往!令主必须找出附呈旧令中筹号最高的那一道,将自己的私心提议彻底撕碎,改而以自己十九号的令筹,代为推行那道旧令中的人物!

年轻的令主们当场炸开了锅:”荒唐!我耗费重金打造巨舟、力压群雄抢到了过半数信誓,凭什么要我去推举别人先前提出的总督?!”

老算师目光炯炯,声如洪钟: “因为在迷雾重重的沧澜群岛,你永远无法知晓——在你扬帆出海之前,那位先前的令主是否早已在一场暴风雨中,悄然收齐了另一批多数岛屿的首肯!如果天地已经认定了一位总督,你自命不凡的横加干涉,便是滔天洪灾的根源!尊古,是为了不翻旧案;顺从,是为了天地归一!”

第三,再涉洪涛,刻石成律(接受阶段 Accept / Accepted)。 令主选定令文(无论是领养的高位旧令,还是全新自选之令),便以十九号令筹携正式诏文,第二度遣快船破浪奔赴各岛,请长老“受命刻石”。 长老接旨,只需对照白玉册:只要在这一来一回的间隙里,没有更跋扈的二十三号探筹快船先行登岛夺走誓言,长老便将这道诏令恭恭敬敬刻入墨石碑,昭告全岛! 当过半数(五座以上)的长岛先后在石碑上凿下同一道诏令,海天共鸣,天地法则已成——这一届的镇海总督便在天道冥冥中正式诞生!

九岛工匠与船夫起初半信半疑,直到那年深秋,惊心动魄的一幕真实上演。

当时,赤羽兵寨的老帅封烈抢先一步,以第七号令筹赢得了西面三座岛与中区两座岛(共五岛)的誓言,并在风暴平息前,成功将”封烈为帅”的诏书送达三座岛刻了石。然而突遭飓风,封烈舟师折戟,余下两岛快船杳无音信,封烈本人更因风寒卧榻不起。

数日后,自恃强盛的青木少主岳青按捺不住,携第十一号令筹出海问誓。他绕过风暴,成功走访了东面四座岛与中区的一座孤屿,同样凑齐了五座岛的尊奉誓言。 然而,当岳青得意洋洋拆开回信时,冷汗瞬间浸透了衣背——那座中区的孤屿在誓言末尾,赫然写着:已于第七号令筹刻石,遵封烈老帅令!

按照先祖铁律,岳青咬碎钢牙,不得不弃掉自己的名字,将第十一号诏令的内容原原本本誊写为”奉封烈为帅”,再度遣使登岛刻石。

最终,当所有风暴散去,九岛通航。人们惊奇地发现:无论哪家令主扬帆、无论哪座岛在风雨中失联、无论使者在海上如何交错——九座岛屿的石碑上,最终赫然凿刻着完全一致、绝不相悖的同一个名字:封烈!

老算师站在悬崖边,眺望浩瀚沧海,悠然道: “何谓九岛长存之法?九取其五,五必相交。凡两度取多数,其间必有至少一岛,既承接了前人的墨石刻文,又将誓约托付给了后来的令主。 这一座小小的重叠孤岛,便是穿越风浪时空的绳缆。只要多数之规不灭,天地之间,便再无 split 之裂、无二主之乱!”

—此时你大约已经认出:这套在不可靠异步网络、节点随时崩溃失联、多并发提案者并存的极端环境下,仅凭多数派相交原理便能牢不可破达成唯一决议的千古神策,正是图灵奖得主 Leslie Lamport 于 1998 年正式发表的分布式系统无冕之王——Paxos 共识协议(Paxos Consensus Protocol / Single-Decree Synod)。它奠定了后世所有强一致性分布式系统、共识引擎与分布式数据库的灵魂。

这是什么

Paxos 是由计算机科学家 Leslie Lamport 在其划时代的论文《The Part-Time Parliament》(1998)与《Paxos Made Simple》(2001)中提出的分布式共识算法。它解决了在异步网络环境(存在任意网络延迟、乱序、丢包、重复)以及节点可能发生故障(Crash-Stop / Crash-Recovery,但不含恶意篡改伪造的拜占庭错误)的前提下,一组分布式节点如何就某一个决议(Single Value)安全、确定地达成一致。

在 Paxos 体系中,节点划分为三种逻辑角色(现实系统中同一物理节点通常身兼数职):

  • 提案者(Proposer):发起倡议、争取决议的节点;
  • 接受者(Acceptor):拥有投票权、维护状态机核心约束的法定成员,决议必须由 Acceptor 的多数派法定人数(Quorum)共同决定;
  • 学习者(Learner):不参与投票,仅在多数派达成共识后获知最终结果并执行。

为了在无中心主节点、随时可能爆发并发提案的无序环境中保证绝对的安全性(Safety:一致性),Paxos 采用了严丝合缝的两阶段交互协议:

第一阶段:准备与承诺(Phase 1: Prepare / Promise)

  1. Phase 1a - Prepare:Proposer 选择一个全局唯一且单调递增的提案编号 $n$(通常由本地自增计数器拼接节点唯一 ID 构成,保证节点间永不冲突),向 Acceptor 集合中的一个多数派发送 Prepare(n) 请求。
  2. Phase 1b - Promise:Acceptor 收到 Prepare(n) 时,比对自身曾经承诺过的最大提案编号 $\max_promised$:
    • 若 $n \le \max_promised$,Acceptor 拒绝响应或回复拒绝,坚守既往承诺;
    • 若 $n > \max_promised$,Acceptor 更新本地 $\max_promised = n$,向 Proposer 回复 承诺(Promise):立誓未来绝不再接受任何提案编号小于 $n$ 的提案!
    • 核心安全机制(Piggybacked Accepted Value):若该 Acceptor 此前已经接受过(Accepted)某个提案(设其编号为 $k$,值为 $v$),它在返回 Promise 的同时,必须将自身接受过的最高提案编号及其对应值 $(k, v)$ 连带返回给 Proposer。

第二阶段:接受与决议(Phase 2: Accept / Accepted)

  1. Phase 2a - Accept:Proposer 收集到一个多数派(Majority Quorum)的 Promise 响应后,开始敲定待提交的值:
    • 最高值强制继承规则(Value Adoption Rule):Proposer 检查所有 Promise 回复。若所有回复中此前均未接受过任何值,Proposer 即可自由提议自己的原始值(Free Value);但凡哪怕有一个 Acceptor 返回了此前接受过的历史值,Proposer 必须无条件放弃自己的初衷,从所有返回的值中,强制挑选提案编号最大的那个值 $v$,作为本次提案的值!
    • Proposer 将选定的值 $v$ 与提案号 $n$ 封装为 Accept(n, v) 请求,广播发送给多数派 Acceptors。
  2. Phase 2b - Accepted:Acceptor 收到 Accept(n, v) 时,只要在该请求到达之前,自身没有向其他更高编号的 Prepare(n' > n) 做出过排他性承诺,Acceptor 就会正式批准该提案,持久化记录 $(n, v)$,并向 Proposer 及 Learners 返回 Accepted(n, v)。
  3. 决议达成(Chosen / Committed):一旦某个提案 $(n, v)$ 被一个多数派的 Acceptors 接受,该值就被正式确立(Chosen)。此时任何节点皆不可更改,Learners 即可安全地将该值应用于状态机。

为什么 Paxos 绝不会产生冲突?(数学证明的直觉)

其数学基石在于鸽巢原理与多数派交集性质(Quorum Intersection Property): 设系统共有 $2F+1$ 个 Acceptor,任意多数派 Quorum 均至少包含 $F+1$ 个节点。 因此,任意两个多数派 $Q_1$ 与 $Q_2$ 必定至少存在一个重叠节点:$Q_1 \cap Q_2 \neq \emptyset$。

假设提案 $(k, V)$ 已在提案编号 $k$ 下被多数派 $Q_1$ 成功接受(决议达成)。未来任何其他 Proposer 试图以更高的编号 $m > k$ 提交新值,它在 Phase 1 必须先获得一个多数派 $Q_2$ 的承诺。 因为 $Q_1 \cap Q_2$ 必定至少包含一个公共节点 $A$,而节点 $A$ 已经接受了 $(k, V)$,所以 $A$ 在给新 Proposer 的 Promise 回复中,必然会交出 $(k, V)$。根据最高值继承规则,新 Proposer 必定会被迫将自身的值替换为 $V$! 这在数学上保证了:一旦某个值被多数派选定,后续任何编号的提案即使胜出,其携带的值也必定是同一个值 $V$,决议永不漂移!

为什么重要

Paxos 被公认为现代分布式系统的基石与”圣杯”:

  1. 分布式共识理论的奠基石:在 Paxos 诞生前,分布式系统普遍依赖脆弱的单主架构或极易引发脑裂的仲裁机制。Leslie Lamport 证明了在异步、无界延迟且不可靠的网络中,无需依赖物理时钟或静态仲裁者,仅凭重叠多数派与单调提案号即可构建严密的强一致性系统。
  2. 现代顶级分布式基础设施的核心骨架:
    • Google Chubby & Spanner:Google 的全球分布式锁服务 Chubby 与分布式全球数据库 Spanner 的核心副本同步协议就是 Paxos;
    • Apache ZooKeeper (ZAB) 与 Raft:业界熟知的 ZAB 协议与 Raft 协议,本质上皆是 Paxos 思想在连续状态机复制(Multi-Paxos)场景下的工程具象化与易理解化衍生。
  3. 看清理论边界(FLM 活锁与工业演进):Basic Paxos 保证了绝对的安全性(Safety),但在极端并发下,两个 Proposer 可能交替以更高的提案号覆盖对方的承诺(Phase 1 互锁,导致 Phase 2 永远无法被多数派接受),产生活锁(Livelock / Dueling Proposers)。为了解决活性(Liveness)问题,工业实践衍生出了 Multi-Paxos(通过租约选拔唯一的稳定 Leader,将两阶段缩减为一阶段极速提交通道),这直接启发了当代云原生高可用架构的设计哲学。

隐喻对应表

  • 浩瀚汪洋中散布九座孤岛与古老石亭 → 分布式共识集群中的法定投票节点(Acceptors)
  • 随时迷航的信鸽、狂风巨浪倾覆快船与孤岛闭门不应 → 异步网络中的丢包、延迟、乱序与节点崩溃停机(Unreliable Asynchronous Network & Crash-Stop Failures)
  • 沿海数大望族令主竞相遣使推举各自主张 → 并发向集群发起写入请求的提案者(Competing Proposers)
  • 盲目击鼓遣使导致岳青与封烈水师迎面相撞、大堤崩塌 → 缺乏并发共识控制导致的数据分歧与脑裂(Split-Brain & Inconsistency)
  • 带有递增刻度与族徽的青铜令筹 → 保证全局唯一且单调递增的提案编号(Globally Unique, Monotonically Increasing Proposal Number $n$)
  • 第一度派船问誓(探筹令)只问愿否尊奉此号 → Paxos 第一阶段第一步的准备请求(Phase 1a Prepare Request)
  • 各岛白玉册记下大号令筹并立誓不纳小号 → Acceptor 更新本地最大承诺号并立下排他承诺(Phase 1b Promise & Updating $\max_promised$)
  • 各岛随誓言一同交还墨石盒内记录的最高旧令 → Acceptor 随 Promise 报文捎带返回此前已接受的最高提案 $(k, v)$(Piggybacked Accepted Value)
  • 必须集齐过半数(五座以上)长老的信誓方可立令 → 提案者必须收集到多数派承诺(Majority Quorum of Promises)
  • 见旧令必须舍弃私心、强制领养最高旧令作为自身文书 → Paxos 核心约束:最高值继承与强制采纳(Value Adoption Rule)
  • 墨盒皆空时方可自书喜好之名 → 当多数派皆无历史接受值时 Proposer 才能提议新值(Proposing Free Value)
  • 第二度派船携令筹与文书请各岛受命刻石 → Paxos 第二阶段第一步的接受请求(Phase 2a Accept Request)
  • 长老验明未违背更高誓言后在墨石碑上正式凿下印迹 → Acceptor 正式接受提案并持久化状态(Phase 2b Accepted)
  • 至少五岛刻石大功告成、总督不可更改诞生 → 提案被多数派接受并成为不可逆的最终决议(Chosen / Committed Value)
  • 岳青虽领高号但因与孤屿相交不得不改推封烈 → 多数派必有交集($Q_1 \cap Q_2 \neq \emptyset$)确保已达成共识的值永不被颠覆(Quorum Intersection Principle)

Beyond the Eastern Sea lies a treacherous, mist-cloaked expanse of water known as the Canglan Archipelago.

Scattered across these tempestuous swells stand nine craggy, isolated islands. At the highest crest of each island perches an ancient stone pavilion, guarded by a white-haired, reclusive hermit elder. Between these nine outposts there are no bridges, no suspension cables—only swift cutters braving monstrous breakers and carrier pigeons tossed mercilessly by gale-force winds. Worse still, dense fog blankets the sea year-round, and jagged reefs lurk beneath the surface. For an island to be cut off by howling squalls for weeks on end, for a courier boat to be swallowed whole by the abyssal depths, or for an elder to enter deep meditation and ignore the outside world was entirely ordinary.

Yet the Canglan Archipelago was no land of hermetic contemplation. Every three years, the great tidal bore swelled, threatening to submerge the lowlands. The islands were compelled by survival to elect a single Grand Admiral capable of commanding ten thousand vessels, and to promulgate a unified, immutable flood-control decree.

In earlier eras, the archipelago settled upon an admiral through a crude, belligerent custom known as “Drumming at the Precipice.”

Along the mainland coast resided several powerful clan lords—the Azure Banner Clan, the Vermillion Fortress, and the Black Water Commandery. Whenever the flood season approached, proud and ambitious lords hurriedly dispatched couriers across the waves, delivering yellow-silk proclamations stamped with their private seals: “Proclaim our clan leader Grand Admiral to govern all waters! Affix your island’s counter-seal at once!”

This haphazard practice soon led to catastrophic tragedy.

On the eve of the Great Flood of the Jiaping Era, the Azure Clan dispatched swift cutters to the five northern islands, proclaiming their young master Yue Qing. At that precise hour, the Vermillion Fortress sent carrier pigeons to the six southern islands, proclaiming their veteran general Feng Lie. A ferocious storm howled over the sea, masking each armada from the other. The three northernmost island elders received Yue Qing’s silk writs and obediently stamped them with vermillion wax; the four southern elders received Feng Lie’s pigeons and affixed identical endorsements. Meanwhile, the central isles—the Solitary Shoal and Thunder Rock—received Yue Qing’s cutters first and stamped their seals, only to receive Feng Lie’s pigeons an hour later, bewilderedly stamping their seals a second time!

When the monstrous tidal surge crashed forward like a million stampeding warhorses, Yue Qing steered the northern fleets eastward to build diversion dams, while Feng Lie commanded the southern armada westward to breach spillways. The two fleets collided head-on amidst towering waves, flags clashing in blind fury, each brandishing sealed imperial writs and shouting that the other were mutinous traitors. In the chaos, war galleys splintered against one another, the seawall ruptured beneath the unmanaged deluge, and a terrifying wall of water engulfed ten thousand fertile acres and a thousand coastal hamlets.

In the aftermath, the grieving masters of the nine islands convened before the ancient shore stele: “Dispatched independently, multiple masters breed disaster. Parted by vast waters, unity cannot be sustained by wishful thinking. Without an inviolable rite of consensus that even heaven and earth cannot corrupt, the nine islands shall forever perish in the belly of the deep!”

In this hour of existential dread, an ancient mathematician from Mount Penglai crossed the tempestuous strait, bearing an ironwood chest filled with cast-bronze tallies. Igniting incense before the grand altar of the sea, he instituted the legendary Covenant of the Solitary Vessel and the Twofold Rite for the nine islands.

The master’s statutes were inscribed as though etched in steel:

First, Precedence Governs All; the Highest Ballot Holds Sway (Proposal Numbers & Phase 1: Prepare / Promise). No lord, regardless of martial might, was permitted to dispatch a proclamation outright. He was required first to cast a set of bronze tallies inscribed with meticulous numerical ranks. Upon each bronze tally was carved a strictly monotonic ordinal number paired with the lord’s unique clan insignia (for example, Azure Clan #17, or Vermillion Fortress #19). Whosoever held a tally with a higher numeric rank enjoyed inviolable priority under the laws of heaven. A lord aspiring to institute an admiral had first to dispatch swift cutters across the sea carrying an Inquiry Tally, asking but one single question: “I bear Bronze Tally #19. I ask you, Elder: do you swear never again to entertain any messenger whose tally bears a number lesser than 19?”

Upon each island, the hermit elder sat before a table bearing a white jade ledger and an inkstone vault. Upon the arrival of an Inquiry Tally, the elder obeyed an unyielding ritual: If the newcomer’s tally was smaller than or equal to the highest tally already inscribed upon his white jade ledger, the elder swung the oak doors shut and ignored him entirely; If the tally surpassed all numbers previously recorded, the elder dipped his brush, inscribed the new number into the white jade ledger, and bowed toward the sea: “Witnessed by the Nine Isles, from this breath forth, I swear never to accept any envoy bearing a tally lesser than this number!”

Yet a far more profound mechanism lay embedded within the vow. Having sworn the oath, the elder was required to open his inkstone vault and inspect whether he had ever counter-sealed and accepted an actual decree in the past. If the vault was barren, he replied: “Never accepted.” But if the vault already harbored an accepted decree (for example, if at Tally #7 he had once agreed to Yue Qing), the elder was bound by sacred law to transcribe that previous decree along with the tally number under which it had been accepted, and return that historical record piggybacked upon his sworn oath to the envoy!

The ambitious lords sputtered in bewilderment: “I spend fortunes braving the waves merely to ask if the elders will honor my rank! Why in heaven’s name must they dig up ancestral decrees and fling them back in my face?!”

The old master stroked his beard and smiled coldly, unveiling the immortal axis of the entire architecture:

Second, Yield to Precedent: The Law of Value Adoption. A lord gained the right to draft a decree only after collecting sworn promises from a strict majority (at least five of the nine islands). Yet, the instant he dipped his vermillion brush to inscribe the admiral’s name upon the scroll, he was bound by law to empty all returned message tubes onto his table. If all five islands responded “Inkstone vault barren; no decree ever accepted,” the lord was entirely free to write down his own favored candidate; However, if even a single island reported an accepted decree from days gone by, the lord was bound by divine commandment: Yield to the past! The lord had to identify the decree associated with the highest tally number among all returned reports, tear up his own personal preference, and use his new Tally #19 to champion that adopted historical decree instead!

The young lords erupted in fury: “Absurd! I spent a kingdom’s treasury building warships and securing a majority of oaths—by what logic must I champion another man’s general?!”

The old master’s eyes flashed like summer lightning: “Because across the fog-shrouded expanses of Canglan, you can never know whether, before your ships ever hoisted their sails, that earlier lord had already collected endorsements from an overlapping majority in the dark! If the universe has already chosen an admiral, your arrogant divergence is the very deluge that drowns the world! Yielding to the past prevents the overturning of history; submission brings absolute harmony!”

Third, Brave the Breakers Again: Inscription in Stone (Phase 2: Accept / Accepted). Once the decree was formulated—whether adopted from a predecessor or minted freshly from an empty slate—the lord attached it to his Tally #19 and dispatched swift cutters a second time, asking the elders to “Inscribe and Commit.” Upon receiving the dispatch, the elder consulted his white jade ledger: so long as no more ambitious lord carrying Tally #23 had landed during the courier’s round-trip journey to overwrite his promise, the elder reverently carved the proclamation into the island’s eternal stone stele! The moment a strict majority (five or more islands) had carved the identical decree into their stone steles, heaven and earth resonated—the Grand Admiral was irrevocably and permanently chosen!

The mariners of the nine islands initially harbored doubts, until a harrowing clash unfolded late that autumn.

General Feng Lie of the Vermillion Fortress moved first. Using Tally #7, he secured oaths from three western islands and two central shoals (five in total). Before the tempests peaked, his second-phase boats managed to reach three of those islands, carving “Feng Lie is Grand Admiral” into their stone steles. Suddenly, a monstrous hurricane crippled his fleet; couriers headed for the remaining two islands were swallowed by the sea, and Feng Lie collapsed with fever in his stronghold.

Days later, believing his rival incapacitated, young master Yue Qing of the Azure Clan set sail with Tally #11. Evading the gale, he visited the four eastern islands and one central shoal, successfully securing oaths from a five-island majority. Yet, when Yue Qing eagerly unrolled the five returned message tubes, cold sweat drenched his silk robe—the central shoal’s vow concluded with the fateful report: Already carved into stone under Tally #7: Feng Lie is Grand Admiral!

Bound by the ancient covenant, Yue Qing ground his teeth until they bled. He was forced to strike out his own name and transcribe his Tally #11 proclamation as “Feng Lie is Grand Admiral,” dispatching couriers to the islands for stone carving.

When the skies finally cleared and navigation resumed, the islanders discovered an astounding miracle: regardless of which lord set sail, regardless of which islands had been cut off by tempests, regardless of how couriers crossed in the night—upon every island’s stone stele was carved the exact same, undisputed name: Feng Lie!

Standing at the edge of the sea cliff, the old mathematician looked across the sparkling azure expanse: “What is the secret of the nine islands? Take five out of nine, and any two fives must overlap. When you draw two majorities, there must always exist at least one island that both carved the predecessor’s stone and surrendered its oath to the successor. That single overlapping isle is the immortal tether bridging past and future across stormy seas. So long as the rule of majorities stands, never again shall there be the fissure of split-brain, nor the chaos of two masters!”

—By now you have likely recognized it: this immortal mechanism that guarantees a single, undisputed decision across unreliable networks, node crashes, and concurrent proposals through the simple magic of quorum intersection is none other than the crowned monarch of distributed systems: the Paxos Consensus Protocol (Single-Decree Synod), formulated by Turing Award laureate Leslie Lamport in his seminal 1998 paper. It forms the intellectual bedrock of every strongly consistent distributed system, consensus engine, and globally distributed database in modern computing.

What it is

Paxos is a foundational distributed consensus algorithm introduced by Leslie Lamport in his landmark papers “The Part-Time Parliament” (1998) and “Paxos Made Simple” (2001). It solves the problem of how a cluster of distributed nodes can safely and definitively agree on a single value in an asynchronous network environment (subject to arbitrary message delays, reordering, drops, and duplicates) where nodes may fail by crashing (Crash-Stop / Crash-Recovery, excluding malicious Byzantine behavior).

In the classic Paxos model, nodes assume three logical roles (frequently co-located on the same physical host):

  • Proposers: Nodes that advocate for client requests and attempt to guide the cluster toward choosing a specific value;
  • Acceptors: The consensus council maintaining the state machine invariants. A value can only be chosen with the agreement of a majority quorum of Acceptors;
  • Learners: Non-voting participants that discover and execute the final chosen value once consensus has been achieved.

To guarantee absolute Safety (Consistency) in a leaderless, asynchronous world where multiple proposers may initiate actions concurrently, Paxos enforces a rigorous two-phase protocol:

Phase 1: Prepare and Promise

  1. Phase 1a - Prepare: A Proposer selects a globally unique, monotonically increasing proposal number $n$ (typically formed by combining a local monotonic counter with the node’s unique ID to break ties). It broadcasts a Prepare(n) request to a majority quorum of Acceptors.
  2. Phase 1b - Promise: Upon receiving Prepare(n), an Acceptor evaluates $n$ against the highest proposal number it has ever promised to honor ($\max_promised$):
    • If $n \le \max_promised$, the Acceptor ignores or rejects the request, preserving its earlier commitments;
    • If $n > \max_promised$, the Acceptor updates $\max_promised = n$ and returns a Promise: it binds itself never to accept any proposal numbered less than $n$ in the future!
    • Crucial Invariant (Piggybacked Accepted Value): If this Acceptor has previously accepted any proposal $(k, v)$ where $k < n$, it must return the tuple $(k, v)$ containing the highest-numbered proposal it has ever accepted along with its promise.

Phase 2: Accept and Accepted

  1. Phase 2a - Accept: Once the Proposer receives promises from a majority quorum of Acceptors, it determines the payload $v$:
    • Value Adoption Rule: The Proposer inspects all received promises. If none of the Acceptors in the quorum have previously accepted a value, the Proposer is free to propose its own original payload ($v = v_{initial}$); however, if any Acceptor reported an already-accepted value, the Proposer MUST discard its own proposal and adopt the value $v$ associated with the highest proposal number $k$ reported among the promises!
    • The Proposer then broadcasts Accept(n, v) containing its ballot number $n$ and the chosen payload $v$ to a majority quorum of Acceptors.
  2. Phase 2b - Accepted: When an Acceptor receives Accept(n, v), it accepts the proposal and persists $(n, v)$ provided it has not in the interim made a conflicting promise to a higher ballot $n’ > n$. It replies with an Accepted(n, v) message to the Proposer and Learners.
  3. Commitment (Value Chosen): A value $v$ is officially chosen (committed) the instant an Accept(n, v) message is accepted by a majority quorum of Acceptors. Once chosen, it is mathematically immutable, and Learners may safely apply it to their local state machines.

Why Paxos Never Disagrees: Intuition of Quorum Intersection

The safety of Paxos rests upon the Pigeonhole Principle and the Quorum Intersection Property ($Q_1 \cap Q_2 \neq \emptyset$): In a cluster of $2F+1$ Acceptors, every majority quorum contains at least $F+1$ nodes. Therefore, any two majorities must share at least one node in common.

Suppose proposal $(k, V)$ was chosen because it was accepted by a majority quorum $Q_1$. If another Proposer later attempts to propose a different value under a higher number $m > k$, it must first gather promises from a majority quorum $Q_2$ in Phase 1. Because $Q_1 \cap Q_2$ contains at least one common Acceptor $A$, and $A$ already accepted $(k, V)$, $A$ will inescapably return $(k, V)$ to the new Proposer during Phase 1b. By the Value Adoption Rule, the new Proposer is forced to overwrite its own payload with $V$. Thus, once a value has been chosen by any quorum, all subsequent proposals that could ever succeed are guaranteed to carry the exact same value $V$. Inconsistency is mathematically impossible.

Why it matters

Paxos is universally recognized as the foundational cornerstone of distributed systems engineering:

  1. The Genesis of Distributed Consensus: Before Paxos, distributed architecture relied on brittle single-master models, fragile heartbeat timeouts, or ad-hoc voting schemes that frequently succumbed to split-brain state corruption. Lamport proved that provably correct, fault-tolerant consensus is achievable across asynchronous networks without shared memory or synchronized physical clocks.
  2. The Backbone of Production Infrastructure:
    • Google Chubby & Google Spanner: Google’s foundational lock service Chubby and globally distributed multi-region database Spanner replicate their transactional state using Paxos;
    • Apache ZooKeeper (ZAB) & Raft: Modern consensus protocols like Raft and ZooKeeper’s ZAB are direct intellectual descendants of Paxos, designed to translate the single-decree synod into continuous state-machine log replication (Multi-Paxos) with more intuitive leader semantics.
  3. Navigating Theoretical Boundaries (Livelock vs. Multi-Paxos): Basic Paxos guarantees unconditional Safety, but under high concurrency, two competing Proposers can continually outbid each other’s ballot numbers in Phase 1 before either can finish Phase 2, resulting in a livelock (dueling proposers). Recognizing this limitation inspired Multi-Paxos—which elects a distinguished stable leader to bypass Phase 1 for steady-state writes—laying the foundation for high-throughput, low-latency cloud infrastructure.

Metaphor mapping

  • Nine isolated islands with ancient stone pavilions → Voting member nodes in the consensus cluster (Acceptors)
  • Pigeons tossed by gales, shipwrecks, and closed stone doors → Packet loss, arbitrary latency, reordering, and fail-stop node crashes (Unreliable Asynchronous Network & Crash-Stop Failures)
  • Coastal clan lords competing to dispatch couriers with private seals → Concurrent nodes initiating conflicting write requests (Competing Proposers)
  • Crudely drumming at the precipice causing fleet collisions and seawall collapse → Uncoordinated concurrency causing split-brain and state divergence (Split-Brain & Inconsistency)
  • Bronze tallies with monotonic numbers and clan insignias → Globally unique, monotonically increasing proposal numbers (Proposal Number $n$)
  • First-round cutter asking if elders will honor the tally rank → Paxos Phase 1a prepare request (Phase 1a Prepare Request)
  • Elders recording higher numbers in jade ledgers and swearing exclusion oaths → Acceptor updating $\max_promised$ and binding itself against lesser ballots (Phase 1b Promise & Updating $\max_promised$)
  • Elders returning historical accepted decrees from inkstone vaults → Acceptor piggybacking its highest accepted proposal $(k, v)$ on the promise (Piggybacked Accepted Value)
  • Requiring promises from at least five of nine islands → Gathering promises from a majority quorum of Acceptors (Majority Quorum of Promises)
  • Obligation to tear up one’s own decree and adopt the highest historical decree → Fundamental Paxos rule: mandatory adoption of highest accepted value (Value Adoption Rule)
  • Drafting a free decree only when all five inkstone vaults are empty → Proposing an original value only when no accepted values exist (Proposing Free Value)
  • Second-round cutter requesting elders to carve the decree into stone → Paxos Phase 2a accept request (Phase 2a Accept Request)
  • Elders verifying no higher tally arrived and carving the decree into steles → Acceptors formally accepting and persisting the proposal (Phase 2b Accepted)
  • At least five islands carving the stone stele to crown the admiral → Value chosen and committed by a majority quorum (Chosen / Committed Value)
  • Yue Qing compelled to adopt Feng Lie’s name due to the overlapping central shoal → Quorum intersection ($Q_1 \cap Q_2 \neq \emptyset$) guaranteeing committed values are never overturned (Quorum Intersection Principle)
Daily Fables每日寓言 2026-10-01