This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » General » Deleting ezsessions
expandshrink

Deleting ezsessions

Deleting ezsessions

Friday 28 September 2012 2:00:46 am - 5 replies

I have been reading up on ways to clean up my database before an upgrade - using cleanup.php and flatten.php

On my main live site, in the admin backend I can see that I have 61,215 "Sessions" with 492 anonymous users online.

1. Is this a lot?
2. Does this cover ALL of my 4 site accesses?
3. Is it possible to delete a number of the sessions, (say 100) at a time, or is it safe to delete them all in one go? I thought I read somewhere that this was possible, but now I cant find it.
4. Is it better to delete the sessions on the command line or in the web admin back-end?

I just ran the command on one of my test servers and it deleted ALL the sessions, not just the ones for the site access I stated.
/usr/local/php/bin/php /opt/local/httpd-2.2.14/htdocs/ezpublish-4.1.3/update/common/scripts/cleanup.php -s siteaccess_name session

Friday 28 September 2012 9:19:42 am

1. well, yes. Having many sessions is fine if you have a lot of traffic on your site happy.gif Emoticon For oldish eZ versions, sessions are always started even for anonymous visitors, while in more recent releases they are not. So the day you upgrade you will probably see a few less

2. yes (as long as they all share the same database)

3. both the cli script and the gui in admin do delete sessions 100 at a time, committing the transaction. This was an explicit change done a while ago to allow sites with 3 million sessions to still purge that table. Note that if you're on an old version you might have to upgrade to get this feature

4. if you have many sessions (many more than 60k), I'd go for the cli script, as deletion can take a while, and doing long tasks via web pages I don't like

Monday 01 October 2012 12:31:21 am

Quote from Gaetano Giunta :

1. well, yes. Having many sessions is fine if you have a lot of traffic on your site happy.gif Emoticon For oldish eZ versions, sessions are always started even for anonymous visitors, while in more recent releases they are not. So the day you upgrade you will probably see a few less

2. yes (as long as they all share the same database)

3. both the cli script and the gui in admin do delete sessions 100 at a time, committing the transaction. This was an explicit change done a while ago to allow sites with 3 million sessions to still purge that table. Note that if you're on an old version you might have to upgrade to get this feature

4. if you have many sessions (many more than 60k), I'd go for the cli script, as deletion can take a while, and doing long tasks via web pages I don't like

Thanks : )

Monday 01 October 2012 4:49:37 pm

If you don't care about users who might be logged in when you decide to cleanup your session (during the night for instance), then querying "TRUNCATE TABLE ezsession;" should be less than a one second query.

That is for a one-shot operation, then you can use the dedicated cronjob. You can use multiple cron executions with -s yoursiteaccess so that you control securely which sessions are dropped (and when...)

Modified on Monday 01 October 2012 4:51:59 pm by Arnaud Lafon

Thursday 04 October 2012 5:23:31 am

Quote from Arnaud Lafon :

If you don't care about users who might be logged in when you decide to cleanup your session (during the night for instance), then querying "TRUNCATE TABLE ezsession;" should be less than a one second query.

That is for a one-shot operation, then you can use the dedicated cronjob. You can use multiple cron executions with -s yoursiteaccess so that you control securely which sessions are dropped (and when...)

Is that a command to do in MYSQL Arnaud, or something to be done on the command line ?

I just deleted all sessions on the command line and now my site is running what feels like 3 to 4 times faster. Awesome : )

I thought it might take a while and cause the server to choke, but it was instantaneous. More so than deleting the expired sessions which I did first.

Thanks for all your tips.

Thursday 04 October 2012 9:37:01 am

Yes that's a SQL query and it can be done using the CLI with mysql -u username -p -e "truncate table ezsession;" you can directly add the password after -p but it's not secure since it will appear in the shell history either.

That said, if you have not experienced any slowdown during your operation, keep using your method happy.gif Emoticon

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from