LoginSignup
6
8

More than 3 years have passed since last update.

apacheのMaxRequestWorkers を設定して同時接続対策をする

Last updated at Posted at 2021-01-15

概要

同時アクセス対策として、apacheのMaxRequestWorkersを増やす対策が可能です。
apacheのバージョン2.4系の場合はMaxClientsではなくMaxRequestWorkersという表現が使われています。

エラーログの確認

まず、apache同時接続によるボトルネックがあるか確認します。

cat /var/log/htttpd/error_log |grep MaxRequestWorkers
[Fri Jan 15 01:35:27.458186 2021] [mpm_event:error] [pid 38749:tid 140604360575296] AH00484: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

原因

MaxRequestWorkersの制限によって、requestに対応するworkerが割り当てられず、requestの処理が遅くなっている状態です。

MPM の確認

ApacheのMPM(Multi Processing Module)には、prefork,worker,eventの3種類があり下記のコマンドで確認できます。

httpd -V |grep MPM
Server MPM:     event

MPM Eventの場合

デフォルトのServerLimitは、16です。
ServerLimit x 25 = MaxRequestWorkersとなるように、/etc/httpd/conf/httpd.confmpm_event_moduleIfModuleを追記してMaxRequestWorkersおよび、ServerLimitを設定します。

例:
20(ServerLimit) x 25 = 500(MaxRequestWorkers)

<IfModule mpm_event_module>
    ThreadsPerChild 25
    ServerLimit 20
    MaxRequestWorkers 500
</IfModule>

MPM Preforkの場合

同様に、ServerLimitを上げる必要があります。

参考

メモ

同時リクエスト数をカウントするコマンド

netstat -an |grep -e :80 -e :443 |wc -l
6
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
8