I have a working application using python and zeromq and I would like to optimize it.
Briefly, a master node send the same request to all workers (about 200) and the then collect the answers. Based on the answer, it sends a message back to one node and the node answers back.
Right now I implemented a very simple pattern. Each worker has one REP socket and the server has a list of REQ sockets. The server iterates through all sockets sending the general message and then iterates through all sockets to collect the answers. Finally, based on the answers the server picks one worker, sends a message to it and waits for the reply.
This is, of course, quite slow. The slowest part is sending 200 times the same message. Collecting is also slow. The solutions that I have found to distribute tasks and collect answers do load balance which is not what I need. I need that each worker receives the message and responds.
What is the pattern recommended for this situation?
Thanks
I don’t know zmq. Here’s a pattern that might not work, just to get started:
master PUB bind *:3140 send
worker SUB connect masterhost:3140 SUBSCRIBE recv
worker PUSH connect masterhost:3141 send
master PULL bind *:3141 recv
master REQ connect workerhost:3142 send recv
worker REP bind *:3142 recv send