EC-CUBE2.11系のパフォーマンスを185%あげる4つの手法

eccube ECCUBE

まずはデフォルトの場合のベンチマークです
PHP5.2.17 MySQL5.5.9 MAMP環境です

同時接続数が 10で、リクエスト数 100 になるまで、http://localhost:8888/ にアクセスした結果21.855秒かかりました
とても重いですね

~~~
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking amber (be patient)…..done

Server Software: Apache/2.2.21
Server Hostname: localhost
Server Port: 8888

Document Path: /
Document Length: 32560 bytes

Concurrency Level: 10
Time taken for tests: 21.855 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 3299600 bytes
HTML transferred: 3256000 bytes
Requests per second: 4.58 [#/sec] (mean)
Time per request: 2185.466 [ms] (mean)
Time per request: 218.547 [ms] (mean, across all concurrent requests)
Transfer rate: 147.44 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1990 557.8 2088 2934
Processing: 0 173 677.8 0 3014
Waiting: 0 167 664.0 0 3007
Total: 1296 2163 295.1 2104 3014

Percentage of the requests served within a certain time (ms)
50% 2104
66% 2218
75% 2280
80% 2306
90% 2682
95% 2868
98% 2935
99% 3014
100% 3014 (longest request)

~~~

PHP5.3.10を使います

14.556秒、150%改善しましたがまだまだ遅いですね

~~~
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking amber (be patient)…..done

Server Software: Apache/2.2.21
Server Hostname: localhost
Server Port: 8888

Document Path: /
Document Length: 32560 bytes

Concurrency Level: 10
Time taken for tests: 14.556 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 3299400 bytes
HTML transferred: 3256000 bytes
Requests per second: 6.87 [#/sec] (mean)
Time per request: 1455.600 [ms] (mean)
Time per request: 145.560 [ms] (mean, across all concurrent requests)
Transfer rate: 221.36 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1207 516.5 1431 2270
Processing: 0 224 550.0 0 2162
Waiting: 0 221 544.8 0 2161
Total: 687 1431 288.0 1442 2559

Percentage of the requests served within a certain time (ms)
50% 1442
66% 1466
75% 1480
80% 1496
90% 1597
95% 2163
98% 2270
99% 2559
100% 2559 (longest request)
~~~

apcを有効にします

EC-CUBEはAPCに対応していないので、画面下にこんなエラーメッセージが出てしまいます

~~~
Fatal error: Class ‘MDB2’ not found in /Users/userdir/eccube-2.11.4/data/class/SC_Query.php on line 76
~~~

これを出ないようにするために修正します

SC_Helper_Session_Exに追記します

~~~
function __destruct() {
session_write_close();
}
~~~

参考:EC-CUBE2.11.1でAPCの動作を確認してみる | のぶろぐ

エラーメッセージが出なくなったのでベンチマークをとります

12.174秒、あまりかわりませんが最初の状態より179%改善しました

~~~
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking amber (be patient)…..done

Server Software: Apache/2.2.21
Server Hostname: localhost
Server Port: 8888

Document Path: /
Document Length: 32560 bytes

Concurrency Level: 10
Time taken for tests: 12.174 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 3299400 bytes
HTML transferred: 3256000 bytes
Requests per second: 8.21 [#/sec] (mean)
Time per request: 1217.353 [ms] (mean)
Time per request: 121.735 [ms] (mean, across all concurrent requests)
Transfer rate: 264.68 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1082 358.8 1188 1450
Processing: 0 131 358.0 0 1275
Waiting: 0 131 357.3 0 1273
Total: 930 1213 88.4 1207 1450

Percentage of the requests served within a certain time (ms)
50% 1207
66% 1224
75% 1237
80% 1247
90% 1390
95% 1422
98% 1436
99% 1450
100% 1450 (longest request)
~~~

SESSIONのストレージにデータベースを使うのをやめる

EC-CUBEはWEBサーバーを分散させることを前提に作られているためセッションをDBに持たせていますがこれがDBへの負荷となるためfileでの処理に変えてベンチをとってみます

11.805秒、画面の表示速度にはあまり影響していないようですが、とりあえずこれで185%の改善。

~~~
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking amber (be patient)…..done

Server Software: Apache/2.2.21
Server Hostname: localhost
Server Port: 8888

Document Path: /
Document Length: 32560 bytes

Concurrency Level: 10
Time taken for tests: 11.805 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 3299400 bytes
HTML transferred: 3256000 bytes
Requests per second: 8.47 [#/sec] (mean)
Time per request: 1180.536 [ms] (mean)
Time per request: 118.054 [ms] (mean, across all concurrent requests)
Transfer rate: 272.93 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1070 327.8 1180 1293
Processing: 0 107 322.3 0 1193
Waiting: 0 106 322.0 0 1193
Total: 970 1176 53.4 1183 1294

Percentage of the requests served within a certain time (ms)
50% 1183
66% 1194
75% 1205
80% 1214
90% 1243
95% 1260
98% 1284
99% 1294
100% 1294 (longest request)
~~~

Cache_Liteを導入する

PEARのライブラリであるCache_Liteを導入し、クエリをキャッシュします
こちらもMySQLのアクセスを減らすことが目的になります

結果はなぜか18.374秒。悪化してしまいました。
データ量があまりないからなのか、キャッシュを見に行く方がパフォーマンスがでないという結果に

~~~
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking amber (be patient)…..done

Server Software: Apache/2.2.21
Server Hostname: localhost
Server Port: 8888

Document Path: /
Document Length: 32560 bytes

Concurrency Level: 10
Time taken for tests: 18.374 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 3299400 bytes
HTML transferred: 3256000 bytes
Requests per second: 5.44 [#/sec] (mean)
Time per request: 1837.391 [ms] (mean)
Time per request: 183.739 [ms] (mean, across all concurrent requests)
Transfer rate: 175.36 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1580 647.8 1734 2292
Processing: 0 243 609.9 0 2135
Waiting: 0 243 609.4 0 2132
Total: 1512 1823 200.5 1758 2292

Percentage of the requests served within a certain time (ms)
50% 1758
66% 1912
75% 2006
80% 2076
90% 2119
95% 2151
98% 2206
99% 2292
100% 2292 (longest request)
~~~

というわけで

結果185%のパフォーマンス改善となりました
MySQLのチューニングをすれば、さらに改善も見込めると思うのでそれはまた別の機会にでも

[PR] cocokamo EC-CUBEで出来たEC-CUBEモールです。登録無料です!

コメント

  1. Tao より:

    APCでクエリをキャッシュした方が速いと思います。

    • のぶ より:

      そんな使い方も出来るんですね〜
      ただapc_delete(‘foo’);しか出来ないとキャッシュクリアするのが厳しくないですか?

      cache_liteだとキャッシュクリアがもう少しだけ柔軟に出来るのでその点は便利かもしれません

タイトルとURLをコピーしました