Forums / General / Good solution to get rid of old sessions.

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

eZ debug

Timing: Jan 18 2025 15:56:42
Script start
Timing: Jan 18 2025 15:56:42
Module start 'content'
Timing: Jan 18 2025 15:56:42
Module end 'content'
Timing: Jan 18 2025 15:56:43
Script end

Main resources:

Total runtime0.7321 sec
Peak memory usage4,096.0000 KB
Database Queries202

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00010.0083 588.9531180.8203
Module start 'content' 0.00840.5623 769.7734610.7500
Module end 'content' 0.57070.1613 1,380.5234337.3906
Script end 0.7320  1,717.9141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.5978210.0002
Check MTime0.00150.2053210.0001
Mysql Total
Database connection0.00070.098510.0007
Mysqli_queries0.651088.93312020.0032
Looping result0.00210.28092000.0000
Template Total0.696795.220.3484
Template load0.00200.279220.0010
Template processing0.694694.890820.3473
Template load and register function0.00010.019010.0001
states
state_id_array0.00110.145910.0011
state_identifier_array0.00120.158620.0006
Override
Cache load0.00180.2418350.0001
Sytem overhead
Fetch class attribute can translate value0.00130.181840.0003
Fetch class attribute name0.00150.208070.0002
XML
Image XML parsing0.00300.414240.0008
class_abstraction
Instantiating content class attribute0.00000.002480.0000
General
dbfile0.00580.7926340.0002
String conversion0.00000.000830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs