The problem

How does ZK know when the service provider has hung up? How to notify service consumers?

How does ZK know that the service provider has hung up?

The core idea is that when the service provider dies, the node is automatically deleted.

This node is called a temporary node.


Node classification 1. Temporary node 2. Non-temporary node


Temporary nodes, which can only be leaf nodes.


How to notify ZK in real time when the service provider is down, instead of being notified after 1 heartbeat?

Because it is a temporary node, the temporary node data is automatically deleted.

How does ZK notify service consumers?

Based on Watch notifications.

When the client is down, temporary nodes are automatically deleted.

Proactively notify service consumers of data changes.


Design patterns

Event listening mode, one-to-many broadcast.


Architecture diagram