Paxos&ZAP

paxos

是什么

Paxos is a family of protocols for solving consensus in a network of unreliable processors (that is, processors that may fail). Consensus is the process of agreeing on one result among a group of participants. This problem becomes difficult when the participants or their communication medium may experience failures.

是个协议,解决在不可靠节点中达到共识的问题。具体的讲,可以确定一个不可变变量的取值。对比2PC和3PC,2PC主要问题是同步阻塞、单点、保守,3PC通过都一个preCommit,可以实现超时提交/abort,减少数据不一致的情况。但仍然参在脑裂问题。而paxos通过更多的accptors能解决脑裂问题。

应用

在分布式存储系统中,多个副本的操作序列op1、op2…是相同的,不变的,可以用paxos来依次确定不可变的值opi,让各个副本执行opi,然后达成一致。

解决一致性问题

确定一个不可变变量的取值 系统满足容错性:

方案一:单个acceptor,使用类似互斥锁管理并发proposer

方案二:引入抢占式访问权,accpetor可以让某个proposer的访问权实现,并不在接收他的访问

两个原则

PS:后者认同前置,首先是没有处理拜占庭将军问题,一般场景中,为了确定opi,这value会不同么?应该是一个确定的值。要不也不会有后者认同前者,这样的规则,新epoch的value生效的唯一场景就是前面的epoch没有形成确定性取值(一个也没有写成功)。

方案三:paxos,引入多个accpetor

又加了个原则:少数服从多数

两阶段:

核心思想

问题

ZAP

This documents the Zab, an atomic broadcast protocol used by ZooKeeper to propagate state changes.

Zab at a high level is a leader based protocol similar to Paxos. Some of the aspects that distinguish Zab from Paxos is that Zab recovers histories rather than single instances of protocols; Zab has prefix ordering properties to allow primary/backup implementations to have multiple outstanding operations outstanding at a time; and Zab does special processing at leadership change to guarantee unique sequence numbers for values proposed by a leader.

Zab与pasox不同:

两种基本模式

崩溃恢复

选举

Table of Contents