Alachisoft NCache 4.1 - Online Documentation

Sessions in geographically separated web farms

 
NCache provides ability to manage ASP.NET session state across multiple web farms. This improves high availability and fault tolerance by allowing web farms to spread across multiple geographic regions. To achieve this, NCache provides Location Affinity feature for sessions.
 
To understand Location Affinity feature for sessions, consider the following scenario. Suppose that you have created multiple clustered caches, one for each geographical location. Each clustered cache has its own set of clients as a web farm. These clients will add, insert, and get sessions mostly from their own clustered cache. However, some time a user might be sent to the web farm of another geographical location. Now, NCache allows the user to access the same session, based on the original session id.
This is further explained with the help of following diagram:
 
 
 
 
This figure demonstrates the following ASP.NET session state scenario:
 
  1. A client makes a request that passes through the Global Load Balancer.
  2. Global Load Balancer passes the request to a Local Load Balancer based on current system load. Suppose, the session request is passed to Local Load Balancer 1.
  3. The Local Load Balancer1 passes the request to the server within a web farm, based on system load. Suppose request is passed to Web Server1. Once the request reaches Web Server1, CustomSessionIDManager adds a unique prefix for this ASP.NET session.
  4. After the server establishes the ASP.NET session, current session state is saved in primary cache for this web farm, in this case Replicated Cache1.
  5. When Global Load Balancer routes the same client to Web Farm2, web server analyzes the session prefix. With the help of this prefix it fetches the session from Clustered Cache1 even though it belongs to Web Farm1.
 
Note: This optimization is possible only in .Net 2.0 and later versions where a CustomSessionIDManager can add sid-prefix to session id. This sid-prefix helps in directing client to the cache holding the session.
 
To use Location Affinity, you have to specify one 'primary' and one or more 'secondary' caches for each web farm in web.config. The primary cache will be used for all local traffic and all secondary caches will be used when a user goes to different geography.
 
Enable Location Affinity for SessionStoreProvider
 
  • Add following section in web.config.
     
    <configSections>
    <section name = "ncache" type = "Alachisoft.NCache.Web.SessionStateManagement.NCacheSection,
    Alachisoft.NCache.SessionStateManagement, Version=x.x.x.x, Culture=neutral, PublicKeyToken=CFF5926ED6A53769"/>
    </configSections>
    <ncache>
    <sessionLocation>
    <primaryCache id = "London_Cache" sid-prefix = "LDC"/>
    <secondaryCache id = "NewYork_Cache " sid-prefix = "NYC"/>
    <secondaryCache id = "Tokyo_Cache" sid-prefix = "TKC"/>
    </sessionLocation>
    </ncache>
     
    Note:
  • Replace version “x.x.x.x” with the actual NCache version that you have.
  • The sid-prefix is a unique identifier that is appended by custom session-ID manager in the beginning of session-ID. sid-prefix length must be equal to 4.
     
  • Enable custom session-ID manager using the sessionIDManagerType attribute of the sessionState element in web.config.
     
    <sessionState cookieless = "false" regenerateExpiredSessionId = "true" mode = "Custom" customProvider = "NCacheSessionProvider" timeout = "60" sessionIDManagerType = "Alachisoft.NCache.Web.SessionStateManagement.CustomSessionIdManager, Alachisoft.NCache.SessionStateManagement">
    <providers>
    <add name = "NCacheSessionProvider" type = "Alachisoft.NCache.Web.SessionState.NSessionStoreProvider"
    sessionAppId = "1234" cacheName = "myCache" writeExceptionsToEventLog = "false" asyncSession = "false"
    enableLogs = "false"/>
    </providers>
    </sessionState>
     
    Note:
  • When Location Affinity is enabled, "CacheName" specified in <providers> section of web.config will be ignored.
  • Cookieless sessions are not supported.
 
 
See Also
 
Copyright © 2005-2012 Alachisoft. All rights reserved.