.github
abstract-document
abstract-factory
acyclic-visitor
adapter
aggregator-microservices
ambassador
api-gateway
async-method-invocation
balking
bridge
builder
business-delegate
bytecode
caching
callback
chain
circuit-breaker
collection-pipeline
command
commander
composite
converter
cqrs
dao
data-bus
data-locality
data-mapper
data-transfer-object
decorator
delegation
dependency-injection
dirty-flag
double-buffer
double-checked-locking
double-dispatch
eip-aggregator
eip-message-channel
eip-publish-subscribe
eip-splitter
eip-wire-tap
event-aggregator
event-asynchronous
event-driven-architecture
event-queue
event-sourcing
execute-around
extension-objects
facade
factory-kit
factory-method
feature-toggle
fluentinterface
flux
flyweight
front-controller
guarded-suspension
half-sync-half-async
hexagonal
intercepting-filter
interpreter
iterator
layers
lazy-loading
leader-election
marker
master-worker-pattern
src
README.md
pom.xml
mediator
memento
model-view-controller
model-view-presenter
module
monad
monostate
multiton
mute-idiom
mutex
naked-objects
null-object
object-mother
object-pool
observer
page-object
partial-response
pipeline
poison-pill
priority-queue
private-class-data
producer-consumer
promise
property
prototype
proxy
queue-load-leveling
reactor
reader-writer-lock
repository
resource-acquisition-is-initialization
retry
role-object
semaphore
servant
serverless
service-layer
service-locator
singleton
spatial-partition
specification
state
step-builder
strategy
subclass-sandbox
template-method
thread-pool
throttling
tls
tolerant-reader
trampoline
twin
typeobjectpattern
unit-of-work
value-object
visitor
.gitignore
.travis.yml
CONTRIBUTING.MD
LICENSE.md
PULL_REQUEST_TEMPLATE.md
README.md
checkstyle-suppressions.xml
faq.md
license-plugin-header-style.xml
pom.xml
update-website.sh
29 lines
1.3 KiB
Markdown
29 lines
1.3 KiB
Markdown
![]() |
---
|
||
|
layout: pattern
|
||
|
title: Master-Worker
|
||
|
folder: master-worker-pattern
|
||
|
permalink: /patterns/master-worker-pattern/
|
||
|
categories: Centralised Parallel Processing
|
||
|
tags:
|
||
|
- Java
|
||
|
- Difficulty-Intermediate
|
||
|
---
|
||
|
|
||
|
## Also known as
|
||
|
|
||
|
> Master-slave or Map-reduce
|
||
|
|
||
|
## Intent
|
||
|
|
||
|
> Used for centralised parallel processing.
|
||
|
|
||
|
## 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
|
||
|
* [https://docs.gigaspaces.com/sbp/master-worker-pattern.html]
|
||
|
* [http://www.cs.sjsu.edu/~pearce/oom/patterns/behavioral/masterslave.htm]
|