0

I am using memcached to store session data. The server handles less than 10 000 000 requests a day. I am using only %10 of RAM on the server at peak times. I'd like sessions to be available for long time, possibly more than 24 hours.

Is there any reason I should avoid setting gc_maxlifetime to 24 hours or any greater number?

Gajus
  • 69,002
  • 70
  • 275
  • 438
  • I'd say it's a waste of memcached for that, you should probably interface the session store with a [memcached/mysql hybrid](http://schlueters.de/blog/archives/152-Not-only-SQL-memcache-and-MySQL-5.6.html) to have long-time store in mysql and shorttime in memcached. – hakre Mar 14 '12 at 18:46
  • 1
    Additionally if memcached, why do you use `gc_maxlifetime` and the gc at all? You can just configure memcached to drop after timeout. – hakre Mar 14 '12 at 18:53
  • What difference does the latter make? – Gajus Mar 14 '12 at 18:57
  • 1
    You spare the overhead of PHP's garbage collection while memcached does it anyway. – hakre Mar 14 '12 at 18:58
  • How do I disable PHP's session garbage collector and set memcache to do it. No need for full answer, just references to reading on the topic would be appreciated. – Gajus Mar 14 '12 at 19:05
  • @Guy You can probably set `gc_divisor` to 0. – ceejayoz Mar 14 '12 at 19:08
  • 1
    Disable PHP GC collection: `session.gc_probability = 0;` - also if you use memcached it *might* get disabled automatically. For memcached see here: [memcached expiration time](http://stackoverflow.com/questions/967875/memcached-expiration-time) – hakre Mar 14 '12 at 19:11
  • Wouldn't that cause an error? Denominator cannot be 0. But setting `session.gc_probability` to 0 could do the trick. – Gajus Mar 14 '12 at 19:12
  • @hakre I've read the link you've given and some of the links that go from there. It is interesting. However, at the moment I am okay with wasting some of the resources. – Gajus Mar 14 '12 at 19:14
  • Well then, nobody stops you to raise the lifetime of the session up to 24 hours or greater. If you change something of the session format, take care you delete old sessions that are incompatible with the new format. – hakre Mar 14 '12 at 19:20

0 Answers0