这个定理里描述了一个分布式的系统中,涉及共享数据问题时,以下三个特性最多只能同时满足其中两个:
选择放弃一致性的 AP 系统目前是设计分布式系统的主流选择,因为 P 是分布式网络的天然属性,你再不想要也无法丢弃;而 A 通常是建设分布式的目的,如果可用性随着节点数量增加反而降低的话,很多分布式系统可能就失去了存在的价值,除非银行、证券这些涉及金钱交易的服务,宁可中断也不能出错,否则多数系统是不能容忍节点越多可用性反而越低的。
为此,人们又重新给一致性下了定义,将前面我们在 CAP、ACID 中讨论的一致性称为“强一致性”(Strong Consistency),有时也称为“线性一致性”(Linearizability,通常是在讨论共识算法 的场景中),而把牺牲了 C 的 AP 系统又要尽可能获得正确的结果的行为称为追求“弱一致性”。不过,如果单纯只说“弱一致性”那其实就是“不保证一致性”的意思……人类语言这东西真的是博大精深。在弱一致性里,人们又总结出了一种稍微强一点的特例,被称为“最终一致性”(Eventual Consistency),它是指:如果数据在一段时间之内没有被另外的操作所更改,那它最终将会达到与强一致性过程相同的结果,有时候面向最终一致性的算法也被称为“乐观复制算法”。
强一致性 Strong Consistency: All accesses are seen by all parallel processes (or nodes, processors, etc.) in the same order (sequentially)
弱一致性 Weak Consistency: Weak consistency means that in a distributed system, there is no guarantee that all parallel processes (or nodes, processors, etc.) see the same order of updates. This can result in inconsistencies between different nodes, but is often a trade-off made in order to achieve higher availability and partition tolerance.
最终一致性 Eventual Consistency: Eventual consistency is a type of weak consistency where if data is not updated for a period of time, all updates will eventually propagate throughout the system and reach a consistent state. This is in contrast to strong consistency, where all accesses are seen by all parallel processes or nodes in the same order.
共识(Consensus)与一致性(Consistency)的区别:一致性是指数据不同副本之间的差异,而共识是指达成一致性的方法与过程。
拜占庭将军问题 Byzantine fault refers to a type of fault that can occur in distributed systems where components may fail and send conflicting information to different parts of the system. This can cause the system to become inconsistent or even fail altogether. Byzantine fault tolerance (BFT) is a technique for ensuring that a distributed system can continue to function correctly even when some of its components fail or behave maliciously. BFT is an important aspect of many distributed consensus algorithms, especially in blockchain technology.
Practical Byzantine Fault Tolerance (PBFT), Proof of Work (PoW), and Proof of Stake (PoS) are all consensus algorithms used in distributed systems, but they differ in how they achieve consensus.
PBFT is designed for use in systems where there is a small number of trusted nodes. It is faster and more efficient than PoW, but it is also less secure. PBFT enables a distributed system to continue to function correctly even when some of its components fail or behave maliciously. It is a type of Byzantine fault tolerance (BFT) and is used in many blockchain systems, including Hyperledger Fabric. 联盟链