Apacheの軽量化 不要なモジュールを考える
今回は、自サイト運用のみで稼動させる場合に、Apacheに標準で組み込まれるモジュールから不要なモジュールを削ってコンパイルするとどれくらいリソースの消費を抑えられるか?という観点でApacheを構築してみたいと思います。
んでは、まず。標準のコンパイルオプションでApacheをビルドしてみます。
DSOを利用可能にしたコンパイルオプションは以下のとおり
実利用メモリは、6,944KB(約7MB)ですね。
では次に不要なモジュールを削ってビルドしてみます。(※ 以下のオプションは、全ての環境で適用できるオプションではありません。利用するとしても充分にテストしてから導入してください)
DSOを利用可能にし、自サイトのみ。日本語提供のみ。CGIはPHPのみ。という環境を前提にしたコンパイルオプションは以下のとおり
実利用メモリは、6,892KB(約7MB)ですね。
54バイトの節約。・・・orz・・・そんなもんか・・・。 メモリの利用サイズに大きな効果はありませんでした(;゚皿゚)
でも、内部的な処理速度を向上しているのかも?次はそのへんを実験してみたいと思います。
んでは、まず。標準のコンパイルオプションでApacheをビルドしてみます。
DSOを利用可能にしたコンパイルオプションは以下のとおり
./configure --enable-module=so静的に組み込まれたモジュールを確認。んで、実際には以下のとおり。
# /usr/local/apache/bin/httpd -l Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_asis.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_access.c mod_auth.c mod_so.c mod_setenvif.c suexec: disabled; invalid wrapper /usr/local/apache/bin/suexecApacheの実行状況確認から使用サイズを見てみます。
# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 4363 2.1 1.3 42992 6936 ? S 07:14 0:00 /usr/local/apache/bin/httpd nobody 4364 0.0 1.3 42936 6944 ? S 07:14 0:00 [httpd] nobody 4365 0.0 1.3 42936 6944 ? S 07:14 0:00 [httpd] nobody 4366 0.0 1.3 42936 6944 ? S 07:14 0:00 [httpd] nobody 4367 0.0 1.3 42936 6944 ? S 07:14 0:00 [httpd] nobody 4368 0.0 1.3 42936 6944 ? S 07:14 0:00 [httpd] nobody 4369 0.0 1.3 42936 6944 ? S 07:14 0:00 [httpd] nobody 4370 0.0 1.3 42936 6944 ? S 07:14 0:00 [httpd] nobody 4371 0.0 1.3 42936 6944 ? S 07:14 0:00 [httpd]補足:PHP5とgzipモジュールをLoadModuleした際の値です。
実利用メモリは、6,944KB(約7MB)ですね。
では次に不要なモジュールを削ってビルドしてみます。(※ 以下のオプションは、全ての環境で適用できるオプションではありません。利用するとしても充分にテストしてから導入してください)
DSOを利用可能にし、自サイトのみ。日本語提供のみ。CGIはPHPのみ。という環境を前提にしたコンパイルオプションは以下のとおり
./configure --enable-module=so --disable-module=autoindex --disable-module=userdir --disable-module=status --disable-module=include --disable-module=asis --disable-module=imap --disable-module=negotiation --disable-module=env
Compiled-in modules: http_core.c mod_log_config.c mod_mime.c mod_dir.c mod_cgi.c mod_actions.c mod_alias.c mod_access.c mod_auth.c mod_so.c mod_setenvif.c suexec: disabled; invalid wrapper /usr/local/apache/bin/suexec
# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 8436 0.5 1.3 42908 6884 ? S 07:22 0:00 /usr/local/apache/bin/httpd nobody 8437 0.0 1.3 42852 6892 ? S 07:22 0:00 [httpd] nobody 8438 0.0 1.3 42852 6892 ? S 07:22 0:00 [httpd] nobody 8439 0.0 1.3 42852 6892 ? S 07:22 0:00 [httpd] nobody 8440 0.0 1.3 42852 6892 ? S 07:22 0:00 [httpd] nobody 8441 0.0 1.3 42852 6892 ? S 07:22 0:00 [httpd] nobody 8442 0.0 1.3 42852 6892 ? S 07:22 0:00 [httpd] nobody 8443 0.0 1.3 42852 6892 ? S 07:22 0:00 [httpd] nobody 8444 0.0 1.3 42852 6892 ? S 07:22 0:00 [httpd]補足:PHP5とgzipモジュールをLoadModuleした際の値です。
実利用メモリは、6,892KB(約7MB)ですね。
54バイトの節約。・・・orz・・・そんなもんか・・・。 メモリの利用サイズに大きな効果はありませんでした(;゚皿゚)
でも、内部的な処理速度を向上しているのかも?次はそのへんを実験してみたいと思います。