We have one site that is on the busy side and the sessions table is getting, shall we say, on the largish side (303k records). I'm looking at reducing that. I'm assuming this would be done in settings.php.
ini_set('session.cache_expire', 200000); ini_set('session.cache_limiter', 'none'); ini_set('session.cookie_lifetime', 2000000); ini_set('session.gc_maxlifetime', 200000);
My question: Which of these settings should we cut down to reduce the number of records? (We don't want to log people out upon closing the browser, so that approach is out.)
Would I cut down the cookie_lifetime?
Any help would be much appreciated. Thanks!
Laura, the MySQL klutz
On Thu, 13 Jul 2006 10:50:02 -0600 Laura Scott laura@pingv.com wrote:
We have one site that is on the busy side and the sessions table is getting, shall we say, on the largish side (303k records). I'm looking at reducing that. I'm assuming this would be done in settings.php.
Out of curiousity, what problems are you experiencing from your large sessions table? That is, what is prompting you to want to reduce the size of this table? I've had the table get more than ten times that size without experiencing any problems.
ini_set('session.cache_expire', 200000); ini_set('session.cache_limiter', 'none'); ini_set('session.cookie_lifetime', 2000000); ini_set('session.gc_maxlifetime', 200000);
My question: Which of these settings should we cut down to reduce the number of records? (We don't want to log people out upon closing the browser, so that approach is out.)
Would I cut down the cookie_lifetime?
There's a comment in session.inc that may help: // Be sure to adjust 'php_value session.gc_maxlifetime' to // a large enough value. For example, if you want user // sessions to stay in your database for three weeks before // deleting them, you need to set gc_maxlifetime to // '1814400'. At that value, only after a user doesn't log // in after three weeks (1814400 seconds) will his/her // session be removed.
In your case, you could make gc_maxlifetime smaller which will cause sess_gc() to delete unused sessions quicker...
Cheers, -Jeremy
On Jul 13, 2006, at 11:21 AM, Jeremy Andrews wrote:
Out of curiousity, what problems are you experiencing from your large sessions table? That is, what is prompting you to want to reduce the size of this table? I've had the table get more than ten times that size without experiencing any problems.
Quite a few people have been having trouble logging in -- mostly new users, but when a few each week are reporting this, we were concerned.
The sessions table thing did not occur to me, and I'm not convinced that this was even related, but our hosting sysadmin thought it might be on the large side. (It's nothing compared with the watchdog table, which fills up with 404s of nonsensical URLs to the point of around 2MB of entries a day. It's mostly crawlers that don't honor robots.txt, but until badbehavior scales properly, we're stuck with chasing down IP addresses.)
Thanks for the heads up on the sessions.inc comment. If it's documented there, maybe it should be documented in the settings.php file, where the setting is actually set. (?)
Laura