Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zmq vs redis for pub-sub pattern

redis supports pub-sub
zmq also supports pub-sub via a message broker

What would be the architectural pros\cons for choosing between them?
I'm aiming at points which are beyond the obvious use-case specific performance benchmarking that should be done (here's a nice example).

Assume use of a high-level language such as Python.

like image 809
Jonathan Livni Avatar asked Sep 03 '13 12:09

Jonathan Livni


People also ask

Is Redis Pub/Sub reliable?

Its not pub sub, its more reliable since your consumer can be offline and the messages will queue up instead of being lost.

How fast is Redis Pubsub?

Redis Pub/Sub is designed for speed (low latency), but only with low numbers of subscribers. Subscribers don't poll and while subscribed/connected are able to receive push notifications very quickly from the Redis broker — in the low milliseconds, even less than 1 millisecond as confirmed by this benchmark.

Is Redis Pub/Sub persistent?

No - Redis' Pub/Sub has no persistence, and once a message has been published, it is sent only to the connected subscribed clients.


2 Answers

I have worked with both ZeroMQ and Redis with python. I would say ZeroMQ is more robust, it offers real simple load balancing and also more than pub-sub, like request reply among others. But if you are only after pub-sub, redis is much simpler.

In case the redis server crashes or stops working, all the clients will stop working as well, with ZeroMQ, the clients work even if there is no server.

Both services are available with any programming language, ruby, python, C, C++ and more.

In short, redis is much simpler, very reliable. ZeroMQ is extremely reliable but more complex.

If I was only doing pub sub, I would pick redis, else I would pick ZeroMQ. If I would forsee huge loads of traffic, I would pick ZeroMQ

like image 106
Trausti Thor Avatar answered Sep 24 '22 14:09

Trausti Thor


ZeroMq Pros/Cons

  • Pub/sub peers can connect and disconnect independently; messages are saved to buffers based on HWM settings, automatically sent upon peer availability (store-and-forward)
  • If a peer fails, buffered messages will be lost
  • Topic subscriptions support prefix matching with pub/sub enveloping only; NEWS subscription matches NEWS* messages

Redis Pros/Cons

  • AOF snapshotting to disk persists messages in the event redis fails
  • Pub/sub clients depend on redis for connectivity
  • Wildcard matching for selective topic subscriptions like news.* supported
like image 23
raffian Avatar answered Sep 22 '22 14:09

raffian