dws has asked for the wisdom of the Perl Monks concerning the following question:

I'm facing a problem that might be deep, or might be a simple RTFM (without knowing what FM to R), and I'm hoping for some help trimming the search space.

In a web application I'm working on, I've noticing that some Apache mod_perl 2 processes are exiting after serving a single request. Since we're using https, I'd rather keep them alive longer to avoid the overhead of setting up a new SSL connection for every request. I'm reasonably sure that it isn't something obvious (e.g., a die() or exit() deep in some method), so I'm crafting some experiments to help make sense of the situation.

What can cause a mod_perl process to exit after serving a single request? Where are good places to start looking

(Apache is configured to expire a child process after it serves several thousand requests, so that isn't it.)

Replies are listed 'Best First'.
Re: What causes mod_perl processes to exit?
by perrin (Chancellor) on Jun 09, 2004 at 18:27 UTC
    You didn't say how you can tell they are exiting after one request. How do you know this?

    A process will exit if some code tells it to with an exit() or child_terminate() call, or if the system kills it because it went over rlimits or something. A die() call will never cause the process to exit.

      You didn't say how you can tell they are exiting after one request. How do you know this?

      I arranged to have Apache include %{pid}P in the log, then crunched the data. I see a handful of processes that serve exactly one request. I'm generating more data to crunch even now, to see if there's a discernable pattern.

Re: What causes mod_perl processes to exit?
by saskaqueer (Friar) on Jun 09, 2004 at 08:04 UTC

    Since you said "reasonably sure that it isn't something obvious", I'll just make sure you're "absolutely sure". Have you checked the error log? Must laugh heartily if the problem is logged in there :). Other than that, the only reason I know of would be a call to CORE::exit(). Anything else would have to be a bug, something very screwy, or something very obvious.

    update: Is this a pure mod_perl handler or are you using ModPerl::Registry? (For one, the CORE::exit() would only be under ModPerl::Registry, as that module overloads exit() so that any calls to a plain exit() do not actually exit the perl interpreter process)

      No exit(), CORE:: or otherwise. And nothing in the logs. (That's the first place I checked.)

      Updated: It's a pure handler.

Re: What causes mod_perl processes to exit?
by kragen (Sexton) on Jun 09, 2004 at 20:57 UTC
    FWIW there is some code in the system that calls CORE::exit and POSIX::_exit, but that code isn't running in this case.

    Turns out (according to dws) that some of the processes are lasting longer than a single request, but exiting as soon as they're called upon to serve a non-mod_perl request. (He added pid logging to access_log.)

      (kragen is about six feet away, if you're wondering. blakem is about 8 feet away, due to our rather... interesting office setup.)