by theamk · 6y ago · 0 comments
> How do I determine how many messages are in queue?
> This isn't possible. [...] rather than provide incorrect information the library avoids providing any view into this data.
> How can I retrieve a list of all connected peers?
> This is not supported.
Those kinds of decisions are very scary for production environment. We've had to debug network connectivity problems before, and it just possible what all the interfaces Linux kernel provides. I cannot imagine doing it with library which hides stuff from you on purpose.
> At any given time a message may be in the ZeroMQ sender queue, the sender's kernel buffer, on the wire, in the receiver's kernel buffer or in the receiver's ZeroMQ receiver queue. Furthermore, a ZeroMQ socket can bind and/or connect to many peers. Each peer may have different performance characteristics and therefore a different queue depth. Any "queue depth" number is almost certainly wrong
The library doesn't hide stuff from you, it just refuses to show you information that might as well be a random number.
If you want to know how many peers are connected you use heartbeats instead of just blindly trusting that 1 tcp socket = 1 available peer.
How do you know my circumstances? Maybe this system has tuned rmem_max/wmem_max so I don't care about kernel buffers? Maybe my programs have problems with multi-gigabyte queues? Why are you assuming stuff for me?
The right answer of course is you don't expose a single "queue size" value, but you don't hide it either. Instead, expose something like "list of sockets: for each, here is an fd and a size of userspace queue". I'll then query the kernel myself to get sender's and receiver's kernel buffer size and so on.
Life is hard enough without libraries hiding stuff from you!
Edit: just checked the FAQ and apparently it will now block or drop messages. I sort of wish it would explicitly error instead of block, so as not to require the caller to queue in a thread or something.
Setting up a monitor socket allows you to observe pretty much any event you could care about, like peer connect/disconnect/errors, etc.
There is also a draft feature to access the number of queued incoming/outgoing messages (see https://github.com/zeromq/libzmq/blob/master/doc/zmq_socket_... for details).
Other than that, great piece of software.
[0] - https://lucumr.pocoo.org/2012/6/26/disconnects-are-good-for-...