Jump to content
Larry Ullman's Book Forums

Session Garbage Collection


sandy
 Share

Recommended Posts

Started looking at my directory of session files and it seems like they are never getting garbage collected.

 

I started looking around in the Yii codebase and in v1.1.13 they had what looked like a default setting of 1%

 

In v1.1.14 it seems that code has been removed to allow the default of php.ini to be the default. When I looked at the php.ini in the Amazon AWS (AMI Linux) it was something like this -

 

session.gc_probability = 1
 

and

 

session.gc_divisor = 1000

 

Which gives a .1% chance by default. So the default in 1.1.14 is not 1%, but 0.1% unless set.

 

I'm not sure if this is the problem why I have not seen a GC in the subdirectory but I'm going to set the default in code to see if it does change.

 

One perplexing note is that is in php.ini is mentions this -
 

 NOTE: If you are using the subdirectory option for storing session files
;       (see session.save_path above), then garbage collection does *not*
;       happen automatically.  You will need to do your own garbage
;       collection through a shell script, cron entry, or some other method.
;       For example, the following script would is the equivalent of
;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
;

;       find /path/to/sessions -cmin +24 | xargs rm

 

 

Has anyone else run into this where no GC is taking place due to the default save dir being change?

 

Sandy
 

Link to comment
Share on other sites

I don't think this has anything to do with the save dir. You just don't have enough activity to trigger garbage collection. If there's only a 1% chance of GC taking place, then you'll have to perform 100 requests of session pages in order to reliably trigger garbage collection once. And that will only clean up the old stuff. This is all very common in development mode.

Link to comment
Share on other sites

 Share

×
×
  • Create New...