# Mongrel Cluster & Memcached Sessions Issues: session is lost

**URL:** <https://www.ruby-forum.com/t/mongrel-cluster-memcached-sessions-issues-session-is-lost/104242>\
**Category:** Rails\
**Created:** [May 15, 2007, 9:07pm UTC](https://www.ruby-forum.com/t/mongrel-cluster-memcached-sessions-issues-session-is-lost/104242 "2007-05-15T21:07:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlemos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@mlemos](https://www.ruby-forum.com/u/mlemos)\
**Post date:** [May 15, 2007, 9:07pm UTC](https://www.ruby-forum.com/t/mongrel-cluster-memcached-sessions-issues-session-is-lost/104242/1 "2007-05-15T21:07:21Z")

</div>

Gents,

I’m having very strange issues in my setup:

front-end: 1 x apache + mod\_proxy\_balancer  
app servers: 12 x mongrels  
session store: 1 x memcached (512MB)

I configured both the local session date (stored on memcached) for 29  
(seems that it cant be more than 30 days, this is a limitation of  
memcached) days of expiration and the session cookies for one year of  
expiration but my users still have to login again and again in very  
short periods of time.

My environment.rb has:

Rails::Initializer.run do |config|

# Memcache Configuration

memcache\_options = { :c\_threshold =\> 10\_000,  
:compression =\> true,  
:debug =\> false,  
:namespace =\> ‘[mysite.com](http://mysite.com)’,  
:readonly =\> false,  
:urlencode =\> false }

CACHE = MemCache.new(memcache\_options)  
CACHE.servers = ‘127.0.0.1:10001’

# Cache Storage Configuration

config.action\_controller.fragment\_cache\_store = CACHE, {}

# Session Storage Configuration

session\_options = { :cache =\> CACHE,  
:session\_key =\> ‘\_bbsession’,  
:session\_domain =\> ‘.mysite.com’,  
:session\_expires =\> 3.months.from\_now,  
:expires =\> 29.days }  
config.action\_controller.session\_store = :mem\_cache\_store  
ActionController::CgiRequest::DEFAULT\_SESSION\_OPTIONS.update(session\_options)

end

More, I tried to debug that and I could prove that after  
leaving/closing the browser and opening it again (not entering the site  
yet) both the local (memcached) and remote (cookies) session data is  
available, but mongrels don’t find them and then the user needs to login  
again.

I’m wondering if this is related to the load balancing or something  
else.

Any ideas, suggestions?

Manoel L.  
Computer Engineer  
Email: removed\_email\_address@domain.invalid
