Sending same message to a list of servers
Kalki70 opened this issue · 0 comments
Hello,
To anyone reading this. I came up with a problem and can't find the right pattern to implement a solution, PUSH/PULL, PUB/SUB, etc.
I need to send the same message to a list of remote servers. Basically the idea is to monitor some processes on remote machines, asking for some statistics. This really look like a PUB/SUB model, where the monitor application publish requests like "tell me the total number of type X messages processed on the last 10 minutes", and the remote processes that are up and running may respond. If some of them are down for maintenance, or crashed, they will simply not receive the message and not respond. That sounds perfect, BUT:
The remote processes to be monitored have no idea to where to connect to in order to start the subscription. I could start the monitor application on my laptop, it could run on a workmate's laptop, on a dedicated server or desktop for an administrator, etc. Also, there could be more than one instance of the monitor application. Also, the remote servers needs to answer back those messages, with the results.
I thought that the monitor application could start PAIR connections to a list of remote processes and just send messages to all of them on a loop, receiving from the same sockets. Not elegant design and also I realized that PAIR is to be used to couple threads and not to be used over the network, so I discarded the idea.
I thought I could start PUSH/PULL connections one by one, so the first sent message could have the "callback address" to where to connect back to answer, but then if the remote processes crashes and restarts, the client will have no idea about the reconnection and will not send the "callback address". I thought about this model mixed with the PUB/SUB, like connect to the remote server and tell "connect back a SUB socket to this address, to receive requests, and a PUSH socket to this other, to answer me back", but it is always the same problem. As the PUSH client can't detect reconnection, it does not know when to send the first message with the addresses.
I have ZeroMQ working great on a production system, with load balancing across servers, etc, but because all processes know their peers by configuration.
I see it would be a wonderful add-on to the PUSH/PULL PUB/SUB models if the client could connect to a list of remote servers and PUSH messages with load balancing (creating many connecting sockets instead of binding, but looking as one to the developer) or to PUB messages to all of them instead.
Anyway, does anyone have an idea about how to solve my problem?