Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

mod_perl: performance tips

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


jckdnk111 at yahoo

Jun 25, 2008, 7:57 AM

Post #1 of 8 (671 views)
Permalink
mod_perl: performance tips

Hi,

I'm curious to know if anyone has any mod_perl-specific performance tips?
I've scoured google but most of the performance tips are related specifically to perl which is good, but my application is still quite slow.

I managed to work out the same module in C and I got nearly 5 times the throughout (according to apache bench - ab) than perl module. I was shocked by this. C is all well and fine, but the c module is much less maintainable / portable (by me at least) compared to the perl module.

So I'm wondering if there might be some tips / tricks that you all might be able to share.

Any advice would be greatly appreciated.

Thanks,

Ty


christopher at tokpela

Jun 25, 2008, 8:19 AM

Post #2 of 8 (648 views)
Permalink
Re: mod_perl: performance tips [In reply to]

On Wed, June 25, 2008 7:57 am, tyju tiui wrote:
> Hi,
>
>
> I'm curious to know if anyone has any mod_perl-specific performance tips?
> I've scoured google but most of the performance tips are related
> specifically to perl which is good, but my application is still quite
> slow.
>
> I managed to work out the same module in C and I got nearly 5 times the
> throughout (according to apache bench - ab) than perl module. I was
> shocked by this. C is all well and fine, but the c module is much less
> maintainable / portable (by me at least) compared to the perl module.
>
> So I'm wondering if there might be some tips / tricks that you all might
> be able to share.
>
> Any advice would be greatly appreciated.
>
>
> Thanks,
>
>
> Ty

Hi Ty,

Try here:

http://www.modperlbook.org/

Specifically - Part II: mod_perl Performance


perrin at elem

Jun 25, 2008, 9:17 AM

Post #3 of 8 (646 views)
Permalink
Re: mod_perl: performance tips [In reply to]

On Wed, Jun 25, 2008 at 11:19 AM, Christopher Taranto
<christopher[at]tokpela.com> wrote:
> Try here:
>
> http://www.modperlbook.org/
>
> Specifically - Part II: mod_perl Performance

Yes, read that, profile your code, and then ask for help with specific
slow parts. There's lots of performance information in the docs on
the mod_perl site too.

- Perrin


adam.prime at utoronto

Jun 25, 2008, 9:19 AM

Post #4 of 8 (647 views)
Permalink
Re: mod_perl: performance tips [In reply to]

Quoting Perrin Harkins <perrin[at]elem.com>:

> On Wed, Jun 25, 2008 at 11:19 AM, Christopher Taranto
> <christopher[at]tokpela.com> wrote:
>> Try here:
>>
>> http://www.modperlbook.org/
>>
>> Specifically - Part II: mod_perl Performance
>
> Yes, read that, profile your code, and then ask for help with specific
> slow parts. There's lots of performance information in the docs on
> the mod_perl site too.
>
> - Perrin
>

for MP1 specific stuff, the guide has this section:

http://perl.apache.org/docs/1.0/guide/performance.html

Adam


jckdnk111 at yahoo

Jun 25, 2008, 1:24 PM

Post #5 of 8 (636 views)
Permalink
Re: mod_perl: performance tips [In reply to]

hmmm, I read the performance chapters from http://www.modperlbook.org/ but there really isn't much in the way of mod_perl-specific tweaks.
It's mostly about hardware tips, benchmarking tips, and apache server tweaks (and of course perl language tweaks).

The book recommended preloading perl modules which was helpful, 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?

The code is pretty simple and even uses most of the same libs as the C module.
What I'm saying is I don't think it's the code which is making such a huge difference ... I think mod_perl itself is the bottleneck.

Don't get me wrong, I'm not bashing mod_perl ... I had read in a few different places that mod_perl is on par or only slightly behind C for writing Apache modules. This is why I am searching for performance tweaks to begin with - also because I really want to use perl in place of C :-)

Ty


----- Original Message ----
From: Christopher Taranto <christopher[at]tokpela.com>
To: tyju tiui <jckdnk111[at]yahoo.com>
Cc: modperl[at]perl.apache.org
Sent: Wednesday, June 25, 2008 11:19:35 AM
Subject: Re: mod_perl: performance tips

On Wed, June 25, 2008 7:57 am, tyju tiui wrote:
> Hi,
>
>
> I'm curious to know if anyone has any mod_perl-specific performance tips?
> I've scoured google but most of the performance tips are related
> specifically to perl which is good, but my application is still quite
> slow.
>
> I managed to work out the same module in C and I got nearly 5 times the
> throughout (according to apache bench - ab) than perl module. I was
> shocked by this. C is all well and fine, but the c module is much less
> maintainable / portable (by me at least) compared to the perl module.
>
> So I'm wondering if there might be some tips / tricks that you all might
> be able to share.
>
> Any advice would be greatly appreciated.
>
>
> Thanks,
>
>
> Ty

Hi Ty,

Try here:

http://www.modperlbook.org/

Specifically - Part II: mod_perl Performance


mpeters at plusthree

Jun 25, 2008, 1:33 PM

Post #6 of 8 (639 views)
Permalink
Re: mod_perl: performance tips [In reply to]

tyju tiui wrote:
> hmmm, I read the performance chapters from http://www.modperlbook.org/ but there really isn't much in the way of mod_perl-specific tweaks.
> It's mostly about hardware tips, benchmarking tips, and apache server tweaks (and of course perl language tweaks).

mod_perl is the combination of Apache and Perl. So almost all of the performance
tips are about Apache and Perl.

> I think mod_perl itself is the bottleneck.

Maybe it's not mod_perl, but Perl itself, or your usage of it. Perl is not
as fast as C and depending on what you're doing it could be 4-5 times slower. Or
it could be that you're not writing very efficient Perl code.

> Don't get me wrong, I'm not bashing mod_perl ... I had read in a few different places that mod_perl is on par or only slightly behind C for writing Apache modules. This is why I am searching for performance tweaks to begin with - also because I really want to use perl in place of C :-)

I think it depends on what you're doing. Perl is definitely slower than C at
most things and the only places where it's faster are probably because coding
the faster solution in C is too costly.

But as others have mentioned on the list... you need to profile your code. See
(don't guess) where the bottlenecks are and then post here (or Perl monks, etc)
on advice on speeding things up. Just a warning though... if you change your
code to be better performant that usually comes with some
readability/maintainability loss too.

--
Michael Peters
Plus Three, LP


perrin at elem

Jun 25, 2008, 1:34 PM

Post #7 of 8 (640 views)
Permalink
Re: mod_perl: performance tips [In reply to]

On Wed, Jun 25, 2008 at 4:24 PM, tyju tiui <jckdnk111[at]yahoo.com> wrote:
> hmmm, I read the performance chapters from http://www.modperlbook.org/ but there really isn't much in the way of mod_perl-specific tweaks.
> It's mostly about hardware tips, benchmarking tips, and apache server tweaks (and of course perl language tweaks).

Well, that's really all there is to tune with mod_perl itself. The
rest is Perl.

> The book recommended preloading perl modules which was helpful, 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?

Is C 5 times faster than Perl? Yes, it often is for CPU intensive
number-crunching applications. Is that what you're doing?

> What I'm saying is I don't think it's the code which is making such a huge difference ... I think mod_perl itself is the bottleneck.

Since mod_perl is just the glue code between Apache and Perl, that
doesn't really make sense. The overhead of mod_perl compared to
running a C module is negligible. What's taking all the time is your
Perl code.

There are lots of tricks for improving the speed of Perl, but unless
you can show us some code, there's no way for us to help you. I still
suggest running your code through a profiler and then getting help
with the slowest parts, either here or on a general Perl discussion.

- Perrin


torsten.foertsch at gmx

Jun 26, 2008, 2:20 AM

Post #8 of 8 (623 views)
Permalink
Re: mod_perl: performance tips [In reply to]

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[at]gmx.net

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.