Apache + Mongrel Cluster Caching (cross server)

Has anyone here successfully setup a system to take advantage of rails
page/action caching when using a mongrel cluster that spans multiple
servers? If so, could you shed some light on how you handled expiring
cache across multiple mongrel servers (physically different machines)?

I’m working on this now. I have two approaches:

  1. (Implemented) - If you control the URLs, put the timestamp of the
    resource in the URL linking to it. eg url_for(:product =>
    product, :timestamp => product.modified_at.to_i)

  2. Instead of using page caching, have Apache cache, use mod_cache.
    Then, set the expires header very short - Apache will ask Rails for
    the resource. But don’t return it if it’s still okay - see
    http://www.igvita.com/blog/2007/03/07/client-http-caching-in-rails/

(I have the headers in #2 working but have not turned on mod_cache
yet)
Let me know how your experience goes.

Action caching can be configured to use a shared fragment store - DRb
or Memcache fragment stores are supplied. Expiry from any server will
expiry the action for all servers, and, with Memcache, the store can
be distributed over a set of servers for redundancy.

Page caching will need some form of sharing of the cache directory
across machines - NFS would be the obvious choice, but I don’t know
how reliable this is, or how Rails or Apache behave when there are
network problems.

On 3/21/07, S. Robert J. [email protected] wrote:

  1. (Implemented) - If you control the URLs, put the timestamp of the
    resource in the URL linking to it. eg url_for(:product =>
    product, :timestamp => product.modified_at.to_i)
  1. Instead of using page caching, have Apache cache, use mod_cache.
    Then, set the expires header very short - Apache will ask Rails for
    the resource. But don’t return it if it’s still okay - see
    http://www.igvita.com/blog/2007/03/07/client-http-caching-in-rails/
  1. Use a SAN.

J.

I have it implemented and working for a long time using NFS mounts for
the public directory. But you don’t really need NFS specifically.
Anything you can mount and share across servers will work.

Bye,

Guy.

On 3/21/07, Justin [email protected] wrote:


Family management on rails: http://www.famundo.com
My development related blog: http://devblog.famundo.com