# Best practice for page\_caching with shared storage

**URL:** <https://www.ruby-forum.com/t/best-practice-for-page-caching-with-shared-storage/110635>\
**Category:** Deployment\
**Created:** [July 28, 2007, 4:15pm UTC](https://www.ruby-forum.com/t/best-practice-for-page-caching-with-shared-storage/110635 "2007-07-28T16:15:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwt137](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cwt137](https://www.ruby-forum.com/u/cwt137)\
**Post date:** [July 28, 2007, 4:15pm UTC](https://www.ruby-forum.com/t/best-practice-for-page-caching-with-shared-storage/110635/1 "2007-07-28T16:15:20Z")

</div>

I’m looking for comments, suggestions, best practices for handling  
page\_caching with shared storage.  
This is the scenario:

nginx box in front of multiple mongrel\_cluster boxes (Xen instances  
actually)

At the moment each mongrel\_cluster has its own public folder, though  
sub-folders of this are shared via symlinks, so the file data  
(principally images uploaded via attachment\_fu, and cached fragments)  
can be shared between the mongrel\_cluster instances and nginx.

I’m now adding some limited page\_caching, principally for the RSS feeds  
to start with. What do you think is the best way to handle this:

– share the whole public folder across everything

– put the cached pages into a subdirectory in public and have some sort  
of test in the nginx config file to see if the pages exist in there  
before passing on the request to the mongrel clusters

– some other suggestion.

Cheers  
Chris

## –

Autopendium :: Stuff about old cars  
[http://autopendium.com](http://autopendium.com)

---

<div class="post-metadata">

**Author:** ![cwt137](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cwt137](https://www.ruby-forum.com/u/cwt137)\
**Post date:** [July 30, 2007, 9:33pm UTC](https://www.ruby-forum.com/t/best-practice-for-page-caching-with-shared-storage/110635/2 "2007-07-30T21:33:37Z")

</div>

On Jul 28, 7:14 am, Chris T [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> can be shared between the mongrel\_cluster instances and nginx.
> 
> I’m now adding some limited page\_caching, principally for the RSS feeds  
> to start with. What do you think is the best way to handle this:
> 
> – share the whole public folder across everything

I’d recommend you look at clustered filesystems, rather than something  
like NFS.

I’d also seriously consider sharing RAILS\_ROOT in its entirety.

This improves deployment time (only one checkout!) and guarantees  
identical code on all nodes.

On the flip side, it eventually will cause a scaling problem as it’s  
shared-something. 🙂

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

---

<div class="post-metadata">

**Author:** ![cwt137](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cwt137](https://www.ruby-forum.com/u/cwt137)\
**Post date:** [July 31, 2007, 12:42am UTC](https://www.ruby-forum.com/t/best-practice-for-page-caching-with-shared-storage/110635/3 "2007-07-31T00:42:09Z")

</div>

removed\_email\_address@domain.invalid wrote:

> > At the moment each mongrel\_cluster has its own public folder, though  
> > I’d recommend you look at clustered filesystems, rather than something  
> > –  
> > – Tom M., CTO  
> > – Engine Y., Ruby on Rails Hosting  
> > – Support, Scalability, Reliability  
> > – (866) 518-YARD (9273)
> 
> >

Thanks Tom

By clustered filesystems (apologies for my ignorance) do you mean some  
sort of SAN. At the moment, I’m using one of the Xen instances as NFS,  
which works OK), and though I was thinking I’ll probably need to upgrade  
the storage as the site grows, it hasn’t so far been a problem.

If you shared RAILS\_ROOT in its entirety does this increase problems  
with the various servers trying to access the same files (obviously  
logging could be a problem – though that could presumably be solved by  
going to a Syslog solution – at the moment I’ve got each  
mongrel\_cluster handling its own logging)?

Any pointers for this self-taught sysadmin gratefully received.

Thanks  
Chris

## –

Autopendium :: Stuff about old cars  
[http://autopendium.com](http://autopendium.com)

---

<div class="post-metadata">

**Author:** ![cwt137](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cwt137](https://www.ruby-forum.com/u/cwt137)\
**Post date:** [July 31, 2007, 10:50pm UTC](https://www.ruby-forum.com/t/best-practice-for-page-caching-with-shared-storage/110635/4 "2007-07-31T22:50:42Z")

</div>

On Jul 30, 3:41 pm, Chris T [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks Tom
> 
> By clustered filesystems (apologies for my ignorance) do you mean some  
> sort of SAN. At the moment, I’m using one of the Xen instances as NFS,  
> which works OK), and though I was thinking I’ll probably need to upgrade  
> the storage as the site grows, it hasn’t so far been a problem.

You don’t necessarily need a SAN to implement a clustered filesystem,  
but it helps.

As an alternative, you could potentially use gnbd or vlbade on a Xen  
instances (or instances) to supply the SANishness required.

> If you shared RAILS\_ROOT in its entirety does this increase problems  
> with the various servers trying to access the same files (obviously  
> logging could be a problem – though that could presumably be solved by  
> going to a Syslog solution – at the moment I’ve got each  
> mongrel\_cluster handling its own logging)?

We’ve found logging to a different disk to be ideal. In our case we  
generally log to the /var partition.

While it’s convenient to have your logs in one place, we’ve found the  
performance penalty to be too high.

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

---

<div class="post-metadata">

**Author:** ![cwt137](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cwt137](https://www.ruby-forum.com/u/cwt137)\
**Post date:** [August 1, 2007, 1:07am UTC](https://www.ruby-forum.com/t/best-practice-for-page-caching-with-shared-storage/110635/5 "2007-08-01T01:07:56Z")

</div>

removed\_email\_address@domain.invalid wrote:

> > going to a Syslog solution – at the moment I’ve got each  
> > – Tom M., CTO  
> > – Engine Y., Ruby on Rails Hosting  
> > – Support, Scalability, Reliability  
> > – (866) 518-YARD (9273)
> 
> >

Thanks again for that Tom. I’ll look into the systems you suggest. From  
what you’re saying, though, it seems there’s no straightforward solution  
for the middle ground in which I’m in, though perhaps in the short-term  
(to get page-caching working properly, i.e. having the pages served by  
nginx rather than the mongrels), sharing the public folder on the NFS  
might be the best solution (with the mongrel\_clusters still logging  
locally).

This will allow me to gradually scale things (and thus concentrate on  
the app for a bit, not to mention marketing, maintenance, keeping up to  
speed with developments, etc).

Cheers  
Chris

## –

Autopendium :: Stuff about old cars  
[http://autopendium.com](http://autopendium.com)
