Apache2.4とAJPのエラーと対処

Apacheでスコアボードがフルになるエラー

Apache2.4で動かしているAPIサーバーで以下のエラーログが出力されていた。

Resource temporarily unavailable: apr_thread_create: unable to create worker thread

リソースが足りないと言われているので、MaxRequestWorkersやMaxConnectionsPerChildを見直したんだけど、今度は↓のようなエラーが出力されるようになった。

   AH00485: scoreboard is full, not at MaxRequestWorkers
   AH00485: scoreboard is full, not at MaxRequestWorkers
   AH00485: scoreboard is full, not at MaxRequestWorkers
   AH00485: scoreboard is full, not at MaxRequestWorkers
   AH00485: scoreboard is full, not at MaxRequestWorkers
   AH00485: scoreboard is full, not at MaxRequestWorkers
   AH00485: scoreboard is full, not at MaxRequestWorkers
   AH00485: scoreboard is full, not at MaxRequestWorkers
   AH00485: scoreboard is full, not at MaxRequestWorkers
   AH00485: scoreboard is full, not at MaxRequestWorkers

原因はKeepaliveでした。KeepAlive Onになっていて、MaxKeepAliveRequests 100だったので、MaxConnectionsPerChildのコネクションを維持できずにエラーになっていた模様です。KeepaliveをいったんOffにしたところエラーは出なくなりました。あとでMaxKeepAliveRequestsを最適化させておこう。

AJPコネクタでエラー

先ほどのエラーは出なくなったのですが、バッチが動く朝4時に下記のエラーが出力されていました。

   (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header
   (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header
   (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header
   (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header
   (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header
   (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header
   (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header
   (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header

AJPコネクタでTomcatに接続している処理が切れてしまうみたい。

    
     ProxyPass ajp://localhost:8009/
    

このProxyPassをProxyPass ajp://localhost:8009/ keepalive=onにすると接続は維持されるみたい。明日試してみよう。

サーバ構築の実際がわかる Apache[実践]運用/管理 (Software Design plus)posted with カエレバ鶴長 鎮一 技術評論社 2012-03-23