Search code examples
zeromqmessaging

What are down sides of using ZeroMQ for sending large messages (up to gigabytes)?


I found that people don't recommend sending large messages with ZeroMQ. But it is a real headache for me to split the data (it is somewhat twisted). Why this is not recommended is there some specific reason? Can it be overcome?


Solution

  • Why this is not recommended?

    Resources ...

    Even the best Zero-Copy implementation has to have spare resources to store the payloads in several principally independent, separate locations:

    |<fatMessageNo1>|
    |...............|__________________________________________________________ RAM
    |...............|<fatMessageNo1>|
    |...............|...............|__________________Context().Queue[peerNo1] RAM
    |...............|...............|<fatMessageNo1>|
    |...............|...............|...............|________O/S.Buffers[L3/L2] RAM
    

    Can it be overcome?

    Sure, do not send Mastodon-sized-GB+ messages. May use any kind of an off-RAM representation thereof and send just a lightweight reference to allow a remote peer to access such an immense beast.


    Many new questions added via comment:

    I was concern more about something like transmission failure: what will zeromq do (will it try to retransmit automatically, will it be transparent for me etc). RAM is not so crucial - servers can have it more than enough and service that we write is not intended to have huge amount of clients at the same time. The data that I talk about is very interrelated (we have molecules/atoms info and bonds between them) so it is impossible to send a chunk of it and use it - we need it all)) – Paul 25 mins ago

    You may be already aware that ZeroMQ is working under a Zen-of-Zero, where also a zero-warranty got its place.

    So, a ZeroMQ dispatched message will either be delivered "through" error-free, or not delivered at all. This is a great pain-saver, as your code will receive only a fully-protected content atomically, so no tortured trash will ever reach your target post-processing. Higher level soft-protocol handshaking allows one to remain in control, enabling mitigations of non-delivered cases from higher levels of abstractions, so if your design apetite and deployment conditions permit, one can harness a brute force and send whatever-[TB]-BLOBs, at one's own risk of blocked both local and infrastructure resources, if others permit and don't mind ( ... but never on my advice :o) )

    Error-recovery self-healing - from lost-connection(s) and similar real-life issues - is handled if configuration, resources and timeouts permit, so a lot of troubles with keeping L1/L2/L3-ISO-OSI layers issues are efficiently hidden from user-apps programmers.