Multi-Region ASP.NET Session State Provider for NCache

Many ASP.NET applications today are deployed in multi-region (multi datacenter) configurations either in the Cloud or on-premises. And, with these applications you often need to redirect users from one region (datacenter) to another. But you cannot afford to lose any ASP.NET Session State in the process.

Multi-region deployments usually prefer to keep user sessions in the same region where they were created. Essentially, they do not engage in cross-region load balancing at user request level. But, quite frequently you need to bump users to other regions for the following reasons:

- Balance load across regions if one region is overwhelmed
- Bring down a region for maintenance

However, you cannot afford to do any of this in a way where ASP.NET Session State is lost. One way to solve this problem is by replicating all your ASP.NET sessions to multiple regions. NCache provides WAN Replication feature for this.

But, in many cases, you may not want to replicate all the ASP.NET sessions just so you can bump 10-20% of the users. Instead, you just want the ASP.NET Session State to "move" when the user is moved from one region to another.

Multi-Region ASP.NET Session State provider for NCache has the intelligence to handle all such cases. It lets you specify all the regions in your web.config file and then when a user is redirected to another region, his ASP.NET session is moved from the source region distributed cache to the destination region distributed cache.

NCache is an extremely fast and scalable Open Source distributed cache for .NET. It handles extreme transaction load by allowing you to add more cache servers at runtime and scale linearly. NCache also provides intelligent cache replication so you don't lose any ASP.NET Session State if a web server or a cache server goes down.

NCache lets you define one primary and multiple secondary ASP.NET Session State caches in your ASP.NET web.config as following. Please note that for each region, the "primaryCache" is different.

All ASP.NET sessions are originally stored in their "primaryCache". Then, when the user is bumped to another region, the Multi-Region ASP.NET Session State Provider for NCache in that region notices that this ASP.NET Session is from another region. And, it connects to the corresponding "secondaryCache" and moves the ASP.NET Session to its "primaryCache" so it is available from here.

Benefits of Multi-Region ASP.NET Session State Provider for NCache

First of all, there is no programming required to use NCache as your Multi-Region ASP.NET Session State Provider. You simply modify your web.config and specify NCache as your Session State Provider (SSP). See details on Configuring Multi-Region ASP.NET Session State Provider for NCache. Following are some of the benefits for using NCache as your Multi-Region ASP.NET Session State Provider:

WAN Replication Not Needed: Since most ASP.NET Sessions are not going to be referenced in more than one region, there is often no need to replicate them across the WAN just because you can bump 10-20% of them to other regions. WAN Replication has a bandwidth consumption cost associated with it. WAN Replication is more appropriate for application data cache.

Cross-Region High Availability: You can now bring down a region (datacenter) without affecting any of its users negatively. Just redirect all of them to other regions and NCache moves their ASP.NET Sessions seamlessly.

Cross Region Scalability: If any region (datacenter) is getting overwhelmed, you can redirect not only new users but also existing ones to other regions without losing their ASP.NET Sessions. NCache moves their ASP.NET Sessions seamlessly.