none
App Fabric : Increasing Region Count in Cache used for Session management

    Pregunta

  • Hi All,

    I have integrated a web application with Appfabric to be used for session management (using the session provider that ships with Appfabric). After some tests i realized  that over time with usage(creation of several new sessions), the Region Count of the Cache keeps on increasing even when most of the sessions have expired.Infact after a period of no activity of around 2 hours , these were the statistics i got from the cache server.


    Size         : 0
    ItemCount    : 0
    RegionCount  : 391
    RequestCount : 9979
    MissCount    : 2729

    I searched this on the appfabric forums and this is what i found in one of the posts

    "Regions' presence is not related to memory leakage as one region object doesn't occupy more than a few KBs of memory. System regions once created are not removed in a running cluster."

    How correct is this statement ??

    Also to my understanding(might be incorrect as well), the session state provider for appfabric creates a new region for each new session.  If it is correct what would happen in case when i am having a few million sessions created over a period of days.Would it not be a problem. Is there a work around ? 

    One solution i can think of is specifying a region(along with Cachename) in the session provider configuration , but that would limit all my sessions to a single cache server(i guess).

    jueves, 29 de marzo de 2012 7:12

Todas las respuestas

  • Hi All,

    I have integrated a web application with Appfabric to be used for session management (using the session provider that ships with Appfabric). After some tests i realized  that over time with usage(creation of several new sessions), the Region Count of the Cache keeps on increasing even when most of the sessions have expired.Infact after a period of no activity of around 2 hours , these were the statistics i got from the cache server.


    Size         : 0
    ItemCount    : 0
    RegionCount  : 391
    RequestCount : 9979
    MissCount    : 2729

    I searched this on the appfabric forums and this is what i found in one of the posts

    "Regions' presence is not related to memory leakage as one region object doesn't occupy more than a few KBs of memory. System regions once created are not removed in a running cluster."

    How correct is this statement ??

    The statement is correct. 400-odd regions is hardly a cause for concern.

    Also to my understanding(might be incorrect as well), the session state provider for appfabric creates a new region for each new session.  If it is correct what would happen in case when i am having a few million sessions created over a period of days.Would it not be a problem. Is there a work around ? 

    What cache server version and type of session state store provider you are using? The session state providers that ship with cache do not use regions. So, the 391 regions (some of these are system regions) that you see have not been added by the session state store provider.

    One solution i can think of is specifying a region(along with Cachename) in the session provider configuration , but that would limit all my sessions to a single cache server(i guess).

    Your guess is spot-on. Limiting session state to a single cache servers is not recommended for obvious reasons.
    viernes, 30 de marzo de 2012 9:27
  • After a round of thorough analysis, i found out that these regions are the default regions created by Appfabric with the increasing number of items that keep on getting stored in the cache and the session provider that ships with Appfabric has nothing to do with this. How ever the number of regions ceases to go beyond 1024. Any specific reason for that ?

    Gurmeet


    • Editado GSG33 viernes, 30 de marzo de 2012 12:01
    viernes, 30 de marzo de 2012 11:59
  • In the following link, some of the posts show the reason count going beyond 1024 as well.Not sure  how this was possible.I tried putting appfabric under heavy load but the default region count did not go beyond 1024.

    http://social.msdn.microsoft.com/Forums/en/velocity/thread/8c525d8c-91f3-48e2-8437-158d9d3e6d57

    I got the following on one of the microsoft sites

    "On an active cache cluster, default regions are created by AppFabric. As the cache grows, the number of these default regions increases. "

    Any Idea why Appfabric creates these multiple default regions and what is the maximum number it can go to ?


    Gurmeet

    viernes, 30 de marzo de 2012 12:05
  • Hi Gurmeet,

    The total number of system regions is capped at 1024, and each key must map to one of those 1024 regions. A system region is created the first time an element with a key that maps to a this region is added. Keys that map to the same system region are located on the same cache server. Once created, a system region is never deleted.

    The count of system regions cannot exceed 1024, but you can create and remove non-system named regions using CreateRegion/RemoveRegion methods on DataCache. To get a list of system regions, you could try out the API DataCache.GetSystemRegions.

    -Arijit

    viernes, 30 de marzo de 2012 12:13
  • Hi Arijit,

    Since the number of system regions in a cache are limited to 1024, what would happen if i try to add a new cache server to a cluster which already has the max(1024) system regions defined for a particular cache name. Would appfabric make use of this new server ? If yes then how ?

    If no then i guess i will need to restart the cache cluster which will lead to losing some of my sessions being maintained in the cluster.

    Regards

    Gurmeet


    Gurmeet

    lunes, 02 de abril de 2012 7:49
  • Hi Gurmeet,

    The system regions transparently get load balanced in AppFabric Cache. Please take a look at http://msdn.microsoft.com/en-us/library/ff383813.aspx. I suppose that addresses your concerns.

    -Arijit

    lunes, 02 de abril de 2012 8:05