Re: [mod_python] Sessions performance and some numbers
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Re: [mod_python] Sessions performance and some numbers




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: [mod_python] Sessions performance and some numbers  
Jim Gallacher


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-10-05 01:45 AM

dharana wrote:
> Any drawbacks if we just look at the mtime of the file? If it's older
> than cur_time - expiration_time then delete it. That way we wouldn't
> need to open it and check if it has expired. It would be uglier but it
> would be faster, and the whole purpose of creatnig FileSession was to
> maximize performance (at least that was my original purpose).

I was thinking along the same lines. This assumes that all sessions use
the same timeout value, forever, which may be a reasonable compromise.
As an additional check, any session files that fail the (cur_time -
timeout) > mtime could then be unpickled and verified before deleting.
Perhaps this second check could be an optional parameter passed in the
FileSession constructor?

In a separate reply Nicolas commented:
> I was thinking about this particular optimization, and it seems ok,
> provided the session is saved each time it is accessed.

As I understand it, the session must always be saved, otherwise the
value of sess._accessed cannot be known for previously exisiting sessions.

Anyway, here is my psuedo code:

def do_cleanup(self):
for sess_file in session_file_list:
if current_time - self._timeout > file_mtime(sess_file):
if self._verify_session_data_before_delete:
sess_data = cPickle.load(sess_file)
if session_has_expired(sess_data):
delete_file(sess_file)
else:
delete_file(sess_file)

Regards,
Jim


> Jim Gallacher wrote:
> 
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:47 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register