I really need to be able to do what I believe apache_child_terminate does, but apparently it doesn't work when using Apache2 (and that is what I am using... Apache 2 in prefork mode).
Is there an equivalent way I can "get rid of" or kill the currently executing Apache process after I finish fulfilling the current request?
Background:
Thanks in advance for any suggestions!
Ok, so this code basically does the apache_child_terminate() equivalent for Apache 2 by nicely telling the Apache process to die after completing the request:
<?php
// Terminate Apache 2 child process after request has been
// completed by sending a "friendly" SIGWINCH POSIX signal (28).
function kill_on_exit() {
posix_kill( getmypid(), 28 );
}
register_shutdown_function( 'kill_on_exit' );
?>
This did not, however, fix my problem. I ended up getting the best performance by completely turning off Apache KeepAlive. I added this to my apache2.conf file:
KeepAlive Off
Now the hundreds of requests per second that I'm getting on a specific page do not tie-up resources for 4 seconds. They complete very fast and the process can be reused for another connection. The performance I'm getting from the normal pages with lots of content is actually pretty good even though every request is going over a different connection to a different process on the server.