[zeromq-dev] Inter thread communication for scalability

Kenneth Adam Miller kennethadammiller at gmail.com
Sat Jan 18 00:06:33 CET 2014


On Fri, Jan 17, 2014 at 4:35 AM, Goswin von Brederlow <goswin-v-b at web.de>wrote:

> On Thu, Jan 16, 2014 at 09:11:48PM -0600, Kenneth Adam Miller wrote:
> > On Wed, Jan 15, 2014 at 8:36 AM, Goswin von Brederlow <goswin-v-b at web.de
> >wrote:
> > > All those threads get confusing. Lets draw a picture:
> > >
> > >
>  +--------------------------------------------------------------------+
> > >    |
>  |
> > >    v
>  |
> > >  Pool A          Thread Set 1         Router X
>  |
> > > PULL-PUSH --==> PULL-read-PUSH ==--> PULL-PUSH --==> PULL Thread Set 2
> PUSH
> > >                                                          \            /
> > >                                                           +-compress-+
> > >                                       Pool B             /            \
> > >                                      PULL-PUSH --==> PULL
>  PUSH
> > >                                       ^
>   ||
> > >                                       |
>   ||
> > >                                       +----------- PUSH-write-PULL
> <--==++
> > >                                                       Thread 3
> > >
> > >
> > So, I believe this is pretty close, but if I'm right, but you created a
> > router to deal with a N-M situation, when in actuality a slightly
> different
> > configuration is needed in order to make that work. I could be
> > understanding this wrong, but after I looked at the examples some more, I
> > think things started to finally click. I think the multi-threaded example
> > given in the manual that used a router and a dealer required that the
> > sockets be of type REQ and REP in order to work. I don't think that PUSH
> > and PULL is, at least not according to the reference guide on zmq_socket.
> > Is that correct? I'm pretty sure that the only thing that you got wrong
> is
> > to illustrate that router takes requests in from thread set 1 and
> shuttles
> > them out to thread set 2 as replies.
>
> I just called the thread router because it routes messages from Thread
> Set 1 to Thread Set 2. I didn't use a ROUTER/DEALER  socket for it as
> I believe the guide has for its router example.
>
> But that is because the other endpoints are PUSH and PULL so messages
> go strictly one way and I only need PULL and PUSH to complement them
> in the router thread. On the other hand I'm fairly new to zmq, too. So
> I could be wrong.
>
> MfG
>         Goswin
>

Oh awesome, thanks!
Ok, so last question-I think now that I'm actually implementing what you
drew that request reply is actually the design that I want; because any
time a thread group needs a resource, it should be able to request it that
way the other can know to send it. Is this the right way to go about it?
Because I was actually going to make a request pattern with PUSH and PULL
and realized that if I did that, that I had no guarantee that the reply
would get sent back to the sender. If I didn't have a pattern that would
allow me to send a resource back to a requesting thread, then I would have
to flush the thread groups' PULL sockets with handles, and I would have no
way to know if even the number that I flushed in there was enough to
satisfy their needs. It could result in performance degradation.

> _______________________________________________
> 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/20140117/c4768a20/attachment.htm>


More information about the zeromq-dev mailing list