Shared memory across mongrels


I have written an application which on initiliazation calculates a graph
based on data in DB. And then any updates on the graph(global variable)
, i am doing both on graph and db.

Everything works fine as long as i work on single mongrel. When i use 2
mongrels, second mongrel cannot see graph in the memory. It gets a null

How do i do this so that graph built in the memory is accessible to all

Sandeep G

How do i do this so that graph built in the memory is accessible to all
Save data to a DB, or to a session variable ?
remember it’s like having two separate processes–they don’t share
memory at all by default.

Any this really isn’t a “mongrel” issue, but more an issue with the
framework you’re using.

Sandeep’s question initial really simple, yet nobody has given him a
satisfactory answer.

I wonder if Rails 2.2 or later provides built in support to share memory
between multiple mongrel servers. I read that Rails 2.2 was
multi-threaded so technically shared memory should be an optin.

If not, Phusion Passenger makes similar claims, yet when I go through
it’s doco I can’t find any relevant pointers.


you may use a different ruby process to contain this graph and your
based rails processes may talk to this drb instance and access the
graph. 2
or more mongrel process do not share any data as they are completely
different processes.


There is no such facility. Passenger can’t do it either, copy-on-write
is an optimization, not a shared memory space.

Using a local memcached instance is the easiest way.

Multithreading is not shared memory across processes, but might give
you enough throughput that you only need to run one mongrel; then the
threads themselves will all share the same heap.


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