# MemCache Failed - Any alternatives?

**URL:** <https://www.ruby-forum.com/t/memcache-failed-any-alternatives/142292>\
**Category:** Rails\
**Created:** [July 6, 2008, 8:50am UTC](https://www.ruby-forum.com/t/memcache-failed-any-alternatives/142292 "2008-07-06T08:50:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajeshwar\_Mothe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@Rajeshwar\_Mothe](https://www.ruby-forum.com/u/Rajeshwar_Mothe)\
**Post date:** [July 6, 2008, 8:50am UTC](https://www.ruby-forum.com/t/memcache-failed-any-alternatives/142292/1 "2008-07-06T08:50:23Z")

</div>

Hi all,

Actually My Rails application configuration is on  
Apache/Mongrel/Rails.We  
are using Apache for balancing.We have clustered Mongrel and What we  
assume  
is happening is that we have a problem with RoR sessions. Currently,  
we’re  
running 3 mongrel servers (let’s call them A, B and C). Now assume a new  
session is created by Server A and the ID is passed to the client (web  
browser) as a cookie which will be passed back to the server in  
subsequent  
HTTP requests.Now assume such a request is handled by server B. Server B  
would try to lookup the object in its session store but wouldn’t find  
anything and hence,  
it would simply create a new session.Then we are getting Exception  
because  
session is not available at that point.We are Using Memcache and we came  
to  
a conclusion like we need to use another alternative to memcache for  
session  
storage.

So please let me know is there any alternative way to solve this  
problem? or  
do we need to chage the entire configuration ? If so, how we need to  
proceed  
further.

People said that this group is having expert brains,i forgot to post  
this  
question in past and i would be happy if any body gives any link or  
explain  
me how to resolve my issue.I would be great to you 🙂

Thanks in Advance !

Cheers,  
Kishan

---

<div class="post-metadata">

**Author:** ![Rajeshwar\_Mothe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@Rajeshwar\_Mothe](https://www.ruby-forum.com/u/Rajeshwar_Mothe)\
**Post date:** [July 6, 2008, 12:48pm UTC](https://www.ruby-forum.com/t/memcache-failed-any-alternatives/142292/2 "2008-07-06T12:48:05Z")

</div>

What are you using as a shared session store? If you’re clustering Rails  
application servers then they should all see the exact same data.

–  
Roderick van Domburg

> **[De domeinnaam Nedforce.nl is te koop.](http://www.nedforce.nl)**
>
> Deze mooie domeinnaam kan al over een paar minuten van jou zijn. Betalen gaat eenvoudig en vertrouwd via iDEAL. Direct na de betaling ontvang je de verhuiscode per e-mail en kun je aan de slag.

---

<div class="post-metadata">

**Author:** ![Rajeshwar\_Mothe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@Rajeshwar\_Mothe](https://www.ruby-forum.com/u/Rajeshwar_Mothe)\
**Post date:** [July 6, 2008, 10:08pm UTC](https://www.ruby-forum.com/t/memcache-failed-any-alternatives/142292/3 "2008-07-06T22:08:13Z")

</div>

You should be using DB-based session store. Memcache is for very high-  
traffic sites, don’t bother with it.

---

<div class="post-metadata">

**Author:** ![Rajeshwar\_Mothe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@Rajeshwar\_Mothe](https://www.ruby-forum.com/u/Rajeshwar_Mothe)\
**Post date:** [July 6, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/memcache-failed-any-alternatives/142292/4 "2008-07-06T23:08:16Z")

</div>

zeka wrote:

> You should be using DB-based session store. Memcache is for very high-  
> traffic sites, don’t bother with it.

There’s nothing wrong with using Memcache,  
the point of it is that it’s shared memory.

So, as long as all of your mongrels are pointing towards the same  
instance of memcache, then they will share that information.

Except,  
I believe memcache will not persist,  
so if we restart memcached, you’ll lose all the sessions.

So,  
you only really want to use it if your sessions dont need to persist.

I’d suggest using the :cookie\_session\_store which is the default session  
storage in rails 2.1, and stores all the data in the client side cookie,  
so there is no dependence on db or file system or memcache…

---

<div class="post-metadata">

**Author:** ![Rajeshwar\_Mothe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@Rajeshwar\_Mothe](https://www.ruby-forum.com/u/Rajeshwar_Mothe)\
**Post date:** [July 7, 2008, 9:44am UTC](https://www.ruby-forum.com/t/memcache-failed-any-alternatives/142292/5 "2008-07-07T09:44:22Z")

</div>

Kishan,

memcached works fine for session storage (although there are  
alternatives like db store, cookie store in RoR 2.x, etc.) so you  
shouldn’t have to switch if memcached is your preferred storage  
mechanism… based on your description of the problem, I’d wager that  
your various mongrel servers (A, B and C, as you label them) are each  
running an isolated instance of memcached, and are not sharing their  
content with the other memcached instances in the cluster… you need  
to re-configure memcached so that the 3 instances “share” their  
content (e.g. the “servers” directive in memcached.yml in case you’re  
using cache-fu)… also make sure that the firewall on each mongrel  
server allows connections on port 11211, which is the default port for  
memcached.

Good luck,

Peter
