Rails sessions in memcached

Hello. I have a quick question regarding storing rails sessions in
memcached. Based on what I’ve read, it seems like storing sessions in
memcached is one of the fastest session stores for Rails. The question
I have has to do with premature ageing out of session objects due to
cache pressure coming from other objects in memcached. How does one
deal with this? Is there a way to segment memcached to disallow ageing
out of session objects due to cache pressure coming from other objects
that I might want to store in memcached?

Thanks for any help here.

On 11/24/06, Sam [email protected] wrote:

Hello. I have a quick question regarding storing rails sessions in
memcached. Based on what I’ve read, it seems like storing sessions in
memcached is one of the fastest session stores for Rails. The question
I have has to do with premature ageing out of session objects due to
cache pressure coming from other objects in memcached. How does one
deal with this? Is there a way to segment memcached to disallow ageing
out of session objects due to cache pressure coming from other objects
that I might want to store in memcached?

Memcache doesn’t work like that, items don’t expire or get deleted to
make room for new items. Memcache can expire items according to how
you configure it, or not expire items at all. I haven’t looked at any
of the memcache session stores for ruby, but in most cases memcache is
used with some sort of permanent backing storage, because memcache
just uses memory and if you stop memcached you lose everything in the
cache.

Chris

Ok, so it is a good idea to then store sessions in memcached? I don’t
believe Rails maintains a backing store for these sessions. Rails
filestore doesn’t seem right as it would require too many disk I/Os. I
read a document on Rails sessions management and it seems like memcached
does the job and will allow us to scale across multiple machines when
the time comes.

It seems like if the cache is full and we store in sessions in the cache
then a user will no longer be able to login due to memcache becoming
full. I really would not want to manage such code in my controllers to
force invalidate other objects to allow for new logins. Anybody have
any good ideas here?

Thanks.

snacktime wrote:

On 11/24/06, Sam [email protected] wrote:

Hello. I have a quick question regarding storing rails sessions in
memcached. Based on what I’ve read, it seems like storing sessions in
memcached is one of the fastest session stores for Rails. The question
I have has to do with premature ageing out of session objects due to
cache pressure coming from other objects in memcached. How does one
deal with this? Is there a way to segment memcached to disallow ageing
out of session objects due to cache pressure coming from other objects
that I might want to store in memcached?

Memcache doesn’t work like that, items don’t expire or get deleted to
make room for new items. Memcache can expire items according to how
you configure it, or not expire items at all. I haven’t looked at any
of the memcache session stores for ruby, but in most cases memcache is
used with some sort of permanent backing storage, because memcache
just uses memory and if you stop memcached you lose everything in the
cache.

Chris

On 11/24/06, Sam [email protected] wrote:

full. I really would not want to manage such code in my controllers to
force invalidate other objects to allow for new logins. Anybody have
any good ideas here?

You manage it the same way you do any other store. If your filesystem
runs out of space when using database/file storage it’s no different
then if memcached runs out of memory.

Chris

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs