chubby中使用paxos的分析

2024-03-21 17:48
文章标签 分析 使用 paxos chubby

本文主要是介绍chubby中使用paxos的分析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


chubby使用paxos作为日志错误容错的复制算法,在协议栈的最底层,paxos算法确保了每个replica的本地日志都有相同的entries,replicas的通信则是通过paxos-specific protocal,一旦某个值进入容错日志,每个replica会调用发送一个callback给客户端应用程序,告诉这个已提交的值




chubby的paxos描述【隐藏了propose和promise的消息发送】
1. 选出一个coordinator.
2. 选择一个value,并广播给所有的replicas,该消息称为accept message,其他replicas不是acknowledge message就是reject it
3. 一旦收到大多数的acknowledge, coordinator就广播commit 消息 to notify replicas


选择coordinator?

在chubby中选择coordinator上,paxos确保在某一个值上【选出一个coordinator】达成一致通过引入两种机制:

1)分配一个有序编号给后续的coordinators【通过产生一个最新的编号来成为coordinator, 如Replica r 的编号为s mod n = Ir , 然后broadcasts all replicas in a propose message 等待replicas 回复 promise】

2)严格限制每个coordinator的选值【什么意思呢?在选择coordinator的时候,使用的是fully paxos,即二阶段paxos,如果在第一阶段后收到一个已确定的值,则使用该值(使用该coordinator)】



与ZK的一点区别?
chubby可以不断轮换coordinator。原文描述为if consensus was achieved by a previous coordinator, the new coordinator is guaranteed to hear about the value decided upon from at least one replica. By induction, that value will have the highest sequence number of all responses received, and so will be selected by the new coordinator. 这样可以轮流换coordinator,这点和ZK还是有区别,ZK一旦leader确定下载,如果不失败的话是不会改变的,但chubby可以不断轮换coordinator



轮换coordinator 怎么解决活锁的问题呢?如果某段时间内有两个replicas一直争抢着要成为coordinator,这个怎么解决?

chubby 解决活锁的办法:In our implementation the master periodically boosts its sequence number by running a full round of the Paxos algorithm, including sending propose messages. Boosting with the right frequency avoids this type of master churn in most cases. 即在希望成为master的时候,是间断性的 right frequency 来避免这一活锁问题


对paxos还有点小不明白的就是并发的情况是怎么样的?有案例吗?

我在看chubby的论文的时候,一直看到那个sequencer的东西,但这个sequencer似乎并不是看得很懂,paxos都是异步的,只要满足序号,并发处理是没有啥问题的



处理拖后腿的replica?

对于拖后腿的replica则让其catch up 那些leading replicas



chubby如何处理优化的?
In a system where replicas are in close network proximity, disk flush time can dominate the overall latency of the implementation.
在replicas都很近的情况下,刷磁盘会很耗代价
使用了lambort的优化made simple的优化:
Propose messages may be omitted if the coordinator identity does not change between instances. This does not interfere with the properties of Paxos because any replica at any time can still try to become coordinator by broadcasting a propose message with a higher sequence number.
为了利用这一优化,所以尽可能的少轮换coordinatorpick a coordinator for long periods of time, trying not to let the coordinator change,但它又说利用了这点每个replica只要写一次磁盘就行了,master在发送accept的消息前写磁盘,其他的replicas在发送acknowledge消息前,写一次磁盘就行了
另一种为增加吞吐量,In order to get additional throughput in a concurrent system, it is possible to batch a collection of values submitted by di?erent application threads into a single Paxos instance



