Pattern:
Master-Slave


Author

Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stal

Intent

"The Master-Slave design pattern supports fault tolerance, parallel computation and computational accuracy. A master component distributes work to identical slave components and computes a final result from the results these slaves return." (Buschmann, F., R. Meunier, H. Rohnert, P. Sommerlad, and M. Stal, Pattern-Oriented Software Architecture: A System Of Patterns. West Sussex, England: John Wiley & Sons Ltd., 1996)

Motivation

The idea of the Master-Slave pattern is to introduce a coordination instance between clients of the service and the processing of individual sub-tasks. The master component divides work into equal sub-tasks, delegates these sub-tasks to several independent but semantically-identical slave components, and computes a final result from the partial results the slaves return. This general principle is found in three application areas: · Fault tolerance. The execution of a service is delegated to several replicated implementations. Failure of service executions can be detected and handled. · Parallel computing. A complex task is divided into a fixed number of identical sub-tasks that are executed in parallel. The final result is built with the help of the results obtained from processing these sub-tasks. · Computational accuracy. The execution of a service is delegated to several different implementations. Inaccurate results can be detected and handled. Provide all slaves with a common interface. Let clients of the overall service communicate only with the master. For a more detailed Motivation description for this pattern see: Buschmann, F., R. Meunier, H. Rohnert, P. Sommerlad, and M. Stal. Pattern-Oriented Software Architecture: A System Of Patterns. West Sussex, England: John Wiley & Sons Ltd., 1996.

Known Uses

Matrix multiplication --In a product matrix, each row can be computed by a separate slave. Transform-coding --Each pixel block in an image can be computed by a separate slave. Computing the cross-correlation of two signals. (Kleiman, S., D. Shah, and B. Smaalders, Programming with Threads, SunSoft Press, Prentice Hall, 1996.)

See Also

This pattern has been used on the following systems: An earlier version of this pattern: Coplien, J.O. and D.C. Schmidt (Eds.), Pattern Languages of Program Design, Addison-Wesley, 1995 (a book publishing the reviewed Proceedings of the First International Conference on Pattern Languages of Programming, Monticello, Illinois, 1994. Slaves are described as Processes variant in: Brooks, P., Master-Slave Pattern for Parallel Compute Services, submitted to the 1996 Conference on Object-Oriented Technologies and Systems (COOTS). Slaves are described as Threads variant in detail in: Kleiman, S. and D. Shah, B. Smaalders, Programming with Threads, SunSoft Press, Prentice Hall, 1996. Object Group pattern is a pattern for group communication and support of fault tolerance in distributed applications. This pattern has a local surrogate for a group of replicated objects distributed across networked machines. A request is broadcast to all objects of the group; and the request succeeds if one group member terminates successfully. (Maffeis, S., The Object Group Design Pattern, 2nd USENIX conference on Object-Oriented Technologies and Systems (COOTS), Toronto, Ontario, Canada, 1996.)

Thumbnail

Keywords

Master-Slave pattern, Buschmann patterns, design patterns, organization of work, work distribution

Business Domains

any system with large number of whole-part object relationshipsany system with sets of objects that can handle similar requestssystems that need to partition work into semantically-identical sub-tasks

Problem Forces

global system task decomposes naturally into several processing stagesneed to create complex, aggregate objectsneed to protect clients from knowing if an object is a whole or a partsupports fault tolerancesupports parallel computationthe number and identities of the cooperating components is not known, nor static

Benefits

changeability and extensibility of componentschanging a software system is easyefficiency by parallel processingincreases reuse of classes by de-coupling the interface from the implementationsimplifies the client - permitting the client to treat whole or part objects generically

Liabilities

complexity of design and implementationmachine dependencyportabilitysensitivity to change in the interfaces

Implementation Files

Simple implmentation of the pattern - Slave. Slave.javaSimple implmentation of the pattern - Master. Master.javaSimple implmentation of the pattern. masterslave.h



Generated on Fri Oct 20 11:14:22 GMT+02:00 2000 by Framework Studio