[zeromq-dev] Architectural question: REP/REP vs. PUB/SUB

gonzalo diethelm gdiethelm at dcv.cl
Mon Aug 30 22:30:19 CEST 2010


I will have one central data server process that will be able to provide
information on request ("give me the Customer with id=55") and to update
it ("insert a new Customer with this info", "change birth for Customer
with id=66 to 22/apr/1990", "delete Customer with id=77", etc.). All
changes to the data in my data server are first replicated to an
underlying RDBMS.

Since there might be other nodes interested in any changes to the data,
each time the data server applies a change it sends out (after
committing to the RDBMS) a notice on a PUB socket, to which any node
which is interested can connect using the appropriate SUB socket and
topic.

All along I have thought that the node that is requesting an actual
change to be done on the data server will do so over a REQ/REP socket;
it seemed to me that asking for changes in a synchronous way was
"safer", for some definition of "safe", of which I am not so sure
anymore...

Please share with me any thoughts you might have regarding these
questions.

1) I have just realized that the node requesting a change could also be
subscribed to receive the change notifications from the data server on a
SUB socket. This being so, I am left wondering if it still makes sense
to have a REQ socket to ask for a change, or whether I should use a PUSH
socket and wait for notifications on the SUB socket, making the whole
thing asynchronous; I must confess this feels more "right", since it
agrees with my generic architectural principles. I could even have more
that one simultaneous request on the wire at the same time, should I
choose to do so.

2) Is it "safe" to do PUB/SUB over a "tcp://" endpoint, or should I be
looking at one of the multicast protocols? Does it simply come down to
network bandwidth usage? Is there any case when tcp would be preferable
for a PUB/SUB socket?

3) I think I can take care of any timing issues (such as delays
connecting the PUB/SUB sockets) if my client first sends a "client
coming up" message down the PUSH socket and waits until it gets a
"everything is ready for you" message on the SUB socket (probably with a
UUID to pair the two). Right?

Thanks in advance and best regards.

-- 
Gonzalo Diethelm 




More information about the zeromq-dev mailing list