Hi,
I am migrating from a standard php website on ubuntu to fuel.
With our php website on ubuntu, there is a cronjob that's trying to cleanup session file regularly, in /etc/cron/php5:
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete
Do I still need this with fuel on ubuntu, or not?
I believe not, but want to be really sure, so that we don't end up killing our servers with too many session files...
thanks.
Laurent
FuelPHP has drivers for several session storage backends. It doesn't use PHP's native session storage.
Both the file and the DB drivers have a garbage collection routine, triggered by the config value gc_probability. The cookie driver doesn't need one, the memcached and redis drivers rely on internal garbage collection mechanisms.
I should have specified that I am using the 'file' driver.
So my understanding is that I can disable that cronjob, if i am wrong, let me know.
thanks a lot for the help!
Laurent
As always, the answer is "it depends".
The file storage driver does have a garbage collection routine. The gc_probability value (0-100) defines the percentage of chance it will kick in after a session write. So the higher the number, the more chance on a clean-up.
Downside of this mechanism is that the cleanup is part of the user request. It will run in the shutdown event so after the page has been send to the client, but the client will see "loading..." while this process runs because as far as the webserver is concerned, the request isn't finished yet.
This is not an issue if there is not a lot to clean up, but if you have a busy site with thousands of session files, it's a lot of disk I/O and it may take a while. You have to determine for yourself if you want to use the built-in mechanism, and if so, what gc_probability should be (clean up often means less files to delete), or if you want to keep using the cron job.