Zenoh distributed communication
Zenoh is a distributed communication system for moving data between applications.
It is useful when you need pub/sub, queries, storage, and communication across different machines or networks.
You can think about Zenoh as a data-centric communication layer:
- publishers write values to keys
- subscribers receive updates for keys they are interested in
- queries can ask for data
- storages can keep the latest values
- routers can connect distributed nodes
Zenoh is often interesting for robotics, IoT, edge systems, distributed applications, and systems that need efficient communication without building a custom protocol from zero.
Core idea
Zenoh uses key expressions.
A key looks like a path:
A publisher writes data to a key.
A subscriber listens to a key or key pattern.
Example pattern:
This can match many keys under robot/.
Install Python package
Install the Python package:
Minimal pub/sub in one Python application
This example runs a subscriber process and a publisher process from one Python file.
Create pub_sub_demo.py:
Run:
Expected output:
What happens
The publisher opens a Zenoh session and declares that it will publish on:
The subscriber opens a Zenoh session and subscribes to:
Because demo/robot/counter matches demo/robot/**, the subscriber receives
the published samples.
The example uses two processes because it behaves like two independent applications, but still lets you run the demo from one command.
The payload is received as Zenoh bytes. In Python, use:
to convert the payload to a string.
When to learn Zenoh
Learn Zenoh when your project needs:
- pub/sub communication
- distributed nodes
- machine-to-machine data exchange
- robot or IoT telemetry
- data routing between networks
- queries over distributed data
- storage of latest values
Topics to learn next
Important Zenoh topics:
- key expressions and wildcards
- publishers and subscribers
- query and queryable
- routers
- peer-to-peer vs routed deployment
- configuration files
- transports
- access control and authentication
- storage plugins
- bridging Zenoh with other systems