Why does my session table have 40 million records? |
I recently launched a site built on CodeIgniter. Today I learned that the session table has over 40 MILLION records in it. These are my session-related settings in the config file:
Code: $config['sess_driver'] = 'database'; What's the issue here? It's my understanding that the CI Session class periodically garbage collects this table, but it does not appear to be working properly. This query says there are 549706 distinct ip addresses in that able: Code: SELECT COUNT(DISTINCT ip_address) FROM `ci_session`
@sneakyimp
Are you following all the requirements mentioned in the documentation ( https://codeigniter.com/user_guide/libra...ase-driver )? (07-23-2018, 06:39 PM)php_rocs Wrote: @sneakyimp Can you be more specific? The site has successfully handled sessions for a couple of months since launch, we just have too many records in the session table.
What are the settings in php.ini for session.gc_probability and session.gc_divisor? If the first is 0 (zero) then that explains why no "garbage" ever gets "collected".
(07-23-2018, 09:08 PM)dave friend Wrote: What are the settings in php.ini for session.gc_probability and session.gc_divisor? If the first is 0 (zero) then that explains why no "garbage" ever gets "collected". Bingo! session.gc_probability was zero for some reason. I changed this value in the PHP.ini files and restarted apache and the new value has taken hold. I'll keep an eye on the table to make sure it gets emptied periodically. It's too bad there's no log where we can check if it is in fact being emptied. |
Welcome Guest, Not a member yet? Register Sign In |