Memcached PHP Sessions

Reinis Rozitis roze at
Mon Feb 5 17:26:52 UTC 2007

> how can you make sure that memcached will not run out of memory and force
to make your session expired?

By suplying it with enough resources (ram).
If you are building a large site/project and you dont know the amounts of
data you will need to store/handle I would say you are pretty screwed at the

Calculating PHP session data is pretty simple cause its stored as serialised
string. You calculate the average string length multiply by active session
count and wolla you have the needed ram amount (okay add something for
internal structures).

If you run out of ram - stick one memory module in or just add one more
server to the pool. So easy it goes.

My $0.02 - we are running a website with 40 000 active php sessions on 1 mil
userbase and there are NO issues regarding sessions. We have dedicated a 2Gb
for this, after 52 days uptime there are ~4mil objects (each user has avg 4
old sessions) and takes like 1.4Gb - so plenty of space to grow up before
even throwing out the old items.

Try, it WORKS really well.


More information about the memcached mailing list