如何处理disk corruption
原因是A disk may be corrupted due to a media failure or due to an operator error (an operator may accidentally erase critical data). When a replica’s disk is corrupted and it loses its persistent state, it may renege on promises it has made to other replicas in the past.
由于不保证它的promise,因此,这违背了paxos的算法的一个关键假设:P2B If a proposal with value v is chosen, then every higher-numbered proposal issued by any proposer has value v. 即如果一个议案被选择了,那么此后,任何proposer提出的议案(编号更高)包含的决议都是v
解决disk corruptions的情况:
Either filele(s) contents may change or file(s) may become inaccessible,解决第一种是将文件checksum存储在文件中 后边的问题检测是replica在第一次启动后存放一个marker在GFS中,如果再次启动发现一个empty disk 并且在GFS中有这个标示,则说明是corrupted disk
重建replica的状态  It participates in Paxos as a non-voting member; meaning that it uses the catch-up mechanism to catch up but does not respond with promise or acknowledgment messages. It remains in this state until it observes one complete instance of Paxos that was started after the replica started rebuilding its state. By waiting for the extra instance of Paxos, we ensure that this replica could not have reneged on an earlier promise
另外,论文还说到,利用这一机制还能降低系统的延迟,即可以接受不需要立即刷磁盘。但他们也说还没有实现,不知道现在有没有实现好



master lease的问题
as long as the master has the lease, it is guaranteed that other replicas cannot successfully submit values to Paxos. Thus a master with the lease has up-to-date information in its local data structure which can be used to serve a read operation purely locally. By making the master attempt to renew its lease before it expires we can ensure that a master has a lease most of the time. With our system, masters successfully maintain leases for several days at a time.
意思是如果master有lease的话,则其他的replicas不能重新选coordinator,这里的coordinator和master其实是同一个概念,即每一次只有一个master,然后他们的系统中说master一次成功维持了几天。通过master lease 这样 read 操作总是能读到本地最新的数据,但,是不是也可能读到stale的值呢?我想应该也是有可能的,比如我刚提交的一个值,我马上读,这有可能就读不到,这点其实和ZK应该是一样的,区别应该还是在于chubby可以要求成为master,当然,chubby后面也说了,基于这个的lease机制,如果replicas使用的话,也可以让clients直接从本地replicas上读,说还没有实现。




master turnover以及abort会有什么影响?那如何检测master turnover和abort operations?
似乎对客户端也没有什么影响,只是需要告诉客户端master改变了,你应该发送请求到另外的一个master去,如果返回epoch number相同表明没有变换过




chubby 如何通知客户端master是哪个?
每个replica都知道的



关于group membership
对于group membership似乎还不是很清楚,chubby中也只是说文献没有指出 paxos也没有证明使用该算法来实现group membership的正确性,基本上在该文献中是一笔带过,回头看看其他文献有没有说明这个东西






snapshots的问题
两个问题: it requires unbounded amounts of disk space; and perhaps worse, it may result in unbounded recovery time since a recovering replica has to replay a potentially long log before it has fully caught up with other replicas
所以有必要在某一点上的操作日志对应的内存的数据结构序列化到磁盘,truncate掉之前的日志记录

另外,snapshots的问题并不是由paxos framework来做的,因为its only concern is the consistency of the replicated log. 

the lagging replica asks for and receives the remaining log records from the leading replica to bring it fully up-to-date

关于snapshot的时候必须对应日志号,那么在线的时候应该怎么处理?以下是论文中的说法

Our first implementation of the fault-tolerant database blocked the system very briefly while making an in-memory copy of the (small) database. It then stored the copied data on disk via a separate thread. Subsequently we implemented virtually pause-less snapshots. We now use a “shadow” data structure to track updates while the underlying database is serialized to disk.



如果直接accept消息而不是完全paxos的算法会有什么问题吗?
这回到了为什么要使用两阶段的问题,按lambort的说话,paxos made simple 中说第一阶段保证了某一proposal被选择了,第二阶段保证最高的proposal对应的值都是value

chubby使用的是TCP还是UDP?

原文这样描述:This would seem ideal, except that it introduced a tension in our choice of protocol. TCP’s back off policies pay no attention to higher-level timeouts such as Chubby leases, so TCP-based KeepAlives led to many lost sessions at times of high network congestion. We were forced to send KeepAlive RPCs via UDP rather than TCP; UDP has no congestion avoidance mechanisms, so we would prefer to use UDP only when high-level timebounds must be met.



引用

chubby的介绍论文 http://static.googleusercontent.com/external_content/untrusted_dlcp/research.google.com/en//archive/chubby-osdi06.pdf

chubby的实现论文,Paxos Made Live - An Engineering Perspective http://www.cs.ucla.edu/~kohler/class/08w-dsi/chandra07paxos.pdf







































































































这篇关于chubby中使用paxos的分析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/833425

相关文章

Python使用FastAPI实现大文件分片上传与断点续传功能

《Python使用FastAPI实现大文件分片上传与断点续传功能》大文件直传常遇到超时、网络抖动失败、失败后只能重传的问题,分片上传+断点续传可以把大文件拆成若干小块逐个上传,并在中断后从已完成分片继... 目录一、接口设计二、服务端实现(FastAPI)2.1 运行环境2.2 目录结构建议2.3 serv

Spring Security简介、使用与最佳实践

《SpringSecurity简介、使用与最佳实践》SpringSecurity是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架,本文给大家介绍SpringSec... 目录一、如何理解 Spring Security?—— 核心思想二、如何在 Java 项目中使用?——

springboot中使用okhttp3的小结

《springboot中使用okhttp3的小结》OkHttp3是一个JavaHTTP客户端,可以处理各种请求类型,比如GET、POST、PUT等,并且支持高效的HTTP连接池、请求和响应缓存、以及异... 在 Spring Boot 项目中使用 OkHttp3 进行 HTTP 请求是一个高效且流行的方式。

Java使用Javassist动态生成HelloWorld类

《Java使用Javassist动态生成HelloWorld类》Javassist是一个非常强大的字节码操作和定义库,它允许开发者在运行时创建新的类或者修改现有的类,本文将简单介绍如何使用Javass... 目录1. Javassist简介2. 环境准备3. 动态生成HelloWorld类3.1 创建CtC

使用Python批量将.ncm格式的音频文件转换为.mp3格式的实战详解

《使用Python批量将.ncm格式的音频文件转换为.mp3格式的实战详解》本文详细介绍了如何使用Python通过ncmdump工具批量将.ncm音频转换为.mp3的步骤,包括安装、配置ffmpeg环... 目录1. 前言2. 安装 ncmdump3. 实现 .ncm 转 .mp34. 执行过程5. 执行结

Java使用jar命令配置服务器端口的完整指南

《Java使用jar命令配置服务器端口的完整指南》本文将详细介绍如何使用java-jar命令启动应用,并重点讲解如何配置服务器端口,同时提供一个实用的Web工具来简化这一过程,希望对大家有所帮助... 目录1. Java Jar文件简介1.1 什么是Jar文件1.2 创建可执行Jar文件2. 使用java

C#使用Spire.Doc for .NET实现HTML转Word的高效方案

《C#使用Spire.Docfor.NET实现HTML转Word的高效方案》在Web开发中,HTML内容的生成与处理是高频需求,然而,当用户需要将HTML页面或动态生成的HTML字符串转换为Wor... 目录引言一、html转Word的典型场景与挑战二、用 Spire.Doc 实现 HTML 转 Word1

Java中的抽象类与abstract 关键字使用详解

《Java中的抽象类与abstract关键字使用详解》:本文主要介绍Java中的抽象类与abstract关键字使用详解,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、抽象类的概念二、使用 abstract2.1 修饰类 => 抽象类2.2 修饰方法 => 抽象方法,没有

MyBatis ParameterHandler的具体使用

《MyBatisParameterHandler的具体使用》本文主要介绍了MyBatisParameterHandler的具体使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参... 目录一、概述二、源码1 关键属性2.setParameters3.TypeHandler1.TypeHa

Spring 中的切面与事务结合使用完整示例

《Spring中的切面与事务结合使用完整示例》本文给大家介绍Spring中的切面与事务结合使用完整示例,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考... 目录 一、前置知识:Spring AOP 与 事务的关系 事务本质上就是一个“切面”二、核心组件三、完