YouTube Icon

Interview Questions.

Top 14 Apache Zookeeper Interview Questions - Jul 25, 2022

fluid

Top 14 Apache Zookeeper Interview Questions

Q1. What Is Apache Zookeeper Meant For?

Apache ZooKeeper is a service utilized by a cluster (group of nodes) to coordinate among themselves and preserve shared statistics with robust synchronization techniques. ZooKeeper is itself a distributed utility providing offerings for writing a distributed software.

The commonplace services furnished by way of ZooKeeper are as follows :

Naming provider:Identifying the nodes in a cluster via name. It is just like DNS, but for nodes.

Configuration management: Latest and updated configuration facts of the device for a becoming a member of node.

Cluster control:Joining / leaving of a node in a cluster and node repute at real time.

Leader election:Electing a node as chief for coordination purpose.

Locking and synchronization service:Locking the information at the same time as modifying it. This mechanism allows you in computerized fail recovery whilst connecting other disbursed programs like Apache HBase.

Highly reliable information registry:Availability of records even if one or some nodes are down.

Q2. How Can We Create Children / Sub-znode?

Creating youngsters is just like creating new znodes. The handiest difference is that the direction of the kid znode could have the discern direction as properly.

Create /determine/direction/subnode/direction /records

Q3. What Are The Benefits Of Distributed Applications?

Reliability:Failure of a unmarried or some systems does not make the whole machine to fail.

Scalability : Performance may be elevated as and while needed by means of including extra machines with minor trade in the configuration of the utility and not using a downtime.

Trparency: Hides the complexity of the machine and shows itself as a single entity / software.

Q4. Explain The Methods Of Zookeeperclass?

The central a part of the ZooKeeper API is ZooKeeper elegance. It offers options to connect the ZooKeeper ensemble in its constructor and has the following strategies -

connect - hook up with the ZooKeeper ensemble

ZooKeeper(String connectionString, int sessionTimeout, Watcher watcher)

create - create a znode

create(String route, byte[] statistics, List acl, CreateMode createMode)

exists - test whether a znode exists and its facts

exists(String path, boolean watcher)

getData - get statistics from a selected znode

getData(String route, Watcher watcher, Stat stat)

setData - set facts in a specific znode

setData(String direction, byte[] information, int version)

getChildren - get all sub-nodes available in a particular znode

getChildren(String course, Watcher watcher)

delete - get a selected znode and all its children

delete(String path, int version)

near - close a connection

Q5. What Are The Challenges Of Distributed Applications?

Race situation: Two or greater machines trying to perform a specific task, which really needs to be performed most effective with the aid of a single machine at any given time. For instance, shared assets must handiest be modified via a single machine at any given time.

Deadlock:Two or extra operations awaiting each different to finish indefinitely.

Inconsistency:Partial failure of facts.

Q6. What Is Zookeper?

ZooKeeper is a disbursed co-ordination carrier to control large set of hosts. Co-ordinating and managing a provider in a distributed environment is a complex process. ZooKeeper solves this problem with its simple structure and API. ZooKeeper lets in developers to recognition on center software good judgment with out annoying approximately the allotted nature of the software.

The ZooKeeper framework became firstly constructed at “Yahoo!” for getting access to their programs in an clean and robust manner. Later, Apache ZooKeeper became a preferred for organized carrier utilized by Hadoop, HBase, and other distributed frameworks.

Q7. Explain The Cli In Zookeeper?

ZooKeeper Command Line Interface (CLI) is used to engage with the ZooKeeper ensemble for improvement purpose. It is useful for debugging and working around with exclusive alternatives. To perform ZooKeeper CLI operations, first activate your ZooKeeper server (“bin/zkServer.Sh begin”) after which, ZooKeeper consumer (“bin/zkCli.Sh”).

Once the patron begins, you may perform the subsequent operation:

Create znodes

Get records

Watch znode for adjustments

Set records

Create children of a znode

List youngsters of a znode

Check Status

Remove / Delete a znode

Q8. How Can We Create Znodes?

Create a znode with the given course. The flag argument specifies whether or not the created znode could be ephemeral, continual, or sequential. By default, all znodes are continual.

Ephemeral znodes (flag: e) can be robotically deleted when a session expires or whilst the customer disconnects.

Sequential znodes warranty that the znode course may be precise.

ZooKeeper ensemble will upload sequence number together with 10 digit padding to the znode route. For instance, the znode course /myapp will be transformed to /myapp0000000001 and the subsequent series range could be /myapp00000000@

If no flags are certain, then the znode is taken into consideration as chronic.

Create /course /facts

