[zeromq-dev] Is zmq suitable for p2p protocols?

Pieter Hintjens ph at imatix.com
Fri Apr 13 10:49:24 CEST 2012

On Thu, Apr 12, 2012 at 9:39 PM, Jorge Timón <timon.elviejo at gmail.com> wrote:

> Hi, we're discussing some things about a distributed protocol in the
> ripple forum and I proposed to use ZeroMQ to build a prototype server.
> We want the p2p protocol to be transport independent but we're going
> to probably just use TCP as a start.

If you start by using TCP, you're really painting yourself into a
corner for no reason. The only plausible case for using TCP instead of
0MQ is interoperability with existing protocols.

We use 0MQ very successfully in p2p protocols. Indeed without 0MQ we'd
have had a really hard time. The project is still confidential but I
can explain how we did it. YMMV.

First we built a basic chat client/broker over 0MQ; this is a day or
so of work. Simple unprotocol for IRC-like chat.

Then over time we built out-of-band discovery (in our case using UDP)
and removed the broker. Every node cross-connects to every other one.
For larger-scale networks you'd use supernodes I assume.

Then we added layers like file transfer, heartbeating, etc.

The trick is to start simple and make one change at a time, rather
than trying to design the "real thing" from scratch. This iterative
approach is dead simple with 0MQ and incredibly hard with raw TCP.
There's a lot of material on my unprotocols.org blog about how this
process works.


More information about the zeromq-dev mailing list