tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kief Morris <k...@bitbull.com>
Subject Re: web.xml and session timeout
Date Fri, 09 Feb 2001 10:00:39 GMT
John Clark L. Naldoza typed the following on 09:57 AM 2/9/2001 +0800
>> <session-config>
>>         <session-timeout>
>>             5
>>         </session-timeout>
>>     </session-config>
>> 
>>     However, I have a session bean with an HttpSessionBindingListener- I
>> would think that my valueUnbound() method would get called after 5
>> minutes and something printed to the screen, but it doesn't look like
>> the session is timing out-
>
>Based upon my limited experience, and having the default setting which
>tomcat gives.  I have observed that the sessions are invalidated every
>minute, not every second.  And this cycle starts when you start-up the
>Tomcat Server.
>
>It does time out, but don't expect it to be timed-out to the nearest
>second.  I tried to get a viable explanation on this mailing list, but
>it appears no one knows how...;-(

A background thread processes wakes itself every minute and checks
for sessions which are past their due date. It is conceivable that a
session could be expired an entire minute after it "ought" to be. For
99.999999% of applications this shouldn't be a problem.

If it is a problem, you can add a <Manager> tag to your server.xml.
You'll have to experiment a bit, I haven't tested this on Tomcat 3.2.

<Manager className="org.apache.tomcat.session.StandardManager"
               checkInterval="60" maxActiveSessions="-1"
               maxInactiveInterval="-1" />

checkInterval is what you're looking for, it's the number of seconds
the background thread sleeps. Setting this too low means your server
will be constantly crunching on this: even when the server is idle or
nearly idle, it will constantly loop over a possibly empty session list.
In other words, don't set this too low unless you really really need it 
and have measured the effects in different situations.

Don't set maxActiveSessions to anything other than -1 unless you
really want users to see an error page when your site gets too much
traffic. maxInactiveInterval is another way of setting the session timeout,
although I haven't looked to see which takes precedence, or whether
it takes seconds or minutes. The -1 setting above is a poor choice.

Kief


Mime
View raw message