Summary: | Efficiency of the JDBCStore | ||
---|---|---|---|
Product: | Tomcat 6 | Reporter: | Grant Genereux <grant-genereux> |
Component: | Catalina | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED DUPLICATE | ||
Severity: | enhancement | ||
Priority: | P2 | ||
Version: | 6.0.18 | ||
Target Milestone: | default | ||
Hardware: | All | ||
OS: | All |
Description
Grant Genereux
2009-05-28 05:38:13 UTC
(In reply to comment #0) > Basically speaking; what StoreBase.processExpires() does is > > 1. Gets all the keys from the store ( in this case the JDBCStore) > 2. Loads all the sessions from the JDBCStore > 3. Removes and deletes any expired session. > > The problem is that in step 2 above, we’ve loaded all the fully de-serialized > sessions back into memory. This happens every few minutes with the default > configuration. > > So, at the time of the call to processExpires() the total amount of memory > being consumed by sessions is no less than if we had not swapped them out to > the store. Are you sure. Looking at the code it loops through the list of sessions doing steps 2 and 3 above for one session at a time rather than all sessions at once. (In reply to comment #1) > (In reply to comment #0) > > > Basically speaking; what StoreBase.processExpires() does is > > > > 1. Gets all the keys from the store ( in this case the JDBCStore) > > 2. Loads all the sessions from the JDBCStore > > 3. Removes and deletes any expired session. > > > > The problem is that in step 2 above, we’ve loaded all the fully de-serialized > > sessions back into memory. This happens every few minutes with the default > > configuration. > > > > So, at the time of the call to processExpires() the total amount of memory > > being consumed by sessions is no less than if we had not swapped them out to > > the store. > > Are you sure. Looking at the code it loops through the list of sessions doing > steps 2 and 3 above for one session at a time rather than all sessions at once. Thanks for the quick reply, Yes, but depending upon when the GC thread kicks in. If not during the: for (int i = 0; i lt keys.length; i++) then by the end of that statement, we'll have all the sessions back in memory. Yes, since the reference is not kept, the GC can collect them, but it could be a bit intensive. Thanks After some more thought; I think a more correct approach would be to have StoreBase.processExpires() call a method to just return the expired keys; rather than keys() (returns all keys). It would be very similar to keys() except it includes an additional where clause such as: AND ( valid_session = '0' OR ? .gt. (last_access+max_inactive*1000) ) With that change, only expired sessions will be re-loaded, and we maintain the session life-cycle contract. |