ZooKeeper .NET Client
Over the past couple of weeks, I ported the Java client for ZooKeeper to .NET. What is ZooKeeper?
ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications. Each time they are implemented there is a lot of work that goes into fixing the bugs and race conditions that are inevitable. Because of the difficulty of implementing these kinds of services, applications initially usually skimp on them, which make them brittle in the presence of change and difficult to manage. Even when done correctly, different implementations of these services lead to management complexity when the applications are deployed.
ZooKeeper aims at distilling the essence of these different services into a very simple interface to a centralized coordination service. The service itself is distributed and highly reliable. Consensus, group management, and presence protocols will be implemented by the service so that the applications do not need to implement them on their own. Application specific uses of these will consist of a mixture of specific components of Zoo Keeper and application specific conventions. ZooKeeper Recipes shows how this simple service can be used to build much more powerful abstractions.
ZooKeeper was originally written by Yahoo! and was open sourced as a Hadoop sub-project. If you are familiar with Google Chubby, ZK scratches a similar itch. Basically, you create a quorum of servers that use a Paxos variant to propagate changes between the nodes. There is plenty of information about ZooKeeper already available, so I won’t go into too any detail — but it helps solve of a number of problems in distributed applications such as naming, configuration, and group membership, barriers, locks, 2PC, and leader election.
I try to take very few liberties when porting code from one language to another in order to get things working first. Now that I have a good base and tests passing, I am planning on making the client feel a little more “.NET-like” – particularly around watches. Also, I am far from a socket programming expert, so any performance improvements in this area would be especially welcome – just remember that ZooKeeper communication is guaranteed to be ordered (asynchronous does not help).
The source is available on GitHub (under src/dotnet). I have already submitted a patch to add C# support for Jute (ZK’s client/server protocol which is a fork of Hadoop’s recordio) and will be contributing the rest of client back to Apache once things get a little more stable. The client is not being used in production at the moment, so please consider the software quality to be alpha.





