What is the use case of an ephemeral znode of zookeeper?
Asked Answered
A

2

4

Zookper document reads something like,

ZooKeeper also has the notion of ephemeral nodes. These znodes exists as long as the session that created the znode is active. When the session ends the znode is deleted. Ephemeral nodes are useful when you want to implement [tbd].

I understood the functionality but what could be the purpose or use case of session specific znode?

Amadavat answered 20/3, 2019 at 2:12 Comment(0)
T
3

An ephemeral zNode is a node that will disappear when the session of its owner ends. A typical use case for ephemeral nodes is when using ZooKeeper for discovery of hosts in your distributed system (service discovery). Each server can then publish its IP address in an ephemeral node, and should a server loose connectivity with ZooKeeper and fail to reconnect within the session timeout, then its information is deleted.

Sources:

 - https://www.elastic.co/blog/found-zookeeper-king-of-coordination
 - https://blog.box.com/blog/a-gotcha-when-using-zookeeper-ephemeral-nodes
Tacky answered 20/3, 2019 at 2:25 Comment(5)
Cant this use-case be fulfilled by connecting to the leader node? Doesn't it have the state of the cluster?Amadavat
is that ephemeral node recreated once connection reconnected ?Durwyn
@BhanuchanderUdhayakumar that will be new ephemeral nodeTacky
@AnuragSharma so we need to create again right ? it won't restore as it is a new session..Durwyn
@BhanuchanderUdhayakumar correct, that is why it is called ephemeralTacky
A
2

Zookeeper leader election uses ephemeral nodes. Each node creates an ephemeral-sequential node and creates a watch on its previous ephemeral node and creates a linked list kind of structure. This article explains more in detail.

Kafka consumer (or consumer groups) offsets are also maintained in the ephemeral nodes. This article explains more in detail.

Amadavat answered 8/2, 2020 at 19:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.