CakePHPと素のHTML/PHPとのパフォーマンスを比べてみる

VirtualBoxにCentOSをとりあえずインストール
の続き

CakePHPと素のHTML/PHPのパフォーマンスを比べてみる。

インストール

$ su -

httpdphpをインストールして、

# yum -y install httpd php wget unzip

設定し、

# vi /etc/httpd/conf/httpd.conf
    AllowOverride None
	↓
    AllowOverride All
# vi /etc/php.ini
date.timezone = Asia/Tokyo

再起動して反映。

# service httpd start

設置

ドキュメントルートに移動。

# cd /var/www/html

素のHTMLを設置する。

# vi index.html
Hello, world!

素のPHPを設置する。

# vi index.php
<?php
echo 'Hello, world!';

CakePHPを設置する。

# wget https://codeload.github.com/cakephp/cakephp/zip/2.4.10
# unzip 2.4.10
# chmod -R 777 cakephp-2.4.10/app/tmp/
# vi cakephp-2.4.10/app/Config/core.php
    Configure::write('Security.salt', '適当な文字列');
    ・・・
    Configure::write('Security.cipherSeed', '適当な数字');

それぞれ、ブラウザからアクセスすると、下記のように表示される。
http://サーバーのアドレス/index.html
http://サーバーのアドレス/index.php

http://サーバーのアドレス/cakephp-2.4.10/

測定

素のHTMLに負荷をかける。

$ ab -c 10 -n 1000 http://サーバーのアドレス/index.html
・・・
Document Path:          /index.html
Document Length:        14 bytes

Concurrency Level:      10
Time taken for tests:   0.765 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      281000 bytes
HTML transferred:       14000 bytes
Requests per second:    1306.97 [#/sec] (mean)
Time per request:       7.651 [ms] (mean)
Time per request:       0.765 [ms] (mean, across all concurrent requests)
Transfer rate:          358.65 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       2
Processing:     1    7  12.0      4     187
Waiting:        1    4   7.8      4     187
Total:          1    8  12.0      4     187

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      5
  75%      5
  80%      6
  90%     22
  95%     36
  98%     43
  99%     45
 100%    187 (longest request)

素のPHPに負荷をかける。

$ ab -c 10 -n 1000 http://サーバーのアドレス/index.php
・・・
Document Path:          /index.php
Document Length:        13 bytes

Concurrency Level:      10
Time taken for tests:   1.099 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      205000 bytes
HTML transferred:       13000 bytes
Requests per second:    910.03 [#/sec] (mean)
Time per request:       10.989 [ms] (mean)
Time per request:       1.099 [ms] (mean, across all concurrent requests)
Transfer rate:          182.18 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:     1    4   7.7      1      55
Waiting:        0    1   2.9      1      42
Total:          1    4   7.7      2      55

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      2
  75%      2
  80%      3
  90%     15
  95%     23
  98%     30
  99%     38
 100%     55 (longest request)

CakePHPに負荷をかける。

$ ab -c 10 -n 1000 http://サーバーのアドレス/cakephp-2.4.10/
・・・
Document Path:          /cakephp-2.4.10/
Document Length:        11560 bytes

Concurrency Level:      10
Time taken for tests:   51.348 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      11860000 bytes
HTML transferred:       11560000 bytes
Requests per second:    19.47 [#/sec] (mean)
Time per request:       513.483 [ms] (mean)
Time per request:       51.348 [ms] (mean, across all concurrent requests)
Transfer rate:          225.56 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    7  85.6      0    1109
Processing:   164  505  86.0    537     785
Waiting:      139  454  79.0    484     730
Total:        164  512 124.6    538    1745

Percentage of the requests served within a certain time (ms)
  50%    538
  66%    554
  75%    564
  80%    569
  90%    593
  95%    615
  98%    643
  99%    700
 100%   1745 (longest request)
  素のHTML 素のPHP CakePHP
Request per second: 1306 910 19
Time per request: 0.7ms 1ms 51ms