ZooKeeper (2013)


Building distributed systems is hard. A lot of the applications people use daily, however, depend on such systems, and it doesn’t look like we will stop relying on distributed computer systems any time soon. Apache ZooKeeper has been designed to mitigate the task of building robust distributed systems. It has been built around core distributed computing concepts, with its main goal to present the developer with an interface that is simple to understand and program against, thus simplifying the task of building such systems.

Even with ZooKeeper, the task is not trivial—which leads us to this book. This book will get you up to speed on building distributed systems with Apache ZooKeeper. We start with basic concepts that will quickly make you feel like you’re a distributed systems expert. Perhaps it will be a bit disappointing to see that it is not that simple when we discuss a bunch of caveats that you need to be aware of. But don’t worry; if you understand well the key issues we expose, you’ll be on the right track to building great distributed applications.


This book is aimed at developers of distributed systems and administrators of applications using ZooKeeper in production. We assume knowledge of Java, and try to give you enough background in the principles of distributed systems to use ZooKeeper robustly.

Contents of This Book

Part I covers some motivations for a system like Apache ZooKeeper, and some of the necessary background in distributed systems that you need to use it.

§  Chapter 1, Introduction, explains what ZooKeeper can accomplish and how its design supports its mission.

§  Chapter 2, Getting to Grips with ZooKeeper, goes over the basic concepts and building blocks. It explains how to get a more concrete idea of what ZooKeeper can do by using the command line.

Part II covers the library calls and programming techniques that programmers need to know. It is useful but not required reading for system administrators. This part focuses on the Java API because it is the most popular. If you are using a different language, you can read this part to learn the basic techniques and functions, then implement them in a different language. We have an additional chapter covering the C binding for the developers of applications in this language.

§  Chapter 3, Getting Started with the ZooKeeper API, introduces the Java API.

§  Chapter 4, Dealing with State Change, explains how to track and react to changes to the state of ZooKeeper.

§  Chapter 5, Dealing with Failure, shows how to recover from system or network problems.

§  Chapter 6, ZooKeeper Caveat Emptor, describes some miscellaneous but important considerations you should look for to avoid problems.

§  Chapter 7, The C Client, introduces the C API, which is the basis for all the non-Java implementations of the ZooKeeper API. Therefore, it’s valuable for programmers using any language besides Java.

§  Chapter 8, Curator: A High-Level API for ZooKeeper, describes a popular high-level interfaces to ZooKeeper.

Part III covers ZooKeeper for system administrators. Programmers might also find it useful, in particular the chapter about internals.

§  Chapter 9, ZooKeeper Internals, describes some of the choices made by ZooKeeper developers that have an impact on administration tasks.

§  Chapter 10, Running ZooKeeper, shows how to configure ZooKeeper.

Conventions Used in this Book

The following typographical conventions are used in this book:


Used for emphasis, new terms, URLs, commands and utilities, and file and directory names.

Constant width

Indicates variables, functions, types, parameters, objects, and other programming constructs.

Constant width bold

Shows commands or other text that should be typed literally by the user. Also used for emphasis in command output.

Constant width italic

Indicates placeholders in code or commands that should be replaced by appropriate values.


This icon signifies a tip, suggestion, or a general note.