Good solution to get rid of old sessions.

Author Message

Martin Kot

Monday 21 July 2008 7:21:13 am

I've got this typical eZ problem where the session table grows to quite unmanageable size after some time. I would like to get some tips on how to do it correctly. I did a small test with cleanup.php, eZ 3.9.1 where I ran:

[code]
./update/common/scripts/cleanup.php -s siteaccess expired_session
[/code]

The script ran for a very long time, but the number of rows in table 'ezsession' was just the same afterwards. So I was kind of disappointed.

Then I found this extension, which looks promising, I haven't tried it yet though.
http://projects.ez.no/session_cleanup

My question is, what are you guys usually doing/using to get rid of old sessions? If I don't get i to work, I'm probably just going to be a bit rude and run a cron script late at night that truncates the ezsession table. The database is mysql 5.0.11 and 4.1.11, InnoDB as engine type. I'm currently dealing with eZ publish 3.9.1 and 3.8.4 respectively.

Ivo Lukac

Monday 21 July 2008 10:45:13 am

Hi Martin,

You probably have Debian or Ubuntu running on which PHP has an issue with session disposal. Your ezsession table is grown big so try giving to cleanup script more time (with -d set_time_limit). If it doesn't help I would try to cleanup all session and put your expired_session script in cronjob every night.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Martin Kot

Monday 21 July 2008 3:04:02 pm

That is correct, it is on Debian. Thanks for the suggestion, I am going to truncate the table and give the script another chance as a cron job.

Andreas Kaiser

Tuesday 22 July 2008 1:31:20 am

Hi,

we're launching a project where this could be an issue. We were planning to use Debian as server. What alternatives could we use...

Does this affect ezp4 or any ezp installed on Debian.

Because it's Debian related, it's related with this post?

http://oscarm.org/news/detail/666-debian_php5_and_session_garbage_collection

EDIT: I've been investigating this and found also these posts:

http://www.simplemachines.org/community/index.php?topic=211513.0
http://forum.kohanaphp.com/comments.php?DiscussionID=565
http://issues.ez.no/IssueView.php?Id=12491&activeItem=1

So changing "gc_probability > 0" in php.ini could solve this?? I'm not very experienced with this, so please correct me if I'm posting nonesense ;)

Thanks,
Andreas

eZ Partner in Madrid (Spain)
Web: http://www.atela.net/

Ivo Lukac

Tuesday 22 July 2008 4:03:59 am

Hi Andreas,

Don't know about this tweak but if you put cleanup of expired_sessions in cronjob every night your ezsession table should not grow (it size will depend on number of site users and session timeout settings)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 04:34:55
Script start
Timing: Jan 31 2025 04:34:55
Module start 'layout'
Timing: Jan 31 2025 04:34:55
Module start 'content'
Timing: Jan 31 2025 04:34:55
Module end 'content'
Timing: Jan 31 2025 04:34:55
Script end

Main resources:

Total runtime0.0125 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.2578151.2266
Module start 'layout' 0.00540.0025 739.484436.6641
Module start 'content' 0.00800.0035 776.148494.1406
Module end 'content' 0.01140.0010 870.289137.9922
Script end 0.0125  908.2813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002217.3203140.0002
Check MTime0.00097.3917140.0001
Mysql Total
Database connection0.00108.052610.0010
Mysqli_queries0.002318.501130.0008
Looping result0.00000.120010.0000
Template Total0.00086.110.0008
Template load0.00064.809110.0006
Template processing0.00021.270410.0002
Override
Cache load0.00043.281610.0004
General
dbfile0.00021.660880.0000
String conversion0.00000.072440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs