Here is what I am trying to achieve -
A REST service (deployed on multiple instances) gets a request, processes it and passes it on to a fleet of worker instances.
The worker does the bigger chunk of work, prepares the response and sends it back.
The main service in the mean time has finished some more work related to the original request, merges that with the worker response and sends it back to caller on the request connection.
How can I model this through ZMQ?
I have tried doing this - - create a PUSH socket and do a "bind" in the service instance. - workers "connect" to the corresponding PULL socket. - Since the same service instance has to get the response and no other service instance, with every message sent to the PUSH socket, service appends a response queue name. - Worker receives the message, does the work and pushes (does a connect) on the response queue given in the message. - Service does a bind on it's response queue and when it receives the response, does the rest of the work and responds to the service caller.
The problem - - All threads in a service instance has to do some synchronization to get hold of the PUSH queue to send a request to worker. - With heavy load this single PUSH queue starts choking. - When I deploy this service code on multiple instances and bind to the same socket, things break.
Is there a standard approach for achieving this with ZMQ? The reason we decided to use ZMQ is less connection management as is needed if worker was another HTTP service (retries, disconnections, connection pools etc) and better throughput with ZMQ.