[zeromq-dev] PUSH/PULL - Queue sizes and Disconnecting from endpoints

David Henderson david.henderson at triggeredmessaging.com
Mon Oct 24 18:19:02 CEST 2011


Hi,

I've got a few zmq questions after playing around with it for a few weeks

A bit of background...

I'm using the node.js library throughout the system.

I have a number of frontend web servers taking requests that should be
written to the database (referred to as TOP).
As the node.js library doesn't (that I could find) have the
pre-defined devices available (so can't use the streamer). In its
place, I have a PULL socket bound to one port, and a PUSH socket bound
to another port. When PULL receives a message, it immediately sends it
onwards using the PUSH socket. (I'll refer to this layer as MIDDLE)
The last layer (referred to as BOTTOM) does the writing to the database.

The intention is to approximate the Pipeline pattern, but with well
known MIDDLE nodes that the other layers connect to
Both TOP and bottom connect() to each of the MIDDLE nodes, so load
balancing happens between nodes.

The system looks something like this: https://gist.github.com/1309400


This, in theory, should allow us to add nodes at the TOP and BOTTOM
layers at will to get the scalability we need.

Questions:

- How can I get visibility of the queues/buffers at each level? I'm
currently logging out the send backlog on the PUSH sockets, which is
mildly useful, but I have found that messages seem to build up
elsewhere in the system (TCP buffers, I guess)

- If I do detect that one of the MIDDLE nodes is becoming overloaded,
I'd ideally like to introduce a new node or two at that level (which I
can do fine by having TOP and BOTTOM nodes connect() to it).
Once I have the new nodes, I would like to disconnect the TOP nodes'
socket from the overloaded MIDDLE node.
The only way I can currently see to do this is to completely tear down
the TOP sockets, re-instantiate and connect only to the good nodes.
Is there a better way to achieve this? Something like a
drain_and_disconnect() method that removed and endpoint from the
available endpoints being load-balanced, sent any messages already in
send buffers, then completely disconnected from the endpoint.
Is this already possible or feasible for a future release?


Thanks,
Dave Henderson



More information about the zeromq-dev mailing list