1. 程式人生 > >Zookeeper coordination service for distributed system :)

Zookeeper coordination service for distributed system :)

Zookeeper open source very powerful for distributed applications. It is used very popular in Hadoop ecosystem and the fist i knew it is when i build cloud message for AZStack-SDK, we use Hbase + Hadoop + Zookeeper  build cluster to store message and query over hundred GB data. Hadoop and Hbase are distributed application, with Hadoop  (multiple namenode, datanode) and Hbase (regionserver). Zookeeper is really excellent coordinator. After use Zoo for cloud message, i started to learn more about it so it really cool for me. In fact, the way information in zookeeper is organized is quite similar to a file system. At the top there is  a root simply referred to as /, below root are znodes.

zknamespace

Unlike an ordinary distributed file system. Zookeeper supports the concepts of ephemeral zNode and sequential zNode. An ephemeral zNode is a node that will disappear when the session of its owner ends. In distributed application every server cam be defined public ip in an ephemeral node, when server loose connectivity with Zookeeper and fail to reconnect within session timeout then all information about that server is deleted. The below figure is a illustration  how to use ephemeral node for manage distributed services

zookeeper_ephemeral

Sequential nodes are nodes whose names are automatically assigned a sequence number suffix. This suffix is auto increment and assigned by Zookeeper when the zNode is created. An easy way of doing leader election with Zookeeper is to let every server publish it information in a zNode that is both sequential and ephemeral. Then whichever server has the lowest sequential zNode is the leader. If the leader or any other server goes offline, its session dies and its ephemeral node is removed, and all other servers can observe who is the new leader.

How to Zookeeper cluster work with client ?

Zookeeper cluster have 2 types (Leader, Follower) system run load balance when client connect to cluster, every instance zookeeper can be served many clients. If client request read data to Follower instance then it response direct by local data, however when client request write data this request will be forwarded to leader and leader broadcast into all node  to update data on follower instance.

fig01

The main objective of the post is introduce the overview about Zookeeper. The next post i will give you instructions how to install, config and how to use Zookeeper in distributed application. Thank you for reading.

Advertisements

Like this:

Like Loading...