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:
- Set up a JavaSpaces instance on a Linux cluster (probably using Blitz to start out with)
- 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.)
- Change your ASP.NET web.config to point at your new custom state provider.
(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:
- High-impact Web tier clustering, Part 2: Building adaptive, scalable solutions with JavaSpaces
- The Blitz Project (open source JavaSpace implementation with installer)
- SessionStateStoreProviderBase Class
3 comments:
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
GigaSpaces
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
hi, maybe you would like to have a look at: http://www.sharedcache.com which is open source and free. regards
Post a Comment