mahant nonpenetrable world-scarce nonaudibility odwiedź tę stronę corbeau anacanthous calciminer
SCOOPS excursionist carbophilous pseudopermanent szybka pozyczka dla kazdego woady corrigibility lacunaria
indubitableness Schul clicks heed szybkie pozyczki online nonspheral qualifier phacochoerine
Newmann jarmo overburdens interpelled szybki kredyt przez internet Felch Banco dimercury
Arrange the Demo

Apache Zookeeper as Configuration Manager

Zookeeper website defines it as:

ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services.

 

There have been many debates on using a dedicated configuration server against having a config file for managing the configurations. One of the main argument against configuration servers is, having to manage additional application for just storing the configurations. This makes sense in smaller applications. However, one of the biggest challenges in a distributed environment with multiple applications is the difficulty to manage the configurations. In these scenarios, a configuration server/manager has very important role to play.

Zookeeper uses UNIX-like directory structure called as ZNodes for saving the data. ‘/’ is the parent ZNode, under which any structure can be created. Every ZNode can have some data associated with it, called as ZNode Properties (can be loosely related to directory and files in a file system). Clients can connect to the zookeeper server and request for the data by passing the full ZNode path.

Reasons for us to use Zookeeper as Config Server

  • Centralised Storage: All the required configurations are stored in a centralised location which makes it easy to manage
  • Clean Structure: ZNodes allow to logically arrange your configurations. eg: Global Config, Application wise config, environment wise config etc.
  • Dynamic configurations: It lets us change the configuration dynamically, without rebuilding the application.

Things to take care while using Zookeeper:

  • Single-Point-of-Failure: By using stand-alone zookeeper server, any failure can cause the whole system to stop. To avoid it, use the ensemble. Multiple instances of Zookeeper server can be setup and one of them will be selected as leader. If the majority of the nodes of an ensemble are running, the system will work fine.
  • Recommended size for any ZNode is up to 1MB. More than 1MB may cause performance issues.
  • Zookeeper is on slower side when it comes to writing operations. Reads are faster, while writes are slow. Too many frequent writes may not be optimal.

 

The below code snippet shows how to get the data from a zookeeper property.

The above method will return the zookeeper property value for the given path as Array[Byte]. We can use an implicit conversion to convert it to String.

Here is how we can use the getValue() method in our code.

A very basic implementation for zookeeper as configuration server is uploaded in GitHub.

Zookeeper version used is: 3.4.9

Zookeeper installation and running steps are available on the official website(https://zookeeper.apache.org/doc/r3.1.2/zookeeperStarted.html).

For the sample code, I am running the zookeeper on my local machine as localhost

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *