最近、このブログのレスポンスが遅いのが、無視できない感じになってきました。
Goolgleのウェブマスターツールによるサイトのパフォーマンスのグラフです。

サイトのパフォーマンス
さすがに、キャッシュ機能を入れたりして、対応する必要がありそうです。
そのへんについて、せっかくWord Pressを使っているので、サーバ側のツールで設定するより、ブログについては、Word Pressのプラグインで対応しようと思います。
ということで、わりとそのへんの定番っぽい「WP Super Cache」を導入しました。

WP Super Cache
「WP Super Cache」のインストール
- WP Super Cacheのページから、プラグインファイルをダウンロードします。現在の最新バージョンは、0.9.9.9でした。
- 解凍して、フォルダごと、プラグインフォルダ(wp-content/plugins)にアップします。
- /wp-contentフォルダの権限を777に設定します。
- 管理ページに入って、WP Super Cacheプラグインを有効にします。
-
設定画面に入ると警告がでるので、指示どおり、wp-config.phpに
define('WP_CACHE', true);
と設定して、リロードします。
-
サーバ側に、/wp-content/cacheフォルダが自動作成されていることを確認します。
drwxr-xr-x 5 apache apache 4096 May 24 18:47 cache
- /wp-contentフォルダの権限を755に戻します。
- 管理ページに戻って、「キャッシング利用 (推奨)」に設定します。
-
「キャッシュテスター」を行ってみます。
下のテストボタンをクリックするとキャッシュされたページをテストできます。
キャッシュを準備するために http://blog.flatlabs.net/ を取得: OK
http://blog.flatlabs.net/ の最初のコピーを取得中: OK (1.html)
http://blog.flatlabs.net/ の二つめのコピーを取得中: OK (2.html)
ページ 1: 2011-05-24 14:46:35
ページ 2: 2011-05-24 14:46:35
両方のページのタイムスタンプがマッチしました !
成功が確認できました。
- 「詳細」タブの「有効時間とガーベージコレクション」で、キャッシュの有効期限を適度な感じに設定します。
これでインストール完了です。
「WP Super Cache」導入による表示スピードアッップの効果
それでは、WP Super Cacheを使うことにより、どのくらいスピードアップの効果があるか、Apacheのabコマンドを使って、比較してみます。
現状を数値的にとらえるにはツールが必要となる。いわゆるベンチマーク・ツールだ。Apacheには、標準で「ab」(Apache Bench)というツールが付属している。
@IT:Apacheパフォーマンス・チューニングのポイント(2/2)
導入前の速度
導入前のトップページの計測です。
# ab -n 100 http://blog.flatlabs.net/
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 blog.flatlabs.net (be patient).....done
Server Software: Apache/2.2.3
Server Hostname: blog.flatlabs.net
Server Port: 80
Document Path: /20110523_234750/
Document Length: 31879 bytes
Concurrency Level: 1
Time taken for tests: 211.564671 seconds
Complete requests: 100
Failed requests: 99
(Connect: 0, Length: 99, Exceptions: 0)
Write errors: 0
Total transferred: 3229636 bytes
HTML transferred: 3198536 bytes
Requests per second: 0.47 [#/sec] (mean)
Time per request: 2115.647 [ms] (mean)
Time per request: 2115.647 [ms] (mean, across all concurrent requests)
Transfer rate: 14.90 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 29 29 1.7 30 41
Processing: 501 2085 1603.6 1659 9385
Waiting: 318 1868 1487.1 1509 8567
Total: 531 2115 1603.7 1694 9414
Percentage of the requests served within a certain time (ms)
50% 1694
66% 1894
75% 2228
80% 2735
90% 4539
95% 5914
98% 8498
99% 9414
100% 9414 (longest request)
導入前の記事ページの計測です。
# ab -n 100 http://blog.flatlabs.net/20110523_234750/
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 blog.flatlabs.net (be patient).....done
Server Software: Apache/2.2.3
Server Hostname: blog.flatlabs.net
Server Port: 80
Document Path: /
Document Length: 81502 bytes
Concurrency Level: 1
Time taken for tests: 171.843609 seconds
Complete requests: 100
Failed requests: 98
(Connect: 0, Length: 98, Exceptions: 0)
Write errors: 0
Total transferred: 8176586 bytes
HTML transferred: 8151186 bytes
Requests per second: 0.58 [#/sec] (mean)
Time per request: 1718.436 [ms] (mean)
Time per request: 1718.436 [ms] (mean, across all concurrent requests)
Transfer rate: 46.46 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 29 29 2.2 29 49
Processing: 531 1688 1080.4 1512 5657
Waiting: 319 1312 964.4 1155 4823
Total: 560 1717 1081.2 1542 5706
Percentage of the requests served within a certain time (ms)
50% 1542
66% 1932
75% 2346
80% 2508
90% 3129
95% 3811
98% 5556
99% 5706
100% 5706 (longest request)
導入後の速度
導入後のトップページの計測です。
# ab -n 100 http://blog.flatlabs.net/
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 blog.flatlabs.net (be patient).....done
Server Software: Apache/2.2.3
Server Hostname: blog.flatlabs.net
Server Port: 80
Document Path: /
Document Length: 81689 bytes
Concurrency Level: 1
Time taken for tests: 27.847163 seconds
Complete requests: 100
Failed requests: 99
(Connect: 0, Length: 99, Exceptions: 0)
Write errors: 0
Total transferred: 8201237 bytes
HTML transferred: 8170880 bytes
Requests per second: 3.59 [#/sec] (mean)
Time per request: 278.472 [ms] (mean)
Time per request: 278.472 [ms] (mean, across all concurrent requests)
Transfer rate: 287.61 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 29 29 1.8 29 39
Processing: 144 248 430.7 173 4327
Waiting: 29 105 421.4 31 4109
Total: 173 277 430.7 202 4356
Percentage of the requests served within a certain time (ms)
50% 202
66% 208
75% 228
80% 236
90% 372
95% 444
98% 1083
99% 4356
100% 4356 (longest request)
導入後の記事ページの計測です。
# ab -n 100 http://blog.flatlabs.net/20110523_234750/
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 blog.flatlabs.net (be patient).....done
Server Software: Apache/2.2.3
Server Hostname: blog.flatlabs.net
Server Port: 80
Document Path: /20110523_234750/
Document Length: 31952 bytes
Concurrency Level: 1
Time taken for tests: 16.863984 seconds
Complete requests: 100
Failed requests: 99
(Connect: 0, Length: 99, Exceptions: 0)
Write errors: 0
Total transferred: 3227594 bytes
HTML transferred: 3197180 bytes
Requests per second: 5.93 [#/sec] (mean)
Time per request: 168.640 [ms] (mean)
Time per request: 168.640 [ms] (mean, across all concurrent requests)
Transfer rate: 186.85 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 29 29 0.5 29 33
Processing: 113 138 208.5 116 2200
Waiting: 29 53 205.6 31 2086
Total: 142 168 208.5 145 2229
Percentage of the requests served within a certain time (ms)
50% 145
66% 146
75% 147
80% 149
90% 152
95% 159
98% 252
99% 2229
100% 2229 (longest request)
結果は、8.6倍の表示スピードアップ!
比較すると、
今回の計測結果からいくと、平均して、約8.6倍スピードアップしたことになります。
十分な効果ありですね。しばらくは、これで大丈夫かと思います。
手軽にこういうことできるのもWordPressのいいとこなのかもしれません。