Are Mongrel instances "sticky" with respect to sessions?

All,

If you deploy multiple Mongrel instances, is it possible to have
affinity between a given session (e.g. session id) and a Mongrel
instance? How is that done?

Thanks,
Wes

On Jan 23, 2007, at 2:06 PM, Wes G. wrote:

If you deploy multiple Mongrel instances, is it possible to have
affinity between a given session (e.g. session id) and a Mongrel
instance? How is that done?

Hello Wes.

Session affinity is generally achieved at the load balancer level,
and Apache 2.2 supports this as well.

See http://httpd.apache.org/docs/2.2/mod/mod_proxy.html and search
locally for lbmethod for details.

Why do you want session affinity? It makes a ton of sense is HUGE
installations, but not so much for smaller ones.


– Tom M., CTO
– Engine Y., Ruby on Rails Hosting
– Reliability, Ease of Use, Scalability
– (866) 518-YARD (9273)

Why do you want session affinity? It makes a ton of sense is HUGE
installations, but not so much for smaller ones.

Because I ended up having to use a custom in-memory persistence scheme
to handle objects that were too large to place on the session (and would
cause Rails to crash during session serialization/deserialization). So
I have a hash which stores some larger things (parsed HTML and Excel
spreadsheet data) that I would like to keep around across requests given
the relatively high cost of generating them.

If I need to go to two or more Mongrels (which I almost certainly will),
the hashes will be private to each Mongrel instance (Ruby process) and
won’t be shared. Which of course, implies that I might end up
generating these objects up to N times where N is the number of Mongrel
instances.

So I would like to either take advantage of session affinity for a given
Mongrel process to be sure that a given artifact generated on behalf of
a given user and managed in my hash is only generated once.

If session affinity doesn’t work with Mongrel, then I guess I can look
into Drb.

Thanks,
Wes

Tom M. wrote:

Session affinity is generally achieved at the load balancer level,
and Apache 2.2 supports this as well.

See http://httpd.apache.org/docs/2.2/mod/mod_proxy.html and search
locally for lbmethod for details.

Tom,

Thanks. Just looked at the Apache docs. and I see how this appears to
be supported.

Wes

Wes G. wrote:

If session affinity doesn’t work with Mongrel, then I guess I can look
into Drb.

Thanks,
Wes

Check out memcached -

http://nubyonrails.com/articles/2006/08/17/memcached-basics-for-rails

sounds like your scheme implements a subset of what memcached already
does.

HTH,

-b

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