← Lessons

quiz vs the machine

Gold1400

Concurrency

The Ephemeral Node And Watch

Combining short lived nodes with change notifications to detect failures fast.

5 min read · core · beat Gold to climb

Two primitives that pair well

Coordination services give clients two powerful tools. An ephemeral node exists only while its creator stays connected. A watch is a one time subscription that fires when a specific node changes or disappears.

Detecting liveness

Because an ephemeral node disappears when its client session ends, its mere presence proves the client is alive. A service can register itself by creating an ephemeral node at a known path. Other clients set a watch on that path and learn instantly when the service goes away.

  • The owner creates an ephemeral node tied to its session.
  • Observers watch the node for deletion.
  • When the session ends, the node is removed and watchers are notified.

The catch with watches

A watch fires once and then must be re registered. Between the fire and the re registration, more changes can happen. Good clients always re read the current state after a watch fires rather than trusting the notification to carry the data.

Key idea

Ephemeral nodes prove liveness and watches deliver fast change notifications, but because a watch fires only once, clients must re read state and re register the watch each time.

Check yourself

Answer to earn rating on the learn ladder.

1. Why does an ephemeral node prove liveness?

2. What is a key limitation of a watch?

3. How does a client learn a service died quickly?