Java Mailing List Archive

http://www.apache-httpd.com/

Home » modperl.perl »

Re: mod_perl: performance tips

Torsten Foertsch

2008-06-26

Replies: Find Java Web Hosting

Author LoginPost Reply
On Wed 25 Jun 2008, tyju tiui wrote:
> but it is still way behind the C module (4 - 5 times fewer requests per
> second). Is mod_perl just that much slower than a pure C module?

Yes it is slower. MP registers hooks at almost all places possible. Your pure
C module probably uses only 1 or 2 of them.

I have seen a factor of 2-2.5 between a very simple PerlResponseHandler
(something like the code below) and a not heavily tuned Apache sending a
plain file consisting of 2 characters. I expect a C module to be even faster.

sub {
use Apache2::RequestRec ();
use Apache2::RequestIO ();
$_[0]->content_type('text/plain');
$_[0]->headers_out->set('Content-Length', 2);
$_[0]->print('ok');
0;
}

Note, without the Content-Length header it would be a lot slower in terms of
requests per second.

If you want performance write C. MP is a real performance gain (and drop of
the server load) compared with CGI loosing almost nothing of the flexibility.

So, disable all unnecessary hooks in mod_perl or even better compile them out
and allways send a Content-Length header. You can also try to write your
output to a temporary file and let the default handler send that file. That
may also speed it up (it'll use sendfile) but it depends.

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch@(protected)
©2008 apache-httpd.com - Jax Systems, LLC, U.S.A.