0MQ, or ZeroMQ, is message-passing middleware designed to be scalable, simple to include in your app (many language bindings), and above all else FAST. I'd recommend using ZeroMQ and not the low level Berkeley socket interface or a high level messaging system because it gives users the flexibility and performance of the low level while still having the ease of implementation of the high level. Also, maintaining raw sockets is difficult and cumbersome when you want to implement a scalable system. A high level system often works perfect if you use it for the situation it was designed for, but it can be difficult to change core elements of the system and its ease of use often comes with a cost in performance.
FAST
See some of these benchmarks in this scipy talk. Here is one example using the python language bindings, PyZMQ:
Easy to use
Using 0MQ amounts to three things:
Easy to use
Using 0MQ amounts to three things:
- Choose a transport
- Set up the infrastructure
- Select a messaging pattern
import zmq
c = zmq.Context()
s = c.socket(zmq.REP)
s.bind('tcp://127.0.0.1:10001')
s.bind(‘inproc://myendpoint’)
while True:
msg = s.recv()
s.send(msg)
Where I (1) create a context, (2) create a socket type, (3) pick one or more transports, and (4) call socket.send and socket.recv. In actuality 0MQ provides 4 different transports:
- INPROC an In-Process communication model
- IPC an Inter-Process communication model
- MULTICAST multicast via PGM, possibly encapsulated in UDP
- TCP a network based transport