[Mongrel] Performance tweak when local files are not served by mongrel

Zed Shaw zedshaw at zedshaw.com
Tue Jun 20 10:45:45 EDT 2006


On Tue, 2006-06-20 at 09:39 +0200, François SIMOND wrote:
> Hello Zed !
> 
> I've experimented a simple but limited performance tweak in the mongrel
> rails loader.
> With the following apache 2.2 mod proxy loadbalancer setup :
> 
>   # Redirect all non-static requests to cluster
>   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
>   RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
> 
Can you explain how this set of statements differs from other
documentation people have posted for apache?  I'm currently writing the
docs for apache so I'm curious about alternatives.

> We can assume that mongrel is called only when the local file does not
> exist.
> I've tried to comment out code in rails loader that check if the local
> file, or the local file . ".html" exists
> Here are the benchmark on a simple action : (ab -n 5000 on mongrel itself)
> 
> Ignoring local files :    254 pages/s
> Checking local files :   245 pages/s

Ah, first if you can handle the cussing read:

http://www.zedshaw.com/blog/programming/programmer_stats.html


> That's an approx. 3.7% performance improvement.
> 

So you have a hypothesis that your changes produce a statistically
significant difference when compared with the previous version.  what
you need to do now is develop some evidence to find out if your
hypothesis is correct.  Re-run your tests with the following changes:

1) Stop using ab.  It's crap.  It's not clear how it measures most of
the activity.  Try httperf instead.
2) Don't run httperf on the same machine as you run mongrel.  Grab a
little laptop and hit mongrel over ethernet.
3) Make sure you use the same exact network, web app, machine,
everything, just change the version between your's and mine.  If you
can, don't even use rails, just test against the DirHandler in a little
test.
4) Run your test with very large runs (each one should take longer than
about 2 minutes) and repeat the runs many times (10 should do for now),
keeping results of each run.  We're interested in the requests/second,
but the test is a failure if you see any errors reported at the bottom
so re-run any failures.
5) Post the results as two csv files and I'll show you how I do the
statistics to find out if there's a statistical difference.  Results
just being a simple list of run#,req/sec but include other measurements
if you think they matter.

What you're trying to do with the above is to remove all possible
confounding elements (rails, apache, httperf/ab overload, network, etc.)
and then repeat your test multiple times just in case the one time you
ran it was a fluke.  Once you've gathered data your goal is to use stats
to figure out if there really was a difference.

> What would you think of a new command line option : --ignore-local-files ?
> 

What I'd rather do instead--and plan to do pretty soon--is break out the
DirHandler, RailsHandler, and "page caching" into three separate
chainable handlers and filters.  The Rails/DirHandlers were written
before I had chained handlers implemented, so simply writing them so
that they are chainable would mean people could just turn off whatever
they didn't need.  If apache is handling all files, then you'd just use
a RailsHandler.

But, do the experiment I describe above.  It'll be fun and you'll get a
glimpse at how I do things.


-- 
Zed A. Shaw
http://www.zedshaw.com/
http://mongrel.rubyforge.org/




More information about the Mongrel-users mailing list