Manager-Worker Framework
The manager-worker framework is a load balancing method in multiprocessing that handles large-scale computations and workloads by breaking them down into smaller, independent tasks that can be done in any order. Compared to naive multiprocessing, this approach significantly reduces the time it takes for the longest process to finish running. The manager-worker framework consists of:
- A manager process, which distributes tasks across each worker process every time a worker is ready to receive more tasks.
- Multiple worker processes, which receive and do the tasks assigned to them by the manager, signaling the manager whenever they are ready for more tasks.
Whenever there is no more work, a worker process is killed. When all workers finish their work, then the manager process is killed (last).
Examples
Manager-Worker ManyMatMul
Consider the ManyMatMul program introduced in 6.5a. Out of the 1000 processes, one process becomes the manager. Thus, there are 999 workers. The manager process does not do any work, since if it stalls, the whole program stalls.
Then, if tasks are dependent, a queue may be set up by the manager process to track independent and dependent tasks and schedule them accordingly. Otherwise, there is finally order in our execution.