You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Adib <am...@gmail.com> on 2011/01/25 12:32:05 UTC

Understanding the Persistent Session Manager

Hi,

I am trying to understand the settings on the persistent session
manager on tomcat 6 and 7. It seems that the persistent session
manager is primarily meant for the purpose of swapping IDLE sessions
to persistent storage and then hope that they expire, I can see the
value of this given that many users abandon sites without logging out.
It also seems that the persisent manager is not designed to persist
every session at the end of every request so that at the start of
every request the session is read from the store and the end of the
request the session is written to store, is this understanding
correct.

I have also been puzzling over the meanings of maxIdleSwap vs.
maxIdleBackup not sure why these two settings exist or what is
difference between them and the practical use case for them? It is
clear to me what the idle session is but  what is meant by backup and
how is it different than a swap?

Thanks
Adib

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Understanding the Persistent Session Manager

Posted by Adib <am...@gmail.com>.
Is there any downside to turning on the ACTIVITY_CHECK flag?

On Tue, Jan 25, 2011 at 4:47 AM, Mark Thomas <ma...@apache.org> wrote:
> On 25/01/2011 12:45, Adib wrote:
>> Thanks for the hints mark, I just read through the code and that
>> answers some of my questions.
>>
>> The docs says that  org.apache.catalina.session.
>> StandardSession.ACTIVITY_CHECK should be true and that  Tomcat will
>> track the number of active requests for each session. what do the docs
>> mean by active request?
>
> In that case, it means a request associated with the session that is
> currently being processed. This is usually not an issue but it can be
> when you have requests that take longer to complete that the session
> timeout (e.g large file uploads).
>
>> is there such a thing as a non active request?
> No.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Understanding the Persistent Session Manager

Posted by Mark Thomas <ma...@apache.org>.
On 25/01/2011 12:45, Adib wrote:
> Thanks for the hints mark, I just read through the code and that
> answers some of my questions.
> 
> The docs says that  org.apache.catalina.session.
> StandardSession.ACTIVITY_CHECK should be true and that  Tomcat will
> track the number of active requests for each session. what do the docs
> mean by active request?

In that case, it means a request associated with the session that is
currently being processed. This is usually not an issue but it can be
when you have requests that take longer to complete that the session
timeout (e.g large file uploads).

> is there such a thing as a non active request?
No.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Understanding the Persistent Session Manager

Posted by Adib <am...@gmail.com>.
Thanks for the hints mark, I just read through the code and that
answers some of my questions.

The docs says that  org.apache.catalina.session.
StandardSession.ACTIVITY_CHECK should be true and that  Tomcat will
track the number of active requests for each session. what do the docs
mean by active request? is there such a thing as a non active request?


On Tue, Jan 25, 2011 at 4:33 AM, Mark Thomas <ma...@apache.org> wrote:
> On 25/01/2011 11:49, Adib wrote:
>> I just read through some of the tomcat source code for the Persistent
>> Session Manager and it seems that there are three possibilities.
>>
>> Session on the JVM heap lets call it the active session
>> Session not in the JVM heap but in the persistent store this would be
>> a swapped out session
>> Session in the JVM heap and in the persistent store this would be a
>> backed up session
>>
>> Now if anyone can shed some light on how often / when the persistent
>> session manager decides to backup the sessions
>
> If you start at swapOut() and trace the calls to the method you find the
> answer to that question.
>
>> or what is considered
>> an accessed session that would be highly appreciated.
>
> Looking processMaxActiveSwaps() (and maybe a little call tracing) will
> answer that question.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Understanding the Persistent Session Manager

Posted by Mark Thomas <ma...@apache.org>.
On 25/01/2011 11:49, Adib wrote:
> I just read through some of the tomcat source code for the Persistent
> Session Manager and it seems that there are three possibilities.
> 
> Session on the JVM heap lets call it the active session
> Session not in the JVM heap but in the persistent store this would be
> a swapped out session
> Session in the JVM heap and in the persistent store this would be a
> backed up session
> 
> Now if anyone can shed some light on how often / when the persistent
> session manager decides to backup the sessions

If you start at swapOut() and trace the calls to the method you find the
answer to that question.

> or what is considered
> an accessed session that would be highly appreciated.

Looking processMaxActiveSwaps() (and maybe a little call tracing) will
answer that question.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Understanding the Persistent Session Manager

Posted by Adib <am...@gmail.com>.
I just read through some of the tomcat source code for the Persistent
Session Manager and it seems that there are three possibilities.

Session on the JVM heap lets call it the active session
Session not in the JVM heap but in the persistent store this would be
a swapped out session
Session in the JVM heap and in the persistent store this would be a
backed up session

Now if anyone can shed some light on how often / when the persistent
session manager decides to backup the sessions or what is considered
an accessed session that would be highly appreciated.


On Tue, Jan 25, 2011 at 3:32 AM, Adib <am...@gmail.com> wrote:
> Hi,
>
> I am trying to understand the settings on the persistent session
> manager on tomcat 6 and 7. It seems that the persistent session
> manager is primarily meant for the purpose of swapping IDLE sessions
> to persistent storage and then hope that they expire, I can see the
> value of this given that many users abandon sites without logging out.
> It also seems that the persisent manager is not designed to persist
> every session at the end of every request so that at the start of
> every request the session is read from the store and the end of the
> request the session is written to store, is this understanding
> correct.
>
> I have also been puzzling over the meanings of maxIdleSwap vs.
> maxIdleBackup not sure why these two settings exist or what is
> difference between them and the practical use case for them? It is
> clear to me what the idle session is but  what is meant by backup and
> how is it different than a swap?
>
> Thanks
> Adib
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Understanding the Persistent Session Manager

Posted by Martin Grotzke <ma...@googlemail.com>.
On Tue, Jan 25, 2011 at 1:35 PM, Adib <am...@gmail.com> wrote:

> Thanks for the link that was useful. So the key idea to understand is
> that there is a background thread that does all the cleanup and this
> background thread executes on a timer not on very request arriving a
> the server.
>
> I am surprised at the limitations of the Persistent Manager it's that
> it should be an easy thing to backup and load sessions on every
> request. Is there something about how tomcat is implemented that makes
> implementing persistence on load and save difficult?
>
Not really. I'd assume that there were specific requirements that lead to
this solution (how PersistentManager is implemented). Saving/loading
sessions per request from/to a datastore can be done using a valve.

I just just implemented what you're looking for with the
http://code.google.com/p/memcached-session-manager/ to support non-sticky
sessions (to be released in a few days).
I chose memcached as backend to be really scalable, as IMHO with a database
this is expensive / hard to achieve.

AFAIK Reinwald is just checking out do achieve what you want with
PersistentManager:
http://old.nabble.com/Why-cant-the-the-classes-%28in-the-jars%29-places-in-Tomcat-lib--see-the-classes-from-the-webapp-WEB-INF-lib.-td30713002.html#a30720080

Cheers,
Martin



>
> Cheers
> Adib
>
> On Tue, Jan 25, 2011 at 4:24 AM, Reinwald Warapen
> <re...@directi.com> wrote:
> > On 1/25/2011 5:02 PM, Adib wrote:
> >>
> >> Hi,
> >>
> >> I am trying to understand the settings on the persistent session
> >> manager on tomcat 6 and 7. It seems that the persistent session
> >> manager is primarily meant for the purpose of swapping IDLE sessions
> >> to persistent storage and then hope that they expire, I can see the
> >> value of this given that many users abandon sites without logging out.
> >> It also seems that the persisent manager is not designed to persist
> >> every session at the end of every request so that at the start of
> >> every request the session is read from the store and the end of the
> >> request the session is written to store, is this understanding
> >> correct.
> >
> >
> http://reinwaldwarapen.com/2011/01/17/storing-and-sharing-sessions-among-standalone-tomcat-instances/
> >>
> >> I have also been puzzling over the meanings of maxIdleSwap vs.
> >> maxIdleBackup not sure why these two settings exist or what is
> >> difference between them and the practical use case for them? It is
> >> clear to me what the idle session is but  what is meant by backup and
> >> how is it different than a swap?
> >>
> >> Thanks
> >> Adib
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Martin Grotzke
http://www.javakaffee.de/blog/

Re: Understanding the Persistent Session Manager

Posted by Adib <am...@gmail.com>.
Thanks for the link that was useful. So the key idea to understand is
that there is a background thread that does all the cleanup and this
background thread executes on a timer not on very request arriving a
the server.

I am surprised at the limitations of the Persistent Manager it's that
it should be an easy thing to backup and load sessions on every
request. Is there something about how tomcat is implemented that makes
implementing persistence on load and save difficult?

Cheers
Adib

On Tue, Jan 25, 2011 at 4:24 AM, Reinwald Warapen
<re...@directi.com> wrote:
> On 1/25/2011 5:02 PM, Adib wrote:
>>
>> Hi,
>>
>> I am trying to understand the settings on the persistent session
>> manager on tomcat 6 and 7. It seems that the persistent session
>> manager is primarily meant for the purpose of swapping IDLE sessions
>> to persistent storage and then hope that they expire, I can see the
>> value of this given that many users abandon sites without logging out.
>> It also seems that the persisent manager is not designed to persist
>> every session at the end of every request so that at the start of
>> every request the session is read from the store and the end of the
>> request the session is written to store, is this understanding
>> correct.
>
> http://reinwaldwarapen.com/2011/01/17/storing-and-sharing-sessions-among-standalone-tomcat-instances/
>>
>> I have also been puzzling over the meanings of maxIdleSwap vs.
>> maxIdleBackup not sure why these two settings exist or what is
>> difference between them and the practical use case for them? It is
>> clear to me what the idle session is but  what is meant by backup and
>> how is it different than a swap?
>>
>> Thanks
>> Adib
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Understanding the Persistent Session Manager

Posted by Reinwald Warapen <re...@directi.com>.
On 1/25/2011 5:02 PM, Adib wrote:
> Hi,
>
> I am trying to understand the settings on the persistent session
> manager on tomcat 6 and 7. It seems that the persistent session
> manager is primarily meant for the purpose of swapping IDLE sessions
> to persistent storage and then hope that they expire, I can see the
> value of this given that many users abandon sites without logging out.
> It also seems that the persisent manager is not designed to persist
> every session at the end of every request so that at the start of
> every request the session is read from the store and the end of the
> request the session is written to store, is this understanding
> correct.
http://reinwaldwarapen.com/2011/01/17/storing-and-sharing-sessions-among-standalone-tomcat-instances/ 

> I have also been puzzling over the meanings of maxIdleSwap vs.
> maxIdleBackup not sure why these two settings exist or what is
> difference between them and the practical use case for them? It is
> clear to me what the idle session is but  what is meant by backup and
> how is it different than a swap?
>
> Thanks
> Adib
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org