Scot Martin wrote:
mp1.99.10-dev Apache 2.0.47 Solaris 8

I'm building a single-purpose, high-performance, multi-threaded application
server using the above and have run into problems with forking and cleanup
of old httpd instances.  Yes, I have to fork and exec as I have to call
some legacy C code and then set up comms between the exec'd process and
Apache.


My first problem comes when loading the server heavily I occasionally see an instance that forked properly, but the child never wakes up and runs. I
only see this behavior when pushing 10 or so requests per second at the server. There's probably 3 per minute of these so it's a real needle in a haystack. Any thoughts on how to prevent this and/or kill the errant kid?



The second problem is after a half hour or so of slamming requests at an Apache instance, the kid hangs. The parent proc does the right thing and starts another kid but since the first kid is hung, my reaper doesn't do its job and I end up with a bunch of zombies until I slay the kid. I've tried setting MaxRequestsPerChild to various values but that doesn't help -
in fact, it doesn't seem to do anything. Am I missing something?

See if using Apache::SubProcess helps.


Lastly, cleanup_for_exec() doesn't seem to work - with tracing on I can see
that we get into APR::Pool but the return status is always zero. I've tried $r->APR::Pool::cleanup_for_exec() and a bald &APR::Pool::cleanup_for_exec().
[...]

There is no $r->cleanup_for_exec() in mp2, there is
APR::Pool::cleanup_for_exec(), which accepts no arguments, returns no result
and does:

/* Preparing for exec() --- close files, etc., but *don't* flush I/O
 * buffers, *don't* wait for subprocesses, and *don't* free any memory.
 */
/**
 * Run all of the child_cleanups, so that any unnecessary files are
 * closed because we are about to exec a new program
 */
APR_DECLARE(void) apr_pool_cleanup_for_exec(void);

which internally calls cleanup_pool_for_exec(global_pool). But you don't need
to use it if you are using Apache::SubProcess, since it internally calls this function. You can see some tests in the test suite, however more tests are needed and you are very welcome to extend them, especially if you find that something doesn't work.


By the way, I've seen a few people ask about how to do zombie cleanup. I tried all sorts of ways and the only way I found to work on Sol 8 was this:



use POSIX 'WNOHANG'; use POSIX ":sys_wait_h"; my($kid); do { $kid=waitpid(-1,WNOHANG); } until $kid <= 0;

if(!(defined ($pid = fork()))) { ...

Have you read: http://perl.apache.org/docs/1.0/guide/performance.html#Avoiding_Zombie_Processes

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to