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