To create a Sequential znode, upload -s flag as proven below.

Create -s /path /statistics

To create an Ephemeral Znode, add -e flag as shown underneath.

Create -e /course /data

Q9. What Are The Benefits Of Zookeeper?

Here are the blessings of using ZooKeeper:

Simple distributed coordination technique

Synchronization:Mutual exclusion and co-operation among server processes. This method facilitates in Apache HBase for configuration control.

Ordered Messages

Serialization :Encode the information according to specific guidelines. Ensure your application runs continually. This technique may be utilized in MapReduce to coordinate queue to execute walking threads.

Reliability

Atomicity:Data trfer either prevail or fail completely, but no traction is partial.

Q10. How Can We Remove A Znode?

Removes a targeted znode and recursively all its children. This might show up simplest if this kind of znode is available.

Rmr /direction

Q11. Mention Some Instances Where Zookeeper Is Using?

Below are some of instances wherein Apache ZooKeeper is being applied:

Apache Storm, being a actual time stateless processing/computing framework, manages its kingdom in ZooKeeper Service

Apache Kafka makes use of it for selecting chief node for the topic partitions

Apache YARN is based on it for the automatic failover of useful resource manager (grasp node)

Yahoo! Utilties it because the coordination and failure recovery service for Yahoo! Message Broker, that's a relatively scalable put up-subscribe gadget managing lots of topics for replication and facts shipping. It is utilized by the Fetching Service for Yahoo! Crawler, where it also manages failure recovery.

Q12. Explain The Types Of Znodes?

Znodes are categorized as patience, sequential, and ephemeral.

Persistence znode - Persistence znode is alive even after the customer, which created that specific znode, is disconnected. By default, all znodes are persistent except otherwise designated.

Ephemeral znode - Ephemeral znodes are active until the client is alive. When a client receives disconnected from the ZooKeeper ensemble, then the ephemeral znodes get deleted robotically. For this motive, only ephemeral znodes are not allowed to have a children in addition. If an ephemeral znode is deleted, then the subsequent appropriate node will fill its role. Ephemeral znodes play an crucial position in Leader election.

Sequential znode - Sequential znodes can be both continual or ephemeral. When a new znode is created as a sequential znode, then ZooKeeper sets the course of the znode by using attaching a ten digit collection variety to the original call. For example, if a znode with route /myapp is created as a sequential znode, ZooKeeper will trade the path to /myapp0000000001 and set the subsequent collection variety as 00000000@If  sequential znodes are created simultaneously, then ZooKeeper in no way uses the equal number for each znode. Sequential znodes play an vital position in Locking and Synchronization.

Q13. Explain The Zookeeper Workflow?

Once a ZooKeeper ensemble starts offevolved, it's going to watch for the customers to attach. Clients will hook up with one of the nodes within the ZooKeeper ensemble. It may be a pacesetter or a follower node. Once a consumer is connected, the node assigns a consultation ID to the particular purchaser and sends an acknowledgement to the purchaser. If the client does now not get an acknowledgment, it certainly attempts to attach any other node inside the ZooKeeper ensemble. Once related to a node, the client will send heartbeats to the node in a everyday c language to make certain that the connection isn't always misplaced.

If a customer desires to study a particular znode, it sends a read request to the node with the znode course and the node returns the requested znode by means of getting it from its personal database. For this reason, reads are fast in ZooKeeper ensemble.

If a purchaser desires to shop data inside the ZooKeeper ensemble, it sends the znode path and the facts to the server. The related server will forward the request to the chief and then the leader will reissue the writing request to all of the fans. If handiest a majority of the nodes reply efficiently, then the write request will prevail and a successful return code might be sent to the consumer. Otherwise, the write request will fail. The strict majority of nodes is known as as Quorum.

Q14. What Are The Basics Of Zookeeper Api?

Application interacting with ZooKeeper ensemble is referred as ZooKeeper Client or in reality Client. Znode is the middle issue of ZooKeeper ensemble and ZooKeeper API gives a small set of techniques to control all the information of znode with ZooKeeper ensemble. A patron have to observe the stairs given beneath to have a clear and clean interaction with ZooKeeper ensemble.

Connect to the ZooKeeper ensemble. ZooKeeper ensemble assign a Session ID for the consumer.

Send heartbeats to the server periodically. Otherwise, the ZooKeeper ensemble expires the Session ID and the purchaser desires to reconnect.

Get / Set the znodes as long as a consultation ID is energetic.

Disconnect from the ZooKeeper ensemble, once all the tasks are finished. If the purchaser is inactive for a extended time, then the ZooKeeper ensemble will automatically disconnect the customer.




CFG