Skip to content

Is ZooKeeper CP or AP

Warren Zhu edited this page Aug 7, 2018 · 4 revisions

Is Zookeeper CP or AP

Many people have used Zookeeper as coordination service. One day, when somebody asked whether Zookeeper is CP or AP system, I find the answer is surprising. My first reaction is that Zookeeper is not strong consistent since the read from the follow is not guaranteed to get the latest state. Then it must be AP due to that we usually take two out of three based on CAP theorem. But wait, it seems also not always available. When network partition happens, the client connected to minority couldn't perform writing. So the answer is more like that Zookeeper is neither CP nor AP. But we jump to conclusion, let's clarify what CAP really means.

Clarification of CAP

  • Consistency actually means linearizability, also strong consistency. Both will be explained below.

  • Availability is defined as every request received by a non-failing node in the system must result in a response. That means any non-failing node should be able handle any request. So most so-called highly-available systems don't meet this definition.

  • Partition Tolerance basically means that you’re communicating over an asynchronous network that may delay or drop messages. The internet and all our data centers have this property, so you don’t really have any choice in this matter.

Consistency Guarantees

It seems that we need more clear definition of different level of consistency Guarantees to help us communicate and evaluate distributed systems. Luckily, Doug Terry has defined this:

  1. Strong consistency also linearizability.
  2. Eventual consistency
  3. Consistent Prefix
  4. Bounded staleness
  5. Monotonic Read
  6. Read my write