java-design-patterns/master-worker-pattern
Anurag Agarwal 428efc7d53 Java 11 migrate remaining p (#1122)
* Moves partial-response to Java 11

* Moves pipeline to Java 11

* Moves poison-pill to Java 11

* Moves priority-queue to Java 11

* Moves private-class-data to Java 11

* Moves producer-consumer to Java 11

* Moves promise to Java 11

* Moves property to Java 11

* Moves prototype to Java 11

* Moves proxy to Java 11

* Corrects checkstyle errors

* Fixes build for pipeline pattern
2020-01-16 08:06:36 +02:00
..
2020-01-16 08:06:36 +02:00
2019-12-18 22:04:08 +02:00

layout, title, folder, permalink, categories, tags
layout title folder permalink categories tags
pattern Master-Worker master-worker-pattern /patterns/master-worker-pattern/ Concurrency
Performance

Also known as

Master-slave or Map-reduce

Intent

Used for centralised parallel processing.

Class diagram

alt text

Applicability

This pattern can be used when data can be divided into multiple parts, all of which need to go through the same computation to give a result, which need to be aggregated to get the final result.

Explanation

In this pattern, parallel processing is performed using a system consisting of a master and some number of workers, where a master divides the work among the workers, gets the result back from them and assimilates all the results to give final result. The only communication is between the master and the worker - none of the workers communicate among one another and the user only communicates with the master to get the required job done. The master has to maintain a record of how the divided data has been distributed, how many workers have finished their work and returned a result, and the results themselves to be able to aggregate the data correctly.

Credits