Sunday, May 31, 2009

Design Patterns for Scalable Distributed Systems

After several months of using GigaSpaces as the platform for building scalable distributed systems, I have collected a handful of design patterns that are useful during the design process.

  • Master-Worker Pattern
  • Command Pattern
  • Observer Pattern
  • Blackboard Pattern
  • Workflow Pattern
These design patterns share a common characteristic; they work well for parallel processing in a distributed environment. For instance, in the master-worker pattern, the master distributes tasks for the workers. The workers can be spread across the network and compute the result individually. Once the results are computed, they send back the results to the master. In the command pattern, the commander sends an arbitrary command to one/all of her managed resources. Resources execute the command on her behalf. In the observer pattern, information is published by an agent onto the shared resources. Observers who have previously subscribed to the information will get notify and process the information based on their specific requirement. In the blackboard pattern, a group of specialists tries to solve a single problem. The solution of the problem will be evaluated by a teacher with respect to the initial constraints provided. In the workflow pattern, although the workflow is sequential, tasks in each stage are performed concurrently because they are not dependent on each other in each stage.

For these patterns to work well in a distributed system, the communication/computation ratio should be kept at minimum. In the next installment, I will show how we can use GigaSpaces to minimize the communication/computation ratio by architecting the system using share nothing and space-based architecture and I will implement some sample applications using GigaSpaces to illustrate the usage of the design patterns mentioned in this post. Stay tune ~