
apacheでアクセス数が少ない場合のメモリ節約方法
現在このサイトは、さくらVPSをつかっていて、いまのところ、メモリが512MBとそれほど多いわけではない。 で、 「何だか動作が遅いなー」 と思って、muninなどのツールを使って状況を確認して見たところ、swapしまくりで、 ディスクIOしまくりだったので、apacheの設定を以下の様に変更してメモリ節約をしてみることにしました。 以下の様に変更してみたら、圧倒的にレスポンススピードが向上しました。 # git diff f65246dc7a075a10537640ac9f6e6641ef812569 httpd/ diff --git a/httpd/conf/httpd.conf b/httpd/conf/httpd.conf index 5c6710a..7e41ddc 100644 --- a/httpd/conf/httpd.conf +++ b/httpd/conf/httpd.conf @@ -41,7 +41,8 @@ # Don't give away too much information about all the subcomponents # we are running. Comment out this line if you don't mind remote sites # finding out what major optional modules you are running -ServerTokens OS +#ServerTokens OS +ServerTokens Prod # # ServerRoot: The top of the directory tree under which the server's @@ -98,11 +99,11 @@ KeepAliveTimeout 15 # MaxClients: maximum number of server processes allowed to start # MaxRequestsPerChild: maximum number of requests a server process serves -StartServers 8 -MinSpareServers 5 -MaxSpareServers 20 -ServerLimit 256 -MaxClients 256 +StartServers 2 +MinSpareServers 2 +MaxSpareServers 4 +ServerLimit 25 +MaxClients 25 MaxRequestsPerChild 4000 まぁ、もちろん、このサイトのアクセス数が少ないからこの設定が有効なだけなので、 ある程度以上になると、この設定ではいろいろと不都合が出ると思いますが、 そうなったら、その時対処方法(別のサーバにするとか)を考えるということにしておきます。

