[zeromq-dev] RPC design pattern
B.Candler at pobox.com
Mon Apr 19 10:47:37 CEST 2010
On Sun, Apr 18, 2010 at 12:54:12PM +0200, Martin Sustrik wrote:
> >The API docs don't make it clear what happens if you call zmq_connect
> >multiple times on the same socket.
> Yes, you pretty much right.
> You can connect your client to multiple instances of a service:
> zmq_connect (c, "tcp://svr001.example.com:5555");
> zmq_connect (c, "tcp://svr002.example.com:5555");
> zmq_connect (c, "tcp://svr003.example.com:5555");
> What happens is that the requests are load balanced among the servers.
I see - so rather than connecting to one of the endpoints, it connects to
all of them simultaneously. Thanks.
I think there's a use case for the other model too. For very large numbers
of clients (N) and servers (M) it could scale better if each client picked
one endpoint. Each server would only have to handle N/M connections on
OTOH, unless there is sufficient churn in the client base, once a server has
gone down and come back up again it may take a long time before it picks up
its share of the load again.
Churn can be forced server-side if necessary, by booting off clients after a
certain number of messages or a certain amount of time.
More information about the zeromq-dev