For on-premises deployments, ASP.NET Session State provides three built-in storage options (InProc, StateServer, and SqlServer) and a fourth "Custom" option. The first two built-in options (InProc StateServer) have scalability problems, whereas, SqlServer option has both performance and scalability problems.
A much better strategy is to use the "Custom" option and plug-in NCache as your ASP.NET Session State Provider. 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.
First of all, there is no programming required to use NCache as your ASP.NET Session State provider. You simply modify your web.config and specify NCache as your Session State Provider (SSP). See details on configuring ASP.NET Session State Provider for NCache. Following are some of the benefits of using NCache as your ASP.NET Session State Provider:
NCache provides two ways for you to manage ASP.NET Session State for applications running in multiple regions (data centers) and still maintaining session consistency across them. They are as follows:
WAN Replication of ASP.NET Session State: NCache provides a Bridge Topology to let you replicate your entire ASP.NET Session State store (the distributed cache) to another region (data center) across the WAN. This ensures that your sessions always exist in multiple regions (data centers). You can use this in active-passive (for disaster recovery) or active-active modes. In active-active, you can even load balance traffic between multiple regions (data centers). All of this is done through configuration changes.
Multi-Region ASP.NET Session State: If you don't want to replicate ASP.NET Session State across the WAN because of bandwidth consumption cost, you can use Multi-site ASP.NET Session State feature of NCache. In this, the ASP.NET Session State is not replicated across sites and instead is kept at the location of its creation. But, if you move any traffic from one region (data center) to another, the ASP.NET Session State moves with it. This allows you to have two or more active regions (data centers), each keeping most of its traffic local, but occasionally overflowing to another region when needed.
And, you can also bring down one datacenter without causing any interruptions for the users because their sessions will be accessible by other datacenters.
The NCache ASP.NET Session State provider implements all the standard ASP.NET Session State Provider features. Additionally, it provides various advanced features to let you handle complex situations in your applications.
INSTALL_DIR\NCache\log-files\SessionStoreProvider
folder) by specifying enableLogs = "true"
. You can also enable logging of errors to the Windows Event Log by specifying writeExceptionsToEventLog = "true"
.Standard Session Locking: The standard ASP.NET session locking behavior is that if a session is locked, another request for it waits for 90 seconds (configurable) and at the end force-unlocks the session. You can specify this option as follows:
enableSessionLocking = "true" sessionLockingRetry = "-1" emptySessionWhenLocked = "false"
Enhanced Session Locking: If you have a high-traffic ASP.NET application where robots may be scraping data and using the same session ID for hundreds or thousands of requests simultaneously. You cannot afford the standard session locking option as waiting for 90 seconds could tie up all your available sockets. Instead, you want to return the request quickly to indicate a failure. You can specify this as follows:
enableSessionLocking = "true" sessionLockingRetry = "5" emptySessionWhenLocked = "false"
This makes 5 retries at half-second intervals and then returns an empty session to signify a failure. Even throwing an exception here is costly. That is why an empty session is implemented. This behavior was originally implemented on a request from a high-traffic airline website.© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.