grpc and zeromq comparsion


Zeromq Problem Overview

I'd like to compare somehow capabilities of grpc vs. zeromq & its patterns: and I'd like to create some comparsion (feature set) - somehow - 0mq is "better" sockets - but anyways - if I apply 0mq patterns - I get comparable 'frameworks' I think - and here 0mq seems to be much more flexible ...

The main requirements are:

  • async req / res communication (inproc or remote) between nodes
  • flexible messages routing
  • loadbalancing support
  • well documented

any ideas?


Zeromq Solutions

Solution 1 - Zeromq

  • async req / res communication (inproc or remote) between nodes

Both libraries allow for synchronous or asynchronous communication depending on how to implement the communication. See this page for gRPC: Basically gRPC allow for typical HTTP synchronous request/response or a 'websocket-like' bidirectional streaming. For 0mq you can setup a simple REQ-REP connection which is basically a synchronous communication path, or you can create async ROUTER-DEALER type topologies.

  • flexible messages routing

'Routing' essentially means that a message gets from A to B via some broker. This is trivially done in 0mq and there are a number of topologies that support stuff like this ( In gRPC the same sort of topology could be created with a 'pub-sub' like connection over a stream. gRPC supports putting metadata in the message ( which will allow you to 'route' a message into a queue that a 'pub-sub' connection could pull from.

  • loadbalancing support

gRPC has a health check support ( but because it's HTTP/2 you'd have to have a HTTP/2 load balancer to support the health check. This isn't a huge big deal, however, because you can tie the health check to a HTTP/1.1 service which the load balancer calls. 0mq is a tcp connection which means that a load balancer would likely check a 'socket connect' in tcpmode to verify the connection. This works but it's not as nice. Again you could get slick and front-end the 0mq service with a HTTP/1.1 webserver that the load balancer reads from.

  • well documented

both are well documented. 0mq's documentation must be read to throughly understand the technology and is more of a higher lift.

Here's the big differences:

  1. 0mq is a tcp protocol whereas gRPC is HTTP with a binary payload.
  2. 0mq requries you design a framing protocol (frame 1 = verison, frame 2 = payload, etc.), whereas much of this work is done for you in gRPC
  3. gRPC is transparently coverted to REST ( whereas 0mq requires a middleware application if you want to talk REST to it.
  4. gRPC uses standard tls x509 certificates (think websites) whereas 0mq uses a custom encryption/authentication protocol ( Prior to 4.x there was no encryption support in 0mq and if you really wanted it you had to dive into this crap: (trust me don't do it)
  5. 0mq can create some pretty sick topologies ( ( whereas gRPC is basically client/server
  6. 0mq requires much more time to build and get running whereas gRPC is basically compiling a protobuf messages and importing the service into your code.

Solution 2 - Zeromq

Not quite the same. gRPC is primarily for heterogeneous service interoperability, ZeroMQ (ZMQ/0MQ/ØMQ) is a lower level messaging framework. ØMQ doesn't specify payload serialization beyond passing binary blobs whereas gRPC chooses Protocol Buffers by default. ØMQ is pretty much stuck on the same machine or machines between datacenters/clouds, whereas gRPC could potentially work on a real client too (ie mobile or web, it already supports iOS). gRPC using ØMQ could be significantly faster and more efficient for in-cloud/-datacenter services than the overhead, latency and complexity of http2 request/response chain. I'm not sure how (or even if) gRPC TLS security is adequate for public cloud and mobile/web usage, but one could always inject end-to-end security requirements (ie libsodium) at the router/controller level of the app/app framework and run in plaintext mode (which would also remove OpenSSL fork BoringSSL from causing maintenance headaches because of upstream flaws).

For very high latency / low bandwidth services (ie mission to mars), one would think about RPC using a transport like SMTP (ie Active Directory alternate replication) or MQTT (ie Facebook Messenger, ZigBee, SCADA)

Bonus (off-topic): It would be nice if gRPC had alternate pluggable transports like ØMQ (which also itself supports UNIX sockets, TCP, PGM and inproc), because HTTP/2 isn't stable in all languages yet and it's slower than ØMQ. And, it's worth looking at nanomsg (especially in the HFT world) because it could be extended with RDMA/SDP/MPI and made crazy low-latency/zero-copy/Infiniband-ready.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3169252View Question on Stackoverflow
Solution 1 - ZeromqascotanView Answer on Stackoverflow
Solution 2 - Zeromquser246672View Answer on Stackoverflow