Part 2: CHAPTER 9 Consistency and Consensus

本文探讨了分布式系统中的一致性、线性化和共识算法的关系。线性化提供了原子性和时间顺序保证,但对网络延迟敏感。共识算法确保节点间的一致决策,适用于分布式事务和原子提交。文中还介绍了2PC、Zookeeper在实现共识中的应用,以及其在网络故障和性能上的挑战。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

?

  • It turns out that there are deep connections between ordering, linearizability, and consensus. 阐明它们之间的关系?
  • 相比于单机事务,分布式事务有何不同?如何实现?
  • 了解 google spanner(事务) 和 zk(consensus) 的实现
  • CAP 定理的理解

resource

http://www.bailis.org/blog/linearizability-versus-serializability

In this chapter, we will talk about some examples of algorithms and protocols for building fault-tolerant(可用性?) distributed systems. 本章讲什么

The best way of building fault-tolerant systems is to find some general-purpose abstractions with useful guarantees, implement them once, and then let applications rely on those guarantees.

Summary

Consistent:

Linearizability: 提供 stronger consistency, make replicated data appear as though there were only a single copy, and to make all operations act on it atomically

  • 优点: 易于理解
  • 缺点: 对网络问题敏感,性能慢

Causality: which puts all operations in a single, totally orderedtimeline, causality provides us with a weaker consistency model

  • 优点: 对网络问题不敏感
  • 使用场景受限
Consensus

Consensus algorithms are a huge breakthrough for distributed systems: they bring concrete safety properties (agreement, integrity, and validity) to systems where everything else is uncertain, and they nevertheless remain fault-tolerant (able to make progress as long as a majority of nodes are working and reachable). They provide total order broadcast, and therefore they can also implement linearizable atomic operations in a fault-tolerant way.

定义: Deciding something in such a way that all nodes agree on what was decided, and such that the decision is irrevocable.

使用场景:

  • Linearizable compare-and-set registers
  • Atomic transaction commit
  • Total order broadcast
  • Locks and leases
  • Membership/coordination service
  • Uniqueness constraint

Zookeeper:

  • providing an “outsourced” consensus
  • failure detection
  • membership service

Consistency Guaranteess

分布式 db 中,由于网络等因素,数据不一致一定会发生,因此 Most replicated databases provide at least eventual consistency

eventual consistency: 所有 replicas 的数据最终会达到一致。

  1. this is a very weak guarantee—it doesn’t say anything about when the replicas will converge
  2. 难以使用和测试: you need to be constantly aware of its limitations and not accidentally assume too much

stronger consistency: 所有 replicas 数据总是保持一致

  • 缺点: worse performance, less fault-tolerant
  • 优势: easier to use correctly

distributed consistency is mostly about coordinating the state of replicas in the face of delays and faults.

Linearizability:

3 个特质:

  • Recency gurantee
  • single operations on singel object
  • time dependency and always move forward in time

定义:

Linearizability(atomic consistency) is a guarantee about single operations on single objects. It provides a real-time (i.e., wall-clock) guarantee on the behavior of a set of single operations (often reads and writes) on a single object。

Linearizability is a recency guarantee(once a new value has been written or read, all subsequent reads see the value that was written, until it is overwritten again) on reads and writes of a register (an individual object). It doesn’t group operations together into transactions.

Vs Serializability:

linearizability can be viewed as a special case of strict serializability where transactions are restricted to consist of a single operation applied to a single object.

[http://www.bailis.org/blog/linearizability-versus-serializability/]

使用场景:

  • Locking and leader election: They use consensus algorithms to implement linearizable
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值