Philip Mak wrote:
> 
> In the recent Hello World 2000 benchmark posted by Joshua Chamas, mod_perl
> handler was shown to be even faster than static HTML (at least for running
> hello world), and twice as fast as using Apache::Registry to run a perl
> script.
> 
> Does this mean that if there's a heavily used script on my system that
> needs to be VERY fast, then it may be worth making it into a mod_perl
> handler? What are the caveats of using mod_perl handlers instead of normal
> scripts?
> 

Its hard to explain, but try not to focus on the Hits/sec, instead
look at the sec/Hits.  Notice that the difference between
Registry CGI Raw and mod_perl handler is only ~ .00025 seconds.

Test Name                           Test File  Hits/sec   Total Hits Total Time 
sec/Hits   Bytes/Hit  
------------                        ---------- ---------- ---------- ---------- 
---------- ---------- 
Apache::Registry v2.01 CGI Raw      hello_raw.  669.9     40196 hits 60.00 sec  
0.001493   52 bytes   
mod_perl handler                    hello.benc  808.4     48522 hits 60.02 sec  
0.001237   197 bytes  

You could easily use that much time with a half page of perl code
for your application depending on what its doing, especially
if you are doing some heavy lifting like writing to a file,
or talking to a database.  Now if all you want to do is send 
a Location: header, and have apache write to the access_log,
then you might want to start rewriting some of your scripts
as mod_perl handlers.

Here's another way to look at Hits/sec as being bad to focus on.
Let's say you have something that is 1000/sec and something that
is 2000/sec, that's only .0005 different.  Most of the time
that .0005 is negligible compared to the time you will spend
in the executing part of the application, which lets say is .01
in execution time, now the overall execution time is .0110 and
.0105 which is 91/sec vs. 95/sec respectively.  So what looked
like something to be twice as fast is now only 4% faster.

But if you write some little fast code, then it can make all 
the difference in the world.  The reason I like Hello World,
is that it lets me know the fastest I can go in that app, 
but there's no guarantees I'll get there. :)

--Josh
_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Reply via email to