[zeromq-dev] REQ/REP for possibly async comm?

Justin Karneges justin at affinix.com
Tue Mar 27 01:08:49 CEST 2012


I wondered about this as well.  I want to make a worker that does remote 
method calls, and it would expose a REQ/REP interface that other workers would 
use whenever they want to make a remote call.

Since the work bottleneck is time (waiting for remote server responses), I'd 
prefer the worker use asynchronous sockets rather than waste many threads on 
synchronous sockets that spend the majority of their time idle.  However, I 
also want to be able to respond to requests out of sequence (e.g. receive 
requests A, B, but then respond to B before A), and I think this breaks the 
REQ/REP pattern.

On Monday, March 26, 2012 03:21:08 PM Andrei Zmievski wrote:
> I have two processes that need to exchange data. Process A has to perform
> time-critical work, but also needs to obtain some configuration data from
> process B. Initially, I considered using REQ/REP sockets since it's a
> roundtrip query, doing something like on A:
> 
> initialize work unit
> if (previously sent request)
>    check response from B
>    if (still no response after 30 seconds)
>       send config request
> else
>    send config request
> finish work unit
> 
> The problem I see with REQ/REP is that they work in lockstep and that B may
> not reply in a reliable fashion. Thus, I wouldn't be able to send a new
> config request until I heard back from B.
> 
> Is it better to switch to PUB/SUB or DEALER/REP scheme here?
> 
> -Andrei



More information about the zeromq-dev mailing list