[Mongrel] MongrelCluster - How can I make a request to a specific mongrel instance?

Kirk Haines wyhaines at gmail.com
Thu Aug 24 19:32:11 EDT 2006

On 8/24/06, David Vrensk <david at vrensk.com> wrote:
> On 8/24/06, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote:
> >
> >         Memcached is indeed another option. Although it sounded like for
> > just one Singleton object cache that memcached would be overkill and
> > require yet another dependency for the app. DRb is built into ruby
> > and is very simple to use. So simple that he could most likely take
> > his singleton class and turn it into a drb server in about 4 lines of
> > code.
> I bet I'm not the only person who would like to see those four lines of
> code.  Pretty please?  With a cherry on top?

That's the lovely thing about DRb. It is so very simple to use.

require 'drb'
config = {:foo => 1, :bar => 'I am a config'}

require 'drb'
config = DRbObject.new_with_uri('drbunix://var/run/drbdemo.sock')
puts config[:foo]
puts config[:bar]

If I were doing this, I'd leave it nearly that simple if the site was
low use.  DRb is pretty fast.  I have serveral sites with applications
which share some common, low use resources in exactly this way, and it
works wonderfully.

However, if it were going to see a lot of hits, I'd just keep using a
local cache, as I mentioned, and setup a thread to wake up and run
every so often to sync the local cache to the remote one.

If the config object in the drb server has a reload() method or
something like that, any of the clients could trigger a config reload
by just calling it on the DRb object.

Very, very easy to implement.  Works well, and is standard in Ruby.
There's something to be said for that.

Kirk Haines

More information about the Mongrel-users mailing list