ZooKeeper




What is Apache Zookeeper?

centralized service for maintaining distributed applications

Why Do We Need Apache Zookeeper?

Apache ZooKeeper is used for maintaining centralized configuration information, naming, providing distributed synchronization, and providing group services in a simple interface so that we don’t have to write it from scratch. Apache Kafka also uses ZooKeeper to manage configuration.

ZooKeeper Architecture

Apache ZooKeeper works on the Client-Server architecture in which clients are machine nodes and servers are nodes.

we can see that each client sources the client library, and further they communicate with any of the ZooKeeper nodes.

Components of the ZooKeeper architecture

Part

Description

Client

Client node in our distributed applications cluster is used to access information from the server. It sends a message to the server to let the server know that the client is alive, and if there is no response from the connected server the client automatically resends the message to another server.

Server

The server gives an acknowledgement to the client to inform that the server is alive, and it provides all services to clients.

Leader

If any of the server nodes is failed, this server node performs automatic recovery.

Follower

It is a server node which follows the instructions given by the leader.

Working of Apache ZooKeeper

  • The first thing that happens as soon as the ensemble (a group of ZooKeeper servers) starts is, it waits for the clients to connect to the servers.
  • After that, the clients in the ZooKeeper ensemble will connect to one of the nodes. That node can be any of a leader node or a follower node.
  • Once the client is connected to a particular node, the node assigns a session ID to the client and sends an acknowledgement to that particular client.
  • If the client does not get any acknowledgement from the node, then it resends the message to another node in the ZooKeeper ensemble and tries to connect with it.
  • On receiving the acknowledgement, the client makes sure that the connection is not lost by sending the heartbeats to the node at regular intervals.
  • Finally, the client can perform functions like read, write, or store the data as per the need.

Features of Apache ZooKeeper

Apache ZooKeeper provides a wide range of good features to the user. Let’s start exploring them.

  • Updating the Node’s Status: Apache ZooKeeper is capable of updating every node that allows it to store updated information about each node across the cluster.
  • Managing the Cluster: This technology can manage the cluster in such a way that the status of each node is maintained in real time, leaving lesser chances for errors and ambiguity.
  • Naming Service: ZooKeeper attaches a unique identification to every node which is quite similar to the DNA that helps identify it.
  • Automatic Failure Recovery: Apache ZooKeeper locks the data while modifying which helps the cluster recover it automatically if a failure occurs in the database.

Benefits of Apache ZooKeeper

As we have understood what Apache ZooKeeper is, let us now discuss about its benefits. Here are some of the advantages of working with Apache ZooKeeper.

  • Simplicity: Coordination is done with the help of a shared hierarchical namespace.
  • Reliability: The system keeps performing even if more than one node fails.
  • Order: It keeps track by stamping each update with a number denoting its order.
  • Speed: It runs with a ratio of 10:1 in the cases where ‘reads’ are more common.
  • Scalability: The performance can be enhanced by deploying more machines.

ZooKeeper Use Cases

There are many use cases of ZooKeeper. Some of the most prominent of them are as follows:

  • Managing the configuration
  • Naming services
  • Choosing the leader
  • Queuing messages
  • Managing the notification system
  • Synchronization

One of the ways in which we can communicate with the ZooKeeper ensemble is by using the ZooKeeper Command Line Interface (CLI). This gives us the feature of using various options, and also for the sake of debugging there is increased dependence on the CLI.

 


No comments:

Post a Comment