[Mongrel] memcache and mongrel_cluster configuration question

Reese, Terry terry.reese at oregonstate.edu
Mon Aug 20 20:05:04 EDT 2007


I'm assuming that what I'm trying to do is a fairly common on this list,
so I'm hoping someone can help me out.  We are deploying a rails app.
using multiple mongrels, managed by mongrel_cluster and apache's
mod_balancer.  All config information is below.  As part of our setup,
we use memcache for sessioning -- which is my current problem.  Sessions
are being set, however, it seems that each mongrel instance is
maintaining its own copy of the session data (does that make sense?).
What I'm seeing is that as data is being placed into session variables,
occasionally, an older instance of a session variable will be
resurrected.  So if I'd placed "water" in a session variable to be used
for some action and then placed "fish" in the session variable to use
for some actions -- when I do those actions, sometimes I'm getting
"water" back when I query the session variable.  It's almost like each
mongrel instance is using it's own "memcache" -- which doesn't make
sense because we only have a single memcache server running.   
 
Any suggestions are welcome.  
 
Thanks, 
 
--TR
 
Any, here's our setup:
 
10 mongrels running on 1 server, managed by mongrel_cluster
1 memcache server, running on localhost
 
httpd-vhost config info:
 
<VirtualHost 127.0.0.1:80>
  SetEnv RAILS_ENV development
  ServerName server.oregonstate.edu
  ServerAdmin xx at c.com
  DocumentRoot /usr/local/apache-lf/rails/public/
  ErrorLog /usr/local/apache-lf/rails/log/error.log
  CustomLog /usr/local/apache-lf/rails/log/access.log common
 
  <Location /balancer-manager>
    SetHandler balancer-manager
    Order Deny,Allow
    Deny From all
    Allow from 127.0.0.1 
  </Location>
 
  RewriteEngine On
  RewriteRule ^(.*/)?.svn/ - [F,L]
 
  ProxyPass /balancer-manager !
  ProxyPass /balancer-manager/ !
  ProxyPass /images/ !
  ProxyPass /stylesheets/ !
  ProxyPass /javascripts/ !
  ProxyPass /error/ !
  ProxyPass /icons/ !
  ProxyPass / balancer://libraryfind/ stickysession=STICKY_ROUTE
  ProxyPassReverse / balancer://libraryfind/
  ProxyPreserveHost On
 
  <Proxy balancer://libraryfind>
     BalancerMember http://127.0.0.1:4010 route=lf-4010
     BalancerMember http://127.0.0.1:4011 route=lf-4011
     BalancerMember http://127.0.0.1:4012 route=lf-4012
     BalancerMember http://127.0.0.1:4013 route=lf-4013
     BalancerMember http://127.0.0.1:4014 route=lf-4014
     BalancerMember http://127.0.0.1:4015 route=lf-4015
     BalancerMember http://127.0.0.1:4016 route=lf-4016
     BalancerMember http://127.0.0.1:4017 route=lf-4017
     BalancerMember http://127.0.0.1:4018 route=lf-4018
     BalancerMember http://127.0.0.1:4019 route=lf-4019
  </Proxy>
 
  <Directory "/usr/local/apache-lf/rails/public">
     Options +FollowSymlinks +ExecCGI
     AllowOverride All
     Order allow,deny
     Allow from all
  </Directory>

 
environment.rb memcache config info:
# Within the Rails::Initializer do block
config.action_controller.session_store = :mem_cache_store
 
#Outside the block
 
memcache_options = {
   :compression => true,
   :debug => false,
   :namespace => "mem-#{RAILS_ENV}",
   :readonly => false,
   :urlencode => false
}
 
CACHE = MemCache.new 'localhost:11211', :namespace => "mem-#{RAILS_ENV}"
ActionController::Base.session_options[:cache] = CACHE

 
*******************************************
Terry Reese
Cataloger for Networked Resources
Digital Production Unit Head
Oregon State University Libraries
Corvallis, OR  97331
tel: 541-737-6384
email: terry.reese at oregonstate.edu
http: http://oregonstate.edu/~reeset
******************************************* 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070820/160e6071/attachment.html 


More information about the Mongrel-users mailing list