eRuby and mod_ruby = *slow*?

Hi,

I’m new to Ruby. I’m currently using PHP for web development; it works
alright, but I find myself struggling with it just to get simple tasks
done so I’m doing a quick evaluation of Ruby to see if it fits my needs.
I created a simple Ruby script and ran ‘ab’ against it, just to get a
basic idea of mod_ruby + eRuby performance:

ruby_test.rhtml

···

===============

<% puts 'test' %>

Simple as can be. Some highlights from the ‘ab -n 100 -c 20’ results:

Time taken for tests:   11.856 seconds

Requests per second:    8.43 [#/sec] (mean)
Time per request:       2371.20 [ms] (mean)
Time per request:       118.56 [ms] (mean, across all concurrent

requests)

Connnection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   312  252.1    348   762
Processing:   356  1800  985.7   1423  5148
Waiting:      175  1766 1005.1   1385  5148
Total:        356  2111  855.9   1865  5148

Obviously this is just a simple benchmark, by no means comprehensive; if
there’s a better way of getting some ballpark figures on how Ruby
performs in this environment I’m all ears. I’m not expecting stellar
figures on a Pro 200 either, but they’re relative to what I’m getting
from PHP.

Anyway, those numbers are horrible. There was a thread I spotted where
someone stated mod_ruby is usually 95% as fast as PHP – definitely not
the case in my experience. For example, a PHP script that iterates over
an array with 10 elements and prints out each element’s value never
dropped below 135 requests/second in the same benchmark.

So what’s going on here? Why is it taking so long for eRuby to print
out a single line of text? Is it possible I’ve misconfigured something?
I’m not sure what information might be useful, so let me know if there’s
anything important I left out. Suggestions are greatly appreciated.
Thanks!

Regards,
Chris

Eruby creates a tempfile filled with ‘puts’ lines, then evals it. If
you use mod_ruby straight and a templating system (I hacked up RDoc’s
for my own purposes) you’ll have a faster and cleaner system.

Even still, you should be able to do better than 8 hits/sec. You may
want to send this along with more configuration info to the mod_ruby
list: modruby@modruby.net

···

Chris Fisher (cfisher@enteract.com) wrote:

Anyway, those numbers are horrible. There was a thread I spotted where
someone stated mod_ruby is usually 95% as fast as PHP – definitely not
the case in my experience. For example, a PHP script that iterates over
an array with 10 elements and prints out each element’s value never
dropped below 135 requests/second in the same benchmark.

So what’s going on here? Why is it taking so long for eRuby to print
out a single line of text? Is it possible I’ve misconfigured something?
I’m not sure what information might be useful, so let me know if there’s
anything important I left out. Suggestions are greatly appreciated.
Thanks!


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04