Paxos algorithm

来自WHY42

Paxos解决的是什么问题

state machine replication

如上所示的系统中,如果客户端要执行某个命令,那么将遵循如下的步骤:

  1. 发送命令到其中某一个server
  2. server首先将命令记录到log中,然后将命令发送到其他的服务中;其他server同样将其记录到log中
  3. 当命令完整的记录到各个server之后,就可以传到state machine去执行了,并将结果返回给客户端

其中,consensus module用来保证log的复制是正确的,也就是paxos要解决的问题。

Paxos算法

The Paxos algorithm, when presented in plain English, is very simple.

推导过程

Safety requirements

  • Only a value that has been proposed may be chosen,
  • Only a single value is chosen, and
  • A process never learns that a value has been chosen unless it actually has been.