`
foreversunyao
  • 浏览: 212299 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Paxos algorithm

阅读更多

Paxos is a family of protocols for solving consensus in a network of unreliable processors. 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.[ 1]

Consensus protocols are the basis for the state machine approach to distributed computing, as suggested by Leslie Lamport [ 2] and surveyed by Fred Schneider.[ 1]

The state machine approach is a technique for converting an algorithm into a fault-tolerant, distributed implementation. Ad-hoc techniques may leave important cases of failures unresolved. The principled approach proposed by Lamport et al. ensures all cases are handled safely.

 

Roles

Paxos describes the actions of the processes by their roles in the protocol: client, acceptor, proposer, learner, and leader. In typical implementations, a single processor may play one or more roles at the same time. This does not affect the correctness of the protocol—it is usual to coalesce roles to improve the latency and/or number of messages in the protocol.

Client
The Client issues a request to the distributed system, and waits for a response . For instance, a write request on a file in a distributed file server.
Acceptor
The Acceptors act as the fault-tolerant "memory" of the protocol. Acceptors are collected into groups called Quorums. Any message sent to an Acceptor must be sent to a Quorum of Acceptors, any message received from an Acceptor is ignored unless a copy is received from each Acceptor in a Quorum.
Proposer
A Proposer advocates a client request, attempting to convince the Acceptors to agree on it, and acting as a coordinator to move the protocol forward when conflicts occur.
Learner
Learners act as the replication factor for the protocol. Once a Client request has been agreed on by the Acceptors, the Learner may take action (ie: execute the request and send a response to the client). To improve availability of processing, additional Learners can be added.
Leader
Paxos requires a distinguished Proposer (called the leader) to make progress. Many processes may believe they are leaders, but the protocol only guarantees progress if one of them is eventually chosen. If two processes believe they are leaders, it is possible to stall the protocol by continuously proposing conflicting updates. The safety properties are preserved regardless.



Message flow: Basic Paxos

(one instance, one successful round)

 Client   Proposer      Acceptor     Learner
   |         |          |  |  |       |  |
   X-------->|          |  |  |       |  |  Request
   |         X--------->|->|->|       |  |  Prepare(N)
   |         |<---------X--X--X       |  |  Promise(N,{Va,Vb,Vc})
   |         X--------->|->|->|       |  |  Accept!(N,Vn)
   |         |<---------X--X--X------>|->|  Accepted(N,Vn)
   |<---------------------------------X--X  Response
   |         |          |  |  |       |  | 


实际上对于一般的开发人员,我们并不需要了解Paxos所有细节及如何实现,只需要知道Paxos是一个分布式选举算法就够了。本文主要介绍一下 Paxos常用的应用场合,或许有一天当你的系统增大到一定规模,你知道有这样一个技术,可以帮助你正确及优雅的解决技术架构上一些难题。

1. database replication, log replication等, 如bdb的数据复制就是使用paxos兼容的算法。Paxos最大的用途就是保持多个节点数据的一致性。

2. naming service, 如大型系统内部通常存在多个接口服务相互调用。
1) 通常的实现是将服务的ip/hostname写死在配置中,当service发生故障时候,通过手工更改配置文件或者修改DNS指向的方法来解决。缺点是可维护性差,内部的单元越多,故障率越大。
2) LVS双机冗余的方式,缺点是所有单元需要双倍的资源投入。
通过Paxos算法来管理所有的naming服务,则可保证high available分配可用的service给client。象ZooKeeper还提供watch功能,即watch的对象发生了改变会自动发 notification, 这样所有的client就可以使用一致的,高可用的接口。

3.config配置管理
1) 通常手工修改配置文件的方法,这样容易出错,也需要人工干预才能生效,所以节点的状态无法同时达到一致。
2) 大规模的应用都会实现自己的配置服务,比如用http web服务来实现配置中心化。它的缺点是更新后所有client无法立即得知,各节点加载的顺序无法保证,造成系统中的配置不是同一状态。

4.membership用户角色/access control list, 比如在权限设置中,用户一旦设置某项权限比如由管理员变成普通身份,这时应在所有的服务器上所有远程CDN立即生效,否则就会导致不能接受的后果。

5. 号码分配。通常简单的解决方法是用数据库自增ID, 这导致数据库切分困难,或程序生成GUID, 这通常导致ID过长。更优雅的做法是利用paxos算法在多台replicas之间选择一个作为master, 通过master来分配号码。当master发生故障时,再用paxos选择另外一个master。

这里列举了一些常见的Paxos应用场合,对于类似上述的场合,如果用其它解决方案,一方面不能提供自动的高可用性方案,同时也远远没有Paxos实现简单及优雅。

Yahoo!开源的ZooKeeper [5]是一个开源的类Paxos实现。它的编程接口看起来很像一个可提供强一致性保证的分布式小文件系统。对上面所有的场合都可以适用。但可惜的 是,ZooKeeper并不是遵循Paxos协议,而是基于自身设计并优化的一个2 phase commit的协议,因此它的理论[6]并未经过完全证明。但由于ZooKeeper在Yahoo!内部已经成功应用在HBase, Yahoo! Message Broker, Fetch Service of Yahoo! crawler等系统上,因此完全可以放心采用。

分享到:
评论

相关推荐

    Revisiting the Paxos algorithm

    ### 重新审视Paxos算法 #### 摘要与背景 本文重新审视了Paxos算法,并基于此算法提出了一种新的I/O自动机模型——时钟通用定时自动机(Clock General Timed Automaton,简称Clock GTA)模型。该模型在 Lynch 和 ...

    分布式一致性一般解决方法.pdf

    The Paxos algorithm is synonymous with distributed consensus, yet it performs poorly in practice and is famously difficult to understand. In this paper, we re-examine the foundations of distributed ...

    基于paxos算法的Hadoop分布式文件系统高可用性探究.pdf

    文章最后提到的关键字,包括云计算(Cloud computing)、单点故障(Single point of failure)、Paxos算法(Paxos algorithm)、HDFS和可用性(Availability),都是本研究的重要组成部分。云计算的概念表明了该研究...

    开源项目-ailidani-paxi.zip

    开源项目-ailidani-paxi.zip,WPaxos: multiple leaders paxos algorithm with deal with WAN latency barriers written in Go

    Paxos-Algorithm-Game:基本Paxos算法的应用

    Paxos算法游戏 该项目的目的是使用Baisc Paxos Algoritm设计一个简单的分布式系统。 这里的项目是一个猜数字游戏,可以让三个用户一起玩。 文件夹Dueling_Paxos中的代码显示了基本paxos中的决斗问题。 先决条件 Java...

    《Paxos Made Simple》分布式一致性协议Paxos论文翻译

    #### The Consensus Algorithm ##### 2.1 The Problem 本小节阐述了一致性算法的目标和需求。在分布式环境中,一致性算法需要确保所有被提议的值中仅有一个值被选中。如果没有任何值被提议,则不应有任何值被选中;...

    DB - Unbounded Pipelining in Dynamically Paxos Clusters.pdf

    When equipped with a consensus algorithm a distributed system can act as a replicated state machine (RSM), duplicating its state across a cluster of redundant components to avoid the failure of any ...

    Algorithm-snek.zip

    常见的方法有基于时间戳的同步机制,或者利用分布式系统中的共识算法,如Paxos或Raft。 通过对"Algorithm-snek"游戏的分析,我们可以看到算法无处不在,无论是基础逻辑还是高级功能,都离不开算法的支持。掌握并...

    awesome-consensus:Paxos和朋友的很棒列表

    "awesome-consensus:Paxos和朋友的很棒列表" 提供了一个详尽的资源集合,涵盖了Paxos算法及其相关的共识算法,如Raft。这些算法在分布式数据库、云存储、物联网等多个领域都有着广泛的应用。 首先,我们来深入理解...

    32分布式数据调度相关论文1

    Raft算法旨在提供更简单的理解和实现,其原始论文是“In Search of an Understandable Consensus Algorithm”。与Paxos类似,Raft也解决了分布式一致性问题,但在实践中更容易理解和实现。 ZooKeeper是另一个提及的...

    分布式数据调度相关论文.pdf

    Raft算法的原始论文《In search of an Understandable Consensus Algorithm》提供了易于理解的一致性算法的阐述。Raft算法同样具有与Paxos类似的性能和功能,但在算法结构设计上进行了分解,使领导选举和日志复制等...

    Algorithm-NewBie-Plan.zip

    2. 分布式一致性:Raft、Paxos等分布式一致性算法在分布式系统中广泛应用,如Zookeeper、etcd等中间件,确保了跨节点的数据一致性。 3. 负载均衡:负载均衡算法如轮询、权重轮询、哈希一致性等,用于在多台服务器间...

    TRON.NETWORK 白皮书

    (2) Consensus layer: a Fast Paxos-based PoS consensus algorithm. 3. P2P-based distributed storage system: a support located at the bottom: (1) Network layer: customized content-addressable P2P ...

    JGroups的Raft实现jgroups-raft.zip

    Raft is a consensus algorithm that is designed to be easy to understand. It's equivalent to Paxos in fault-tolerance and performance. The difference is that it's decomposed into relatively independent...

    raft_raft_AllTheDifference_源码

    Raft is a consensus algorithm that is designed to be easy to understand. It's equivalent to Paxos in fault-tolerance and performance. The difference is that it's decomposed into relatively independent...

    一文搞懂Raft算法

    raft是工程上使用较为广泛的强一致...raft是一个共识算法(consensusalgorithm),所谓共识,就是多个节点对某个事情达成一致的看法,即使是在部分节点故障、网络延时、网络分割的情况下。这些年最为火热的加密货币(比

    一致性算法

    这个源程序压缩包中的"Algorithm"可能包含了实现这些算法的代码,研究者可以通过分析和运行这些代码来理解一致性算法的工作原理,并对其进行优化或扩展,以适应特定的分布式环境或多智能体系统的挑战。 总的来说,...

    Chandy-Misra-Haas-Algorithm:分布式系统中死锁检测的Chandy-Misra-Haas资源模型算法

    例如,引入超时机制避免无限等待,使用确认机制保证消息的可靠传输,或者采用分布式一致性算法如Paxos或Raft来协调进程间的消息同步。 总的来说,Chandy-Misra-Haas算法为分布式系统的死锁检测提供了一种有效的方法...

Global site tag (gtag.js) - Google Analytics