I am trying to build a ZeroMQ pattern where,
- There can be many clients connecting to a single server endpoint
- Server will distribute incoming client tasks to available workers (will be mapped to the number of cores on the server)
- These tasks are long running (in hours) and need to perform a lot of local I/O
- During each task execution (iteration) there will be data/messages (potentially in order of
[GB]
s) sent back and forth between the client and the server worker - Client and server workers need to know if there are failures/errors on the peer side, so that they can recover (retry) or shutdown gracefully and try later
Based on the above, I presume that the ROUTER/DEALER
pattern would be useful. PUB/SUB
is discarded as I need to know if the peer fails.
I tried using various combinations of the ROUTER/DEALER
pattern but I am unable to ensure that multiple messages from a client reach the same worker within an iteration. I understand that I need to implement a broker/forwarder/device that routes the incoming messages to the right recipient/handler/worker. But I am unable to map the frontend and backend sockets in the broker. I am looking at MajorDomo pattern, but I guess there has to be a simpler broker model that could just route the messages to the assigned worker. (not really get into services)
I am looking for some examples, if there are any or any guidance on what I may be missing. I am trying to build this in Golang.