UNIX系のシステムでは、ファイルの持つタイムスタンプ情報に「修正時間」(mtime)、「作成時間」(ctime)、「アクセス時間」(atime)
情報があります。
touchコマンドでは-mオプションでmtimeを、-aオプションでatimeを更新できます。
ls -l で mtime、ls -lc で ctime、ls -lu で atime を表示することができます。
CODE:
-
# ls -l *.txt
-
-rw-r–r– 1 root root 0 5月 13 16:50 access.txt
-
-rw-r–r– 1 root root 0 5月 13 16:50 modify.txt
-
# touch -a access.txt
-
# touch -m modify.txt
-
# ls -lu *.txt
-
-rw-r–r– 1 root root 0 5月 13 16:58 access.txt
-
-rw-r–r– 1 root root 0 5月 13 16:50 modify.txt
-
# ls -l *.txt
-
-rw-r–r– 1 root root 0 5月 13 16:50 access.txt
-
-rw-r–r– 1 root root 0 5月 13 16:58 modify.txt
非常にアクセス負荷の高い静的コンテンツ用のWWWサーバの場合はこのatimeに対する更新を無くしてやることで、負荷を下げること
ができます。
アクセス対象のファイルはこうなっています。
CODE:
-
# ls -l *.html
-
-rw-r–r– 1 root root 44 11月 21 2004 index.html
-
# ls -lu *.html
-
-rw-r–r– 1 root root 44 5月 8 17:56 index.html
ここでabで性能を確認しました。
3回実施した上で後の2回が以下の通り。
CODE:
-
/usr/local/apache2/bin/ab -n 10000 -c 100 http://stockholm/
-
-
# /usr/local/apache2/bin/ab -n 10000 -c 100 http://stockholm/
-
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
-
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
-
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
-
-
Benchmarking stockholm (be patient)
-
Completed 1000 requests
-
Completed 2000 requests
-
Completed 3000 requests
-
Completed 4000 requests
-
Completed 5000 requests
-
Completed 6000 requests
-
Completed 7000 requests
-
Completed 8000 requests
-
Completed 9000 requests
-
Finished 10000 requests
-
-
Server Software: Apache/2.2.4
-
Server Hostname: stockholm
-
Server Port: 80
-
-
Document Path: /
-
Document Length: 44 bytes
-
-
Concurrency Level: 100
-
Time taken for tests: 11.277795 seconds
-
Complete requests: 10000
-
Failed requests: 0
-
Write errors: 0
-
Total transferred: 2617830 bytes
-
HTML transferred: 441320 bytes
-
Requests per second: 886.70 [#/sec] (mean)
-
Time per request: 112.778 [ms] (mean)
-
Time per request: 1.128 [ms] (mean, across all concurrent requests)
-
Transfer rate: 226.64 [Kbytes/sec] received
-
-
Connection Times (ms)
-
min mean[+/-sd] median max
-
Connect: 0 10 10.1 8 65
-
Processing: 17 100 16.9 100 694
-
Waiting: 16 72 25.6 79 658
-
Total: 17 111 20.4 109 713
-
-
Percentage of the requests served within a certain time (ms)
-
50% 109
-
66% 114
-
75% 118
-
80% 121
-
90% 131
-
95% 139
-
98% 147
-
99% 154
-
100% 713 (longest request)
-
# /usr/local/apache2/bin/ab -n 10000 -c 100 http://stockholm/
-
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
-
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
-
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
-
-
Benchmarking stockholm (be patient)
-
Completed 1000 requests
-
Completed 2000 requests
-
Completed 3000 requests
-
Completed 4000 requests
-
Completed 5000 requests
-
Completed 6000 requests
-
Completed 7000 requests
-
Completed 8000 requests
-
Completed 9000 requests
-
Finished 10000 requests
-
-
Server Software: Apache/2.2.4
-
Server Hostname: stockholm
-
Server Port: 80
-
-
Document Path: /
-
Document Length: 44 bytes
-
-
Concurrency Level: 100
-
Time taken for tests: 11.428654 seconds
-
Complete requests: 10000
-
Failed requests: 0
-
Write errors: 0
-
Total transferred: 2610000 bytes
-
HTML transferred: 440000 bytes
-
Requests per second: 874.99 [#/sec] (mean)
-
Time per request: 114.287 [ms] (mean)
-
Time per request: 1.143 [ms] (mean, across all concurrent requests)
-
Transfer rate: 222.95 [Kbytes/sec] received
-
-
Connection Times (ms)
-
min mean[+/-sd] median max
-
Connect: 0 42 30.3 41 104
-
Processing: 25 70 18.0 68 117
-
Waiting: 1 39 24.8 38 108
-
Total: 25 113 17.1 113 217
-
-
Percentage of the requests served within a certain time (ms)
-
50% 113
-
66% 120
-
75% 126
-
80% 129
-
90% 136
-
95% 140
-
98% 144
-
99% 145
-
100% 217 (longest request)
Requests per second: 880.845 (平均)
index.htmlのタイムスタンプは以下の通りで確かに
atimeは更新されています。
CODE:
-
# ls -l *.html
-
-rw-r–r– 1 root root 44 11月 21 2004 index.html
-
# ls -lu *.html
-
-rw-r–r– 1 root root 44 5月 13 17:08 index.html
atimeの更新は、/etc/fstabのマウントオプションとして「noatime」を指定することで無効化できる。
LABEL=/ / ext3 defaults,noatime 1 1
atimeの更新を無効化すると、mountコマンドで「noatime」と表示されます。
$ mount
/dev/hda1 on / type ext3 (rw,noatime)
(省略)
上記を設定した上で、再度以下を実施しました。
CODE:
-
# /usr/local/apache2/bin/ab -n 10000 -c 100 http://stockholm/
-
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
-
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
-
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
-
-
Benchmarking stockholm (be patient)
-
Completed 1000 requests
-
Completed 2000 requests
-
Completed 3000 requests
-
Completed 4000 requests
-
Completed 5000 requests
-
Completed 6000 requests
-
Completed 7000 requests
-
Completed 8000 requests
-
Completed 9000 requests
-
Finished 10000 requests
-
-
Server Software: Apache/2.2.4
-
Server Hostname: stockholm
-
Server Port: 80
-
-
Document Path: /
-
Document Length: 44 bytes
-
-
Concurrency Level: 100
-
Time taken for tests: 11.135027 seconds
-
Complete requests: 10000
-
Failed requests: 0
-
Write errors: 0
-
Total transferred: 2610000 bytes
-
HTML transferred: 440000 bytes
-
Requests per second: 898.07 [#/sec] (mean)
-
Time per request: 111.350 [ms] (mean)
-
Time per request: 1.114 [ms] (mean, across all concurrent requests)
-
Transfer rate: 228.83 [Kbytes/sec] received
-
-
Connection Times (ms)
-
min mean[+/-sd] median max
-
Connect: 0 0 1.4 0 24
-
Processing: 11 110 367.6 82 9107
-
Waiting: 11 90 125.6 82 8169
-
Total: 11 110 367.6 82 9107
-
-
Percentage of the requests served within a certain time (ms)
-
50% 82
-
66% 83
-
75% 84
-
80% 84
-
90% 92
-
95% 106
-
98% 109
-
99% 747
-
100% 9107 (longest request)
-
# /usr/local/apache2/bin/ab -n 10000 -c 100 http://stockholm/
-
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
-
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
-
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
-
-
Benchmarking stockholm (be patient)
-
Completed 1000 requests
-
Completed 2000 requests
-
Completed 3000 requests
-
Completed 4000 requests
-
Completed 5000 requests
-
Completed 6000 requests
-
Completed 7000 requests
-
Completed 8000 requests
-
Completed 9000 requests
-
Finished 10000 requests
-
-
Server Software: Apache/2.2.4
-
Server Hostname: stockholm
-
Server Port: 80
-
-
Document Path: /
-
Document Length: 44 bytes
-
-
Concurrency Level: 100
-
Time taken for tests: 11.79239 seconds
-
Complete requests: 10000
-
Failed requests: 0
-
Write errors: 0
-
Total transferred: 2610000 bytes
-
HTML transferred: 440000 bytes
-
Requests per second: 902.59 [#/sec] (mean)
-
Time per request: 110.792 [ms] (mean)
-
Time per request: 1.108 [ms] (mean, across all concurrent requests)
-
Transfer rate: 229.98 [Kbytes/sec] received
-
-
Connection Times (ms)
-
min mean[+/-sd] median max
-
Connect: 0 0 1.4 0 24
-
Processing: 11 109 294.7 89 9563
-
Waiting: 11 96 152.2 88 9563
-
Total: 11 109 294.7 89 9563
-
-
Percentage of the requests served within a certain time (ms)
-
50% 89
-
66% 90
-
75% 91
-
80% 92
-
90% 94
-
95% 104
-
98% 110
-
99% 693
-
100% 9563 (longest request)
Requests per second: 900.33 (平均)
1%と非常にわずかですが確かにチューニング効果はあるようです。
実際にatimeが必要になる局面が想定できないなら、やってみても
良い気がします。
それと確かにatimeは更新されていません。
CODE:
-
# ls -lu *.html
-
-rw-r–r– 1 root root 44 5月 13 17:08 index.html
※この調査はCentOS5+apache2.2.4で実施しました。
サーバのスペックはかなり低いものです。
関連会社インターオフィスのブログ記事を転載しています。
コメント入力欄