To increase or not increase the number in ZeroMQ

I am developing a server application that will talk about ZeroMQ. Without going into detailed details, the server will store and serve (from request requests) (eventid, eventstring) tuples.

My questions are about wired protocol design. I would like to send my tuple from one end to the other. I see two options:

  • Serialize my tuple (using protobuf or something else) and send it as a single message.
  • Send my tuple as a multi-page message; the first part contains eventid, and the second contains eventstring.

Is any of these two options better than the others? Reading The ZeroMQ Guide , there is in the chapter "Advanced Request-Response Templates" , which reuse multi-part message envelopes. Does this mean that I, as a user, should try to adhere to a single message in order to create more advanced message templates in the future?

+4
source share
2 answers

The manual describes serialization:

http://zguide.zeromq.org/page:all#Serializing-Your-Data

Your case with two fields is so trivial that it doesn't matter IMO what format you use while it works.

+2
source

I recommend looking at the wired protocol for the Majordomo protocol . This example shows that each β€œfield” in the structure is sent as a separate frame. This works very well and is well supported.

You can also define a byte layout and send your data as a single frame. You will need to solve any problems with endian (if you use the code on platforms that are small and large), but this is quite easy to handle. If you do not know how to do this, use a frame technique, for example, Majordomo.

There will be little performance between using a frame and multiple frames. If you don't send gigabits per second, this is unlikely to be a problem. As always, a guideline for measuring your specific case before you β€œoptimize” and spend a ton of time and effort saving 200 nanoseconds per message.

+1
source

All Articles