[zeromq-dev] REQ to many REP.
Steve Murphy
murf at parsetree.com
Tue Jun 24 02:22:33 CEST 2014
On Mon, Jun 23, 2014 at 2:24 PM, Riskybiz <riskybizlive at live.com> wrote:
> I’d like to set up a 0MQ REQ-REP arrangement where there are many REP
> sockets connected to just one REQ socket. The actual number of REP sockets
> is unknown at design-time; however at run-time a list of the port addresses
> will be provided to the code running the REQ socket.
>
So, many possible "servers" (which answer requests), one client (which
makes requests).
If you look at the Guide, around figure 15, you'll see that one client
with a REQ socket,
can connect to multiple servers (each a REP socket), and the requests will
be "round-robined" by the zmq layer,
to each server in turn.
Your client can connect to as many servers as you desire, but you have to
know where the servers
are, so you can connect to them!
The opposite, many clients to a single server, runs about the same way, and
is a common
situation in most datacenters, Incoming requests are "round robined", to
make sure no client
gets preferential treatment.
>
> What I’d like is that, somehow, the code running the solitary REQ socket
> will loop through the list of port addresses and connect to the multiple
> REP sockets as they bind and become available. Subsequently the REQ socket
> would work with (poll??) the established connections to send and receive
> messages as necessary.
>
>
>
> It’s the first time I’ve tried this. Looking at the zmq_poll reference in
> the manual http://api.zeromq.org/3-2:zmq-poll it’s unclear to me whether
> I can handle variable number of connections in an iterative manner. For
> example in: http://zguide.zeromq.org/cpp:mspoller the poll set is hard
> coded.
>
Poll just tells you when a socket has I/O. The underlying zmq library will
hand you the next proper
request, from one of the servers. If you are a client, the next proper
server will see the incoming
request, and the library will get its response back to the client.
>
> Another question is can a REQ socket handle multiple connections? How
> best could a message be routed to the desired destination REP socket? Is
> some more advanced pattern necessary here ROUTER, BROKER??
>
Yes, when multiple clients want to talk to a pool of multiple servers,
then you need the broker,
implemented with ROUTER/DEALER sockets. see Figure 16 in the Guide.
>
>
> What I’m trying to achieve is a REQ-REP flow to act as a command/control
> layer which will coordinate a PUSH-PULL socket pair. There will be a
> run-time flexible number of PUSH sockets but always just one PULL socket.
>
I'm not quite clear on the nature of the push/pull, and how it relates to
the req-rep, but
I don't have to be. You do. Read the Guide, and you'll start to see how
things fit together
better, what the library can do for you, and what you'll have to do on your
own.
>
> Is anyone able to offer any guidance to clear my muddy thoughts on how to
> make this work? Am coding in C++.
>
>
> With thanks,
>
>
>
> Riskybiz.
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
--
Steve Murphy
ParseTree Corporation
57 Lane 17
Cody, WY 82414
✉ murf at parsetree dot com
☎ 307-899-5535
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140623/34effa37/attachment.htm>
More information about the zeromq-dev
mailing list