Some time back , I stumbled upon Space Based Architecture (SBA) and found it to be very interesting architecture to build highly scalable applications. SBA based applications are inherently scalable than their counter parts i.e tier based architectures. Now that I am looking at REST, SBA seems to adopt few properties of REST, though not intentionally i guess(Note: I am not drawing pararelles between REST and SBA, only looking at few similarities). I find the following similarities b/w SBA and REST
- Uniform Interface (PUT,TAKE,NOTIFY,..)
- Stateless interaction
- Highly scalable arch style
In SBA, a space is shared between multiple services which is used as place to store data and behaviour which can be accessed by multiple services. The Master-Worker pattern which is most commonly associated with space based programming shows the true power of spaces by making it possible to pass behaviors and state between masters and workers and thus enabling simplified parallel processing. This pattern suits problem domains where either a problem is highly parallelizable or if there are a set of tasks that can be be performed by any set of workers. Imagine a SOA based or traditional client-server based system where a client accesses a piece of functionality on a remote server which is executed in place on the remote server and result delivered back to the client. In SBA, the same client-server or SOA paradigm shifts the processing to the client, i.e a client picks a piece of business logic from the shared space, executes it locally on the client thus reducing the the complexities involved in load balancing, horizontal scaling on the server. To achieve this, SBA requires that functionalities exposed by services or servers be self-sufficient unit. I think SBA achieves the first law of distributed object design perfectly well.
There are some criticism of SBA where people say it is just a new name for shared database. However, I feel that comparing spaces to databases might not be entirely right. Shared database works like persistent memory where databases are used as shared memory and the primary purpose here is to place some data into a shared environment as a layer of interoperability between applications. However spaces brings not only data but behavior and distributed aspect to sharing. So looking at spaces as just another object repository is missing out on the aspects such as parallelism and distributed behavior.
The space programming model associated with SBA is supported by Tuple Spaces, JavaSpaces, GigaSpaces. Tuple space can be thought of as distributed shared memory where programs can read and write entries. JavaSpaces provides distributed object exchange and coordination mechanism for Java objects. JavaSpaces supports the following interfaces to interact with the space:
- write(): Writes new objects into a space
- take(): Retrieves objects from a space
- read(): Makes a copy of objects in a space
- notify: Notifies a specified object when entries that match the given template are written into a space
Gigaspaces develops upon JavaSpaces and adds extensions like update operation to update an object in the space at finer granularity than write(). write() in JavaSpaces replaces the entire object. With JavaSpaces, the only way to update a small part of an object is to first take() the entire object out of the space, modify the object and write back the object to the space. Gigaspaces also adds .NET, C++ and Java interoperability, support for JMS, queries etc..
Overall, I feel SBA has a lot of potential for solutions demanding high degree of linear scalability, distributed objects and pararllelism. I have played around with JavaSpaces and found it be very simple to get started with. Blitz is another open source toolkit that further claims to simplify the development of applications based on space programming model. Gigaspaces provides both commercial as well as an open source platform for utilizing space programming model. A white paper by Nati Shalom of Gigaspaces explains the benefits of SBA as compared to tier based architecture. A good read if you are looking at SBA seriously.