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: [EMAIL PROTECTED]

Reply via email to