ZAB(zoopeeper atomic broadcast protocol)协议

说明

Zab协议(ZooKeeper Atomic Broadcast Protocol)是ZooKeeper使用的一种基于Paxos算法的原子广播协议,用于保证分布式环境下的一致性和可靠性。Zab协议实现了分布式系统中的原子广播,使得ZooKeeper集群中的所有节点都可以达成一致的状态,从而保证了系统的可靠性和一致性。

Zab协议将ZooKeeper集群中的所有节点分为两类:Leader和Follower。Leader节点负责接收客户端请求,并将请求广播给所有Follower节点。Follower节点接收请求并将其复制到本地存储中。当多数节点都成功复制请求后,Leader节点将请求标记为已提交,并将其广播给所有Follower节点。Follower节点接收提交请求并将其应用到本地存储中。

Zab协议的设计目标是保证原子性、顺序性、可靠性和高效性。它通过将ZooKeeper集群中的所有节点分为Leader和Follower两类,实现了分布式系统中的原子广播,使得ZooKeeper集群中的所有节点都可以达成一致的状态,从而保证了系统的可靠性和一致性。

Simply put

The ZooKeeper Atomic Broadcast (ZAB) protocol is a critical component of Apache ZooKeeper, a distributed coordination service. ZAB is responsible for ensuring that updates to ZooKeeper’s distributed state are performed in a highly available and consistent manner. Here’s an overview of how it works:

ZAB uses a primary-backup model, with one ZooKeeper server acting as the primary (also called the leader) and the others acting as fully redundant backups (followers). The primary is responsible for handling all write requests and broadcasting updates to the followers in the form of transactions.

Every transaction is assigned a monotonically increasing zxid (ZooKeeper transaction ID). The primary generates a zxid for each transaction it receives and sends that zxid with the transaction to each follower in a broadcast message. When a follower has successfully applied the transaction, it sends an acknowledgment to the primary with the highest zxid it has received so far. This is known as a Acknowledgment (ACK).

Once the primary has received acknowledgments from a quorum of followers (usually a majority), it considers the transaction committed. It then sends a commit message to all followers, which tells them to commit the transaction locally. The followers then respond with an acknowledgment that they have committed the transaction. Once the primary has received acknowledgments from a quorum of followers that have committed the transaction and have no outstanding transactions on their logs, it considers the transaction durable.

你可能感兴趣的:(分布式系统概念和设计,&,GPT,&,ME,Zookeeper,with,me,&,gpt,zookeeper,一致性模型)