# Memcached and fragment storage, session storage with a mongr

**URL:** <https://www.ruby-forum.com/t/memcached-and-fragment-storage-session-storage-with-a-mongr/113999>\
**Category:** Rails\
**Created:** [September 6, 2007, 11:50pm UTC](https://www.ruby-forum.com/t/memcached-and-fragment-storage-session-storage-with-a-mongr/113999 "2007-09-06T23:50:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cleaner416](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d26b3c/32.png) [@cleaner416](https://www.ruby-forum.com/u/cleaner416)\
**Post date:** [September 6, 2007, 11:50pm UTC](https://www.ruby-forum.com/t/memcached-and-fragment-storage-session-storage-with-a-mongr/113999/1 "2007-09-06T23:50:27Z")

</div>

Greetings,

I’ve been using file-based fragment caching and DB-based session  
caching quite extensively. I decided to try out memcached for both to  
see if I could achieve a performance gain.

I searched around a bit and simply added two lines to my  
development.rb:

config.action\_controller.fragment\_cache\_store = :mem\_cache\_store  
config.action\_controller.session\_store = :mem\_cache\_store

(I also changed config.action\_controller.perform\_caching = true for  
testing )

This works like a charm on my development box. I’ve got memcached -vv  
running in another terminal window I can see it doing it’s thing.

However, as soon as I tried this on my production box, (by adding the  
above lines to production.rb) I ran into some odd problems. My  
production setup is pretty vanilla: Apache 2.2 load balancing to a  
couple of mongrel instances via mongrel cluster on a fedora core 5  
box. It seems as if a memcache pool is being created for each  
mongrel instance, instead of the app. Is there some other kind of  
config I need to do in production.rb? The stuff I’ve found via  
googling seems to apply to Rails \< 1.2

Thanks much

---

<div class="post-metadata">

**Author:** ![cleaner416](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d26b3c/32.png) [@cleaner416](https://www.ruby-forum.com/u/cleaner416)\
**Post date:** [September 7, 2007, 12:56am UTC](https://www.ruby-forum.com/t/memcached-and-fragment-storage-session-storage-with-a-mongr/113999/2 "2007-09-07T00:56:32Z")

</div>

> config.action\_controller.session\_store = :mem\_cache\_store  
> couple of mongrel instances via mongrel cluster on a fedora core 5  
> box. It seems as if a memcache pool is being created for each  
> mongrel instance, instead of the app. Is there some other kind of  
> config I need to do in production.rb? The stuff I’ve found via  
> googling seems to apply to Rails \< 1.2

I don’t know the specific answer, but it might be a memcache key prefix  
issue. You can set a namespace for memcache and it will prefix every  
key  
with that. Perhaps with what you have above the prefix is using  
something  
unique to each mongrel instance (like it’s pid or port).

Not a fix, but maybe will help guide you…

good luck.
