Is memcached a good way to store session share ammong web servers?

Vincent van Leeuwen memcached at
Mon Nov 13 10:37:19 UTC 2006

On 2006-11-12 23:13:24 -0500, Evert|Rooftop wrote:
> The best possible situation is:
> * don't let sessions expire
> * only update memcached and the database when session information is 
> updated (so record what the sessiondata was on the beginning of the script)
> * read session data from memcached.. if it isn't there, use the database
> But yea.. this will only work for non-expiring sessions. If you need 
> your sessions to timeout in a while, its harder because you need to keep 
> updating the databaseserver with the last request time..

No you don't. We keep 2 timestamps in memcached: last time the session was 
active, which is updated at each pageload, and last time the data in memcached 
was synced to the database. If the difference between the two timestamps is > 
5 minutes, we sync the data in memcached to the database and update the 
timestamps appropriately. Obviously, when we make any significant changes to 
the session data in memcached we sync it to the db immediately, so that we 
never lose important data when memcached goes down.

Isn't there a search function for this mailinglist somewhere? This topic has 
been covered MANY times.


Vincent van Leeuwen
Media Design -

More information about the memcached mailing list