dongshao8125 2013-11-19 20:04
浏览 44

什么是Apache 2中的PHP apache_child_terminate等价物?

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:

  • There is one particular type of request that I get over 100 times each second. A very small message is returned (just a few characters), but Apache keeps the process around for 4 seconds to allow for subsequent requests to be processed by the same Apache process. I can't lower the 4 second keep alive much more because it affects the performance of all the other PHP pages that have a lot of content and requests. So the idea is that only on that one type of request, I don't want the process to linger for 4 seconds.

Thanks in advance for any suggestions!

  • 写回答

1条回答 默认 最新

  • dq23171 2013-11-19 22:17
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