[Raleigh-talk] mod_perl 2.0, mpm_worker, and ithreads

James Olin Oden james.oden at gmail.com
Thu Dec 6 13:22:14 PST 2007


On Dec 6, 2007 3:22 PM, Trevor Little <trevormg19 at gmail.com> wrote:
> Hey everybody,
>
> I'm hopping someone can lend me some experience with mod_perl 2.0,
> mpm_worker, and ithreads. Specifically, I'm trying to decide the best
> way to deploy mod_perl in a production environment and after reading
> through all the documentation I could absorb today, I'm still left
> with some questions. I should mention first that none of the code
> we've written uses threads, I'm just trying to figure out the
> benefits/disadvantages to running in a threaded mod_perl environment
> with mpm_worker.
>
> 1. How do I know if a cpan module I use is thread-safe? Is there any
> way to know for sure without reading all the code myself? We use a lot
> of CPAN modules and having to go back and check each one for thread
> safety, re-implementing the ones that are not, would keep me away from
> ithreads for now.
>
If they say they are in their documentation.  Otherwise its likely
that they are but YMMV.

> 2. Some of our cgi scripts override signal handlers and fork their own
> children. Is that going to play nice in a threaded environment break
> things?
>
Not according to the perlthrtut man page...look for fork() within it.
That said, I have done it and it seems to work.

> 3. Is there a performance benefit to running mod_perl with mpm_worker
> if almost all requests to the server will be to a cgi application?
> I've read people who've said that perl's memory usage with threads is
> worse than with pre-fork, and I've read documentation that seems to
> imply the opposite.
>
Read the perlthrtut man page, but the bottom line is that for each
thread a whole new perl interpret
gets created.  This is why its called ithread (interperter Threads).
Thats an expensive operation.  OTOH if you do this at start or not so
often its not so bad.

In the particular case of mod_perl you may want to look towards a
mod_perl list or perhaps their docos.

Cheer...james

P.S. I have used ithreads for production app written from the ground
up but I have not used mod_perl.


More information about the Raleigh-talk mailing list