From: Thomas Fini Hansen Date: 2004-06-21T20:46:16+09:00 Subject: Re: rubys web performance On Mon, Jun 21, 2004 at 04:09:19PM +0900, David Garamond wrote: > my experience with php seems to confirm this. php compilation is so fast > that it's okay to use PHP CGI for medium traffic and simple to medium > application complexity. I'd go with this, and the statement that PHPs syntax is 'optimized' for parsing. Actually it chokes on stuff like $obj->ary[$i]->value; (alledgedly it's improving in PHP5, like many other things). > *but*, if your application needs to compile 1000+ lines of php code on > every request (e.g. you include/require several libraries, like PEAR > modules), the overhead does start to show itself (0.5-1 seconds or more > of delay). True again. I often test things on an old 300Mhz box, to slow things down to a speed where I can actaully gauge the speeds. Larger projects like phpgroupware get extremely slow, which make you think twice before throwing them on the big iron. And don't forget that Ruby can be doing catchup when actually running the code. I've seen Ruby code that was several factors faster than the equvalent PHP code, doing a lot of throwing data around. > php cgi apps seems faster since most libraries are written in C, while > Perl's (and Ruby's) are written in pure Perl/Ruby code so they need to > compile many lines of code per request. but this situation is changing > everyday that PEAR is more and more used everyday... And while we're talking about lines.. I had to fix the code in SquirrelMail that encodes the headers when there's non-ASCII characters in it. Thought that it would be easy as I'd done my own in Ruby for another project and it was just 7 lines of code. Imagine my surprise when I found out that it was 118 lines of PHP code. About 10 was 'extra' code for stuff related to SquirrelMail. I couldn't resist, first I tried rewriting the function to exec Ruby. Slow as hell, but only 19 lines. Then I ported my Ruby function as well as I could and it ended up at 32 lines. So even if we subtract the 10 lines, it's still the difference between 7 and 22 lines. My own conclusion is that, while Ruby might be slow on the uptake sometimes, it's not because it's inheriently slower. -- Thomas beast@system-tnt.dk