A Look at the SpaceFacade Pattern

A unique form of distributed computing may be called ‘space-based.’ Program objects and data can share a space in this scenario, without a lot of stipulations placed upon them. JavaSpaces has emerged as a standard means to do such programming, and GigaSpaces has in turn emerged as a major commercializer of JavaSpaces technology.

Today, Owen Taylor of GigaSpaces writes about spaces. There is an interoperability play here. He notse one can embed a space in the same process as a .NET application and expose it to C++ and Java as a fully-functioning virtual resource. In fact, GigaSpaces has recently gone beyond the Java world to support space-based programming in .NET. [See Java player GigaSpaces sets course for .NET coverage, TSS.NET, February 27, 2007] – J.Vaughan

By Owen Taylor
A space-based architecture is fundamentally different from traditional architectures (meaning stuff we already understand).

This is primarily due to the combined behaviors of state management and event distribution that a Space provides. This creates a natural hub and spoke architecture where the space acts as the communication hub for the rest of the application.

Additionally, when using a space as a reliable in-memory store for your active Objects, there is a shift in dependency away from the database for frequent reads and even updates to the system state within a business transaction. (changes are usually propagated to the DB in an asynchronous fashion to facilitate long-term persistence and extensive queries)

Due to the space taking on the responsibility for state management and event distribution, an entirely new architecture can be achieved.

In essence, what a Space offers is a single logical resource that allows the sharing of Objects between different machines, processes, and threads within a process - aw heck, let’s just say among “services”. Which indeed leads us to adopt a service-oriented, space-based architecture.

Spaces are designed to support a very potent pattern called Master/Worker which is used to address problems where there is a huge amount of work to be done and most of it can be done independent of the rest.

In the Master/Worker pattern, the Master writes Entries into the space and the workers take them out. I liken this to serving a bowl of popcorn. The master fills the bowl and the workers take the popcorn out.

The more workers, the faster the popcorn is processed because there is no dependency between kernels.

Many work-flow applications can be modeled this way as can matching engines and execution engines as long as the Entries written are designed to house (or be deployed in the same process as) a self-contained set of instructions and or data.

What this allows within the familiar tier-based architecture is a kind of magical pressure valve that can take advantage of any number of boxes that might be available on the network and thus process these kernels of work at tremendous speeds. A facade can be created that receives a request for processing, cracks it into parallel tasks and submits them to a space.

While the original caller writes, blocks and waits for a result (thinking it is talking to a single resource) in the back-end many simultaneous operations are occurring that result in faster results and a more adaptive and scalable solution.

This use of this SpaceFacade pattern has resulted in great successes for the customers of GigaSpaces. These successes are measurable in various ways.

Performance:
Major financial firms worldwide are leveraging the space to facilitate dramatically reduced transaction latency and greater overall throughput. By collocating services with the data they require in the same process as a space, latency of operations within real applications are reduced from tens of milliseconds to hundreds of microseconds. This is realized through removing the dependency on separate messaging, data-caching/store, and business processing layers, and the resulting reduction in network hops and distributed transactions.

Reliability:
As described here.Virgin Mobile experiences not only greater throughput as a result of this architecture, but also increased reliability as the in-memory ‘virtual’ resources act as a buffer to the traditional backend systems. Last fall (2006), while their DB was down for 10+ hours, the Space and its associated services continued to accept and process orders so not a single one was lost.

Interoperability:
Being able to embed a space in the same process as a .NET application and expose it to C++ and Java as a fully-functioning virtual resource offers up an extremely simple solution to the problem of sharing information among disparate services and applications. I can think of three major financial services companies that today, leverage our support for inter-language communication where the SpaceFacade also hides the language used when implementing cooperative services.

Layers of indirection are remarkably useful!

———————

Owen Taylor is Senior Director for Worldwide Technical Communications, GigaSpaces Technologies.

————————-

Author’s Note: If you would like to try out the Space as implemented by GigaSpaces, I have posted a simple .NET/C# example on my blog here.

Further information on our .NET support can be found on the GigaSpaces .NET wiki.

For an introduction to the core space API and further discussion of the space value proposition you can look at my post on four verbs.


Leave a Reply