[zeromq-dev] Configuration help requested

Kenneth Adam Miller kennethadammiller at gmail.com
Fri Mar 6 18:44:11 CET 2015

Well, if your HEAD is immediately receiving the next client request, by
what mechanism will it know to which client to send the final response?
Like, say in sequence that the head receives requests from two different
clients, and forwards them out. There's not actually any guarantee that two
links in the chain, even if proximal, will receive the messages sent in the
order you mean them. So the HEAD could get back the finished request for
the second client, but how will it know to route the response to the client

It's not hard at all to forward the address around from the original
client, with router sockets, when you receive, your first message part in a
ZMQ_RCVMORE call is the client address. Just use ZMQ_SNDMORE in your push
sockets to bounce that client address around. When it gets back to head
from the tail, and you call send on the original router socket you received
the address, the address that it originally read out is the first part on a
ZMQ_SNDMORE send done on that router socket. This way, no matter what you
do with the chain logic or whatever it wont matter; it will act as a
request reply to the client.

On Fri, Mar 6, 2015 at 12:34 PM, Larry White <ljw1001 at gmail.com> wrote:

> Hi Kenneth, Thank you. Some comments/questions below.
> On Fri, Mar 6, 2015 at 11:59 AM, Kenneth Adam Miller <
> kennethadammiller at gmail.com> wrote:
>> What if instead of sending from the tail, you just used a push socket
>> that the head could wait on in a loop. The REP socket could send a reply to
>> the client immediately after having received from the tail on a pull
>> socket. In this way, you still get what you want, and don't have to deal
>> with the idea of maintaining addresses to send to the tail in order that
>> they be sent to the right destination.
> i think this might work, but seems as complex as forwarding the addresses.
> I guess I was under the impression that this kind of forwarding loop
> architecture was straightforward in ZeroMQ.
>> Another cool idea that might be of interest to you is the idea that
>> mutiple requests can be concurrently processed in the chain, with the head
>> accepting and forwarding as many as can be read on the socket. In this way,
>> the entire system isn't waiting as I implied above; you have higher
>> throughput this way, because that's less time spent doing nothing but
>> waiting. In any case, I think the way to do this would be to use a router
>> socket at the head, and forward the address from the original client around
>> through your chain. When that address gets back use it to send on the
>> router socket.
>> This is why I was using the PUSH socket between links. If I understand
> these sockets correctly, a link can work as quickly as possible, push work
> for the next link, then start working on its next request.  This should
> maximize the throughput of the chain, I think, as the only thing that's
> blocking are the clients.
>> On Fri, Mar 6, 2015 at 11:47 AM, Larry White <ljw1001 at gmail.com> wrote:
>>> Hi,
>>> I'm trying to implement "chain replication" using 0MQ, and need help
>>> configuring the system.
>>> In chain replication, you have n clients and a sequence of server
>>> replicas. The replicas are updated in order from HEAD to TAIL.  A three
>>> link chain works in a loop like this:
>>> 1. CLIENT sends write request to HEAD
>>> 2. HEAD processes request and forwards to MIDDLE (No reply to client)
>>> 3. MIDDLE processes request and forwards to TAIL
>>> 4. TAIL processes request and sends a reply back to CLIENT.
>>> I would like the interaction between CLIENT and the chain to be
>>> synchronous (blocking), so that the client waits until it receives the
>>> reply from TAIL.
>>> I tried to set this up with head having a REP socket for client and a
>>> PUSH socket for the chain. This causes an exception (obvious in hindsight)
>>> that says
>>> java.lang.IllegalStateException: Cannot receive another request
>>> What is the correct way to do structure the relationship between Client
>>> and Head?
>>> Thank you very much for your help.
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150306/f4b9fad4/attachment.htm>

More information about the zeromq-dev mailing list