nonblocking - ZeroMQ pattern for load balancing work across workers based on idleness -
i have single producer , n workers want give work when they're not processing unit of work , i'm struggling find zeromq pattern.
1) req/rep
the producer requestor , creates connection each worker. tracks worker busy , round-robins idle workers
problem:
- how notified of responses , still able send new work idle workers without dedicating thread in producer each worker?
2) push/pull
producer pushes 1 socket workers feed off, , workers push socket producer listens to.
problem:
- has no concept of worker idleness, i.e. work gets stuck behind long units of work
3) pub/sub
non-starter, since there no way make sure work doesn't lost
4) reverse req/rep
each worker req
end , requests work producer , sends request when completes work
problem:
- producer has block on request work until there work (since each
recv
has pairedsend
). prevents workers respond work completion - could fixed separate completion channel, producer still needs polling mechanism detect new work , stay on same thread.
5) pair per worker
each worker has own pair
connection allowing independent sending of work , receipt of results
problem:
- same problem
req
/rep
requiring thread per worker
as zeromq non-blocking/async under hood, cannot find pattern allows code asynchronous well, rather blocking in many many dedicated threads or polling spin-loops in fewer. not use case zeromq?
your problem solved load balancing pattern in zmq guide. it's flow control whilst being able send , receive messages. producer send work requests idle workers, whilst workers able send , receive other messages @ times, e.g. abort, shutdown, etc.
Comments
Post a Comment