Zookeeper
Legal Hierarchies
Quorums
Distributed Systems
Information Technology

Legal Hierarchical Quorums in Zookeeper

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Apache ZooKeeper is an open-source server which enables highly reliable distributed coordination. It is commonly used in distributed systems for maintaining configuration information, naming, providing distributed synchronization, and providing group services. To ensure that it performs these tasks reliably, ZooKeeper uses a concept known as "Legal Hierarchical Quorums."

Quorum Basics

The notion of a quorum in distributed computing involves a majority of nodes (servers in a cluster) agreeing on a state before a decision is considered as committed. This majority set ensures the consistency and reliability of data despite failures of some of the nodes.

Hierarchical Quorum

In ZooKeeper, a "Hierarchical Quorum" extends this basic notion by organizing the set of all nodes into groups, where each group itself has a quorum configuration. This arrangement helps in optimizing for scenarios where nodes are spread across geographically distant locations (also referred to as Data Centers or DCs). Here, each DC can be treated as a group.

The fundamental idea is that for a global quorum to be satisfied, a quorum of these groups (DCs) needs to achieve their internal quorum. This layered quorum approach helps reduce cross-datacenter communication, thus improving response times for global decisions.

A “Legal Quorum” in the hierarchical setting ensures that not only a majority of the nodes in the majority of groups agree, but also that these groups are legally representative of the whole ensemble. For example, if there are dependencies or weights assigned to certain nodes or groups, a legal quorum takes these into account, ensuring that the system's integrity and committed decisions are as per the defined rules and priorities.

Technical Example

Consider a distributed system with 9 nodes divided into 3 groups (DCs - DC1, DC2, DC3) with each group containing 3 nodes. A simple majority quorum would just require any 5 nodes to agree for a decision to be globally committed. However, in a hierarchical setup:

  • Each group (DC) might first agree internally among at least 2 of its 3 nodes.
  • Then, at least 2 out of the 3 groups must achieve this internal quorum for a global agreement.

This hierarchical arrangement allows the system to operate efficiently even when one of the groups completely fails or becomes isolated due to network issues.

Benefits and Challenges

Benefits

  1. Fault Tolerance: Enhanced fault tolerance, as the system can function even if one or more groups fail.
  2. Scalability: Improves scalability since each group can handle decisions locally reducing the need for all nodes across groups to participate in every decision.
  3. Efficiency: Reduces the number of inter-datacenter messages, improving response times for write operations.

Challenges

  1. Complexity: Increased complexity in configuration and understanding the system's behavior.
  2. Maintenance: More complicated setup and maintenance due to the layered quorum approach.

Summary Table

FeatureDescription
Node ArrangementNodes are arranged in hierarchically grouped quorums.
Decision MakingRequires local and global quorums to agree on decisions.
Fault ToleranceCan withstand failure of complete groups.
EfficiencyReduces cross-DC communication, enhancing performance.
Configuration ComplexityMore complex due to hierarchical setup.

Conclusion

Legal Hierarchical Quorums in ZooKeeper provide a robust mechanism for managing distributed consensus in environments where nodes are geographically dispersed. This methodology enhances the system’s fault tolerance and efficiency but adds layers of complexity in configuration and maintenance. Proper understanding and careful setup are crucial to leverage the full benefits of this system while managing its complexities effectively.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.