[zeromq-dev] Async Client/Server problem
Kalantari Babak
BABAK.KALANTARI at psi.ch
Thu Apr 18 11:08:30 CEST 2013
Hi,
I am a 0mq newbie. I have the follwoing problem in hand:
I have several client nodes (machines) and one server node.
A client node:
consists of several threads. A thread (say, requester thread) sends a request and waits (blocks) immediately to receive the reply for that request. So a request has always a reply. The reply may take arbitrarily long to arrive keeping the requester blocking.
Server node:
consists of many worker threads. A worker receives a request, does something with it and eventually (may take arbitrarily long) sends a reply back to the requester.
This is a classical problem. I need that the requester (client thread) receives his own reply, of course. I would like to have only one tcp connection between a client node and the server.
I have read "Asynchronous Client/Server Pattern" example in 0mq guide. The server side seems to be exactly what I need: [ ROUTER <-> Sevrer <-> DEALER <-> DEALER <-> Worker ].
The client side however is not what I want since each client thread has to use a DEALER which directly conncects to the server node by a tcp connection. So I am thinking of two possible solutions for the client side but I want to learn your opinon before I dig in to the coding:
Client-side solution 1: [ requester <-> DEALER <-> ROUTER ] this ends up with a ROUTER to ROUTER between client node and server node via a tcp.
Client-side solution 2: [ requester <-> DEALER <-> ROUETR <-> DEALER ] this ends up with a DEALER to ROUTER between client node and server node via tcp plus local DEALER to ROUTER connectins between requester threads and the ROUTER.
I am not sure about correctness of solution 1; solution 2 looks more reasonable but also more complex. Or maybe there are better solutions??
Every comment or advice is appreciated.
Regards,
Babak
More information about the zeromq-dev
mailing list