[rabbitmq-discuss] How to structure Master with many slaves? RPC??

Emile Joubert emile at rabbitmq.com
Tue Oct 23 17:29:47 BST 2012


On 23/10/12 13:41, theBuckWheat wrote:
> I have a list of discrete tasks sitting on the master server and a (dynamic)
> list of remote slaves, and I want to pick a slave from the list and send it
> one of these tasks and then do the same for the remaining tasks until all
> available slaves are busy.  

If slaves are not interchangeable and you need address them each
individually then each slave will need to declare its own queue. The
master will need to know how to address each slave queue and send work
at a rate that matches its processing power. Are you sure you need to do
this though?

> 1) How best to structure pushing work to slaves;  At present, on the master
> I keep a table of all slaves and a status flag.  If I set the status to
> available, the master (based on a priority selection scheme) can pick one
> off the list and push work to it.  The status is then set to 'busy'.  I can
> set the status to unavailable at any time and that only removes the slave
> from the list of slaves the master can push work to.  

This solution involves alot of work for the master, which is responsible
for tracking the status and availability of individual slaves. This also
has the drawback that work given to one slave cannot easily be
reassigned to another slave.

> 2) How to structure fetching the finished work file?  Push or pull?  At
> present, when a slave is finished, it calls the master and only sets a flag. 
> Based on a priority scheme, the master will eventually pull the finished
> work file from that slave, after which it marks that slave as being
> available for work.

Is there any reason why a common reply queue for completed work from all
slaves can't work?

> The load-balance model seems to apply, but only if I can control which slave
> gets the message.  I don't want to broadcast to all slaves due to bandwidth
> constraints.  As I read the various queue configurations, I understand how
> each can be used, but I don't see a published one that applies to this
> particular master-slave configuration because of its dynamic nature.   This
> leads me to ponder the RPC model.  Am I missing something?

Can you explain why you need to assign work so accurately to a specific
slave? Why does it matter which slave performs the work?

A more common approach is to aggregate similar kinds of slaves, or to
separate the work by kind of task and use a shared queue for each. Each
worker (in a given group) subscribes to the same queue and delivers
completed work to a shared reply queue. This allows each slave to work
at its own pace and if a slave crashes before completing the task
another slave can accept the task.

In this scenario you don't broadcast to all slaves - instead you send
one work item to a shared work queue and one slave receives it and
completes it.


More information about the rabbitmq-discuss mailing list