memo.xight.org

/ / memo.xight.org

2006-02-28

mod_cache + mod_disk_cache を利用した apache2 のパフォーマンス改善とその効果

- /etc/apache2/mods-available/disk_cache.conf
<IfModule mod_cache.c>
	<IfModule mod_disk_cache.c>
		CacheRoot "/var/cache/apache2/disk_cache"
		CacheSize 524288
		CacheEnable disk /
		CacheDirLevels 4
		CacheDirLength 5
	</IfModule>
</IfModule>


- cache 用ディレクトリの作成

# mkdir /var/cache/apache2/disk_cache


- mod_cache と mod_disk_cache の有効化

# a2enmod cache
# a2enmod disk_cache
# apache2ctl configtest
# apache2ctl restart





- mod_cache + mod_disk_cache 使用前後のベンチマーク比較 (ApacheBench を利用)
mod_cache + mod_disk_cache 使用前 (HTMLへのアクセス)

% ab -n 100 -c 10 http://xight.org/test/static
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.4502 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking xight.org (be patient).....done


Server Software: Apache
Server Hostname: xight.org
Server Port: 80

Document Path: /test/static
Document Length: 119 bytes

Concurrency Level: 10
Time taken for tests: 104.65314 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 43800 bytes
HTML transferred: 11900 bytes
Requests per second: 0.96 [#/sec] (mean)
Time per request: 10406.532 [ms] (mean)
Time per request: 1040.653 [ms] (mean, across all concurrent requests)
Transfer rate: 0.40 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 11 1039 2724.4 30 21007
Processing: 46 9083 8619.9 6165 30877
Waiting: 38 5708 7523.9 3087 27202
Total: 116 10122 9075.1 6263 30907

Percentage of the requests served within a certain time (ms)
  50% 6263
  66% 12234
  75% 15935
  80% 18918
  90% 27164
  95% 27222
  98% 30892
  99% 30907
 100% 30907 (longest request)


mod_cache + mod_disk_cache 使用後 (HTMLへのアクセス)

% ab -n 100 -c 10 http://xight.org/test/static
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.4502 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking xight.org (be patient).....done


Server Software: Apache
Server Hostname: xight.org
Server Port: 80

Document Path: /test/static
Document Length: 119 bytes

Concurrency Level: 10
Time taken for tests: 2.551448 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 43800 bytes
HTML transferred: 11900 bytes
Requests per second: 39.19 [#/sec] (mean)
Time per request: 255.145 [ms] (mean)
Time per request: 25.514 [ms] (mean, across all concurrent requests)
Transfer rate: 16.46 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 11 24 8.9 26 42
Processing: 36 218 43.8 230 266
Waiting: 28 130 65.2 128 266
Total: 52 243 44.8 255 295

Percentage of the requests served within a certain time (ms)
  50% 255
  66% 261
  75% 265
  80% 267
  90% 277
  95% 284
  98% 293
  99% 295
 100% 295 (longest request)





mod_cache + mod_disk_cache 使用前 (PHPへのアクセス)

% ab -n 100 -c 10 http://xight.org/test/dynamic
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.4502 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking xight.org (be patient).....done


Server Software: Apache
Server Hostname: xight.org
Server Port: 80

Document Path: /test/dynamic
Document Length: 1011 bytes

Concurrency Level: 10
Time taken for tests: 122.299908 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 125500 bytes
HTML transferred: 101100 bytes
Requests per second: 0.82 [#/sec] (mean)
Time per request: 12229.991 [ms] (mean)
Time per request: 1222.999 [ms] (mean, across all concurrent requests)
Transfer rate: 1.00 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 15 1222 3040.3 24 21007
Processing: 36 10810 9137.5 9190 36141
Waiting: 33 5607 5397.5 3218 21047
Total: 56 12032 9438.8 9487 36160

Percentage of the requests served within a certain time (ms)
  50% 9487
  66% 15184
  75% 18169
  80% 18399
  90% 24175
  95% 36120
  98% 36160
  99% 36160
 100% 36160 (longest request)


mod_cache + mod_disk_cache 使用後 (PHPへのアクセス)

% ab -n 100 -c 10 http://xight.org/test/dynamic
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.4502 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking xight.org (be patient).....done


Server Software: Apache
Server Hostname: xight.org
Server Port: 80

Document Path: /test/dynamic
Document Length: 1011 bytes

Concurrency Level: 10
Time taken for tests: 6.392257 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 125500 bytes
HTML transferred: 101100 bytes
Requests per second: 15.64 [#/sec] (mean)
Time per request: 639.226 [ms] (mean)
Time per request: 63.923 [ms] (mean, across all concurrent requests)
Transfer rate: 19.09 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 16 59 297.9 27 3007
Processing: 114 266 59.1 266 492
Waiting: 68 230 72.4 222 388
Total: 168 326 308.0 295 3317

Percentage of the requests served within a certain time (ms)
  50% 295
  66% 311
  75% 337
  80% 347
  90% 386
  95% 416
  98% 524
  99% 3317
 100% 3317 (longest request)


効果覿面!

- 注意
CacheDirLevels * CacheDirLength <= 20 で無いとエラーが発生する.

Syntax error on line XXX of /etc/apache2/mods-enabled/disk_cache.conf:
CacheDirLevels*CacheDirLength value must not be higher than 20


しばらく動作させると以下のエラーが発生し,閲覧が不可能になる場合がある.
apache を再起動するとおさまるように見えるが,原因不明.

[Wed Mar 01 08:06:10 2006] [error] [client XXX.XXX.XXX.XXX] Directory index forbidden by rule: /path/to/public_html/foo/


- Reference
Apache HTTP サーバ - mod_cache
http://httpd.apache.org/docs/2.2/ja/mod/mod_cache.html
Apache HTTP サーバ - mod_mem_cache
http://httpd.apache.org/docs/2.2/ja/mod/mod_mem_cache.html
Apache HTTP サーバ - mod_disk_cache
http://httpd.apache.org/docs/2.2/ja/mod/mod_disk_cache.html

j-lab - ApacheConf2
http://ns.jk.to/zwiki/ApacheConf2

カテゴリ: [Apache]
内部リンク: [2006-03-01-1]
2006-02 /

Color Reference

ChangeLogを検索
携帯電話からアクセス!

カテゴリ

最近の話題

リンク

過去ログ

Google

QR Code

Since
2002-11-28
Update
2008-12-02 10:52
Copyright © 2005 xight.org All Rights Reserved.