You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by ApacheNinja <dp...@gmail.com> on 2013/10/10 20:48:35 UTC

Help needed - shiro-activeSessionCache.data grows close to 2GB daily

Hello,

I have posted previously but am in desperate need of help so I have posted
again.  In our shiro-ehcache folder the file shiro-activeSessionCache.data
has grown to almost 2GB in one day.  I have configured it to write to
another location with more space but the file keeps getting bigger everyday. 
We have not had any problems with this before and I am unclear why the cache
is being written to disk.  We are in need of any help and it would be
greatly appreciated.  Thank you.


These are the settings for our Shiro session cache in our ehcache.xml file: 

   <cache name="shiro-activeSessionCache" 
       	 maxElementsInMemory="10000" 
       	 overflowToDisk="true" 
       	 eternal="true" 
      timeToLiveSeconds="0" 
       	 timeToIdleSeconds="0" 
       	 diskPersistent="false" 
      diskExpiryThreadIntervalSeconds="600" 
      >
    </cache>

We have configured programmatically like this:

public static void initSecurityManager() {
		 
		  //Set realms
			mSecurityManager = new DefaultSecurityManager();
			mSecurityManager.setAuthenticator(new MockAuthenticator());
			ArrayList <Realm> realms = new ArrayList<Realm>();
			realms.add(new PortalRealm());
			realms.add(new PortalBaselineRealm());
			mSecurityManager.setRealms(realms);
			
			//Setup caching
			SessionDAO sessionDAO = new EnterpriseCacheSessionDAO();
		
((DefaultSessionManager)mSecurityManager.getSessionManager()).setSessionDAO(sessionDAO);
			EhCacheManager shiroCacheManager = new EhCacheManager();
		  shiroCacheManager.setCacheManagerConfigFile("classpath:ehcache.xml");
			mSecurityManager.setCacheManager(shiroCacheManager); 
			
			SecurityUtils.setSecurityManager(mSecurityManager);
	 }



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Help-needed-shiro-activeSessionCache-data-grows-close-to-2GB-daily-tp7579231.html
Sent from the Shiro User mailing list archive at Nabble.com.

RE: Help needed - shiro-activeSessionCache.data grows close to 2GB daily

Posted by Michael Chandler <Mi...@onassignment.com>.
Hi there. I saw you didn't get a reply to this, and yesterday I finally achieved some success in regards to caching my sessions after a long-running struggle.  I'm no expert, but wanted to make a suggestion.

One of the things I have in my configuration that you appear NOT to have is a session validation scheduler.  The validation scheduler will ensure that invalid or orphaned sessions are evicted from the cache.  Here's what I did:

I created an instance of org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler.  It has a property called "interval" which takes a value in milliseconds.  I set that property to 2 hours (7200000).  The session manager has a property called sessionValidationScheduler, which I set with that object instance.  I've only been up and running since last night, but presumably this should prevent old and orphaned sessions from piling up in your cache, conducting validation every 2 hours in my case or whatever interval you set.

Mike

-----Original Message-----
From: ApacheNinja [mailto:dpryce7@gmail.com]
Sent: Thursday, October 10, 2013 11:49 AM
To: user@shiro.apache.org
Subject: Help needed - shiro-activeSessionCache.data grows close to 2GB daily

Hello,

I have posted previously but am in desperate need of help so I have posted again.  In our shiro-ehcache folder the file shiro-activeSessionCache.data has grown to almost 2GB in one day.  I have configured it to write to another location with more space but the file keeps getting bigger everyday.
We have not had any problems with this before and I am unclear why the cache is being written to disk.  We are in need of any help and it would be greatly appreciated.  Thank you.


These are the settings for our Shiro session cache in our ehcache.xml file:

   <cache name="shiro-activeSessionCache"
         maxElementsInMemory="10000"
         overflowToDisk="true"
         eternal="true"
      timeToLiveSeconds="0"
         timeToIdleSeconds="0"
         diskPersistent="false"
      diskExpiryThreadIntervalSeconds="600"
      >
    </cache>

We have configured programmatically like this:

public static void initSecurityManager() {

                  //Set realms
                        mSecurityManager = new DefaultSecurityManager();
                        mSecurityManager.setAuthenticator(new MockAuthenticator());
                        ArrayList <Realm> realms = new ArrayList<Realm>();
                        realms.add(new PortalRealm());
                        realms.add(new PortalBaselineRealm());
                        mSecurityManager.setRealms(realms);

                        //Setup caching
                        SessionDAO sessionDAO = new EnterpriseCacheSessionDAO();

((DefaultSessionManager)mSecurityManager.getSessionManager()).setSessionDAO(sessionDAO);
                        EhCacheManager shiroCacheManager = new EhCacheManager();
                  shiroCacheManager.setCacheManagerConfigFile("classpath:ehcache.xml");
                        mSecurityManager.setCacheManager(shiroCacheManager);

                        SecurityUtils.setSecurityManager(mSecurityManager);
         }



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Help-needed-shiro-activeSessionCache-data-grows-close-to-2GB-daily-tp7579231.html
Sent from the Shiro User mailing list archive at Nabble.com.

The information transmitted, including attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this e-mail in error, please notify the sender immediately by replying to the message and deleting the material from your computer.