Monday, December 10, 2007

Distributed state management for ASP.NET

The more I delve into distributed architectures, the more I'm feeling like Microsoft just isn't providing much of a path forward to scalable distributed systems. Case in point: state management.

By default, session state in ASP.NET is stored in the web server's memory. To share state across servers - which you would want to do in a server farm - you need to store it in SQL Server or in the .NET state service. This is fine for small solutions, but once you bump up against the need to partition state across many servers or multiple hosting locations, things start to get complex and expensive.

Now, it seems the Java folks have worked through these issues already. Here I'm thinking of Space-Based Architecture and more concretely JavaSpaces.

Perhaps I'm oversimplifying, but wouldn't JavaSpaces be a perfect place to store session state in a distributed system? Data in a JavaSpace is persistent, atomic, distributed, & fault tolerant.

There isn't a .NET equivalent of JavaSpaces. But, MS does provide SessionStateStoreProviderBase and the ability to choose a custom provider for session state.

So, here's the recipe as I see it:
  1. Set up a JavaSpaces instance on a Linux cluster (probably using Blitz to start out with)
  2. Write a custom state provider that inherits from SessionStateStoreProviderBase and implements the necessary JavaSpaces methods. (Working out the bridging between .NET & JavaSpaces, of course. There is a tantalizing page called Using JavaSpaces from .NET - but it relies on a commercial product to accomplish this.)
  3. Change your ASP.NET web.config to point at your new custom state provider.
These don't appear to be big hurdles to overcome, and it seems like a nice little open source project.

(In the interest of due diligence, I did run across 2 commercial software products that seem to be solving this kind of problem: ScaleOut and NCache. But for a server farm of 20 servers, you're looking at something in the neighborhood of $30K, not including the cost of the Windows Server licenses + ongoing annual maintenance fees. There is also GigaSpaces, which provides hosted JavaSpaces and has a .NET API, but is also expensive.)

Here are some links I found useful in my research:


Geva Perry said...

Lee --

Thanks for mentioning GigaSpaces. As you say, we provide a native Space-Based .Net API. More about that here.

Also, there are various options in terms of cost. Perhaps the most interesting to the readers of your blog are the GigaSpaces Start-Up Program (which provides the product free to start-up companies and individuals) and the GigaSpaces free Community Edition.

Geva Perry

David Brinker said...

Hi Lee,

You've raised an important topic and we're glad you found ScaleOut Software in your search for solutions. I'd like to make a couple of clarifications about our products.

When you mentioned pricing I think you found our StateServer product, which stores any type of application data, rather than our SessionServer product which is much less expensive and stores only ASP.NET session state. Also, ScaleOut's products can run directly on your Web servers, so there is no additional cost for hardware or software.

ScaleOut SessionServer provides transparent storage for ASP.NET session state. No APIs are needed, it just works after a one line change in your code.

Your readers can learn more about our products here.

David Brinker
ScaleOut Software

Anonymous said...

hi, maybe you would like to have a look at: which is open source and free. regards