Perlを中心とした技術系の話などをつらつら

2006年07月31日

コネクションプーリング都市伝説は正しそう

またちょっと古いねたですが、WEB+DB PRESS vol.33でnipotanさんが書いてたコネクションプーリング都市伝説を読んだ時、ほんとのところどっちが速いのかってのをabでベンチマークをとってみました。

ベンチマークとったときにエントリを書こうと思ってたんですが、モチベーションがあがらず今になっちゃいました。。

以下がベンチマークの結果です。

プーリングを有効にした場合

Server Hostname:        rakuda.localhost
Server Port:            80
Document Path:          /
Document Length:        12323 bytes
Concurrency Level:      20
Time taken for tests:   107.840 seconds
Complete requests:      1000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      12579000 bytes
HTML transferred:       12323000 bytes
Requests per second:    9.27 [#/sec] (mean)
Time per request:       2156.80 [ms] (mean)
Time per request:       107.84 [ms] (mean, across all concurrent requests)
Transfer rate:          116.65 [Kbytes/sec] received
Connnection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0     0    0.0      0     1
Processing:   640  2140  486.9   1999  4674
Waiting:      639  2139  486.9   1999  4673
Total:        640  2140  486.9   1999  4674
ERROR: The median and mean for the initial connection time are more than twice the standard
       deviation apart. These results are NOT reliable.
Percentage of the requests served within a certain time (ms)
  50%   1999
  66%   2066
  75%   2141
  80%   2267
  90%   2650
  95%   3388
  98%   3774
  99%   3941
 100%   4674 (last request)

コネクションプーリングを無効にした場合

Server Hostname:        rakuda.localhost
Server Port:            80
Document Path:          /
Document Length:        12323 bytes
Concurrency Level:      20
Time taken for tests:   104.939 seconds
Complete requests:      1000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      12579000 bytes
HTML transferred:       12323000 bytes
Requests per second:    9.53 [#/sec] (mean)
Time per request:       2098.78 [ms] (mean)
Time per request:       104.94 [ms] (mean, across all concurrent requests)
Transfer rate:          119.87 [Kbytes/sec] received
Connnection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0     0    0.1      0     3
Processing:   353  2081  502.0   1969  5219
Waiting:      351  2081  502.0   1969  5219
Total:        353  2081  502.0   1969  5219
Percentage of the requests served within a certain time (ms)
  50%   1969
  66%   2033
  75%   2117
  80%   2192
  90%   2503
  95%   3011
  98%   4032
  99%   4571
 100%   5219 (last request)

これ以外にもいくつかパスを替えてベンチマークをとったところ、いずれも若干ですがプーリングしないほうが早かったので、現在はプーリングしないほうで運用しています。

Posted by horiuchi at 10:41 | Permalink | Comments (0) | TrackBack (1)

Sledgeのセッション用テーブルはMyISAMにしています。

naoyaさんのエントリーnaoyaのはてなダイアリー - MyISAM vs InnoDBに反応して、久々にエントリを書いてみます。

FlipClipは、すべてMyISAMで運用しているんですが、理由はあんまりなくて、デフォルトでMyISAMだからってのが大きいのと、スナップショットを取るのにmysqlsnapshotに手を加えたものを使っているので、InnoDBにするとそれを使えなくなるというのが主な理由です。それにまだDBがボトルネックだうはーってな状態になったことがないってのもあります。

それでも少し前にサーバのチューニングをそろそろ考えたほうがいいかなーということを考えたことがありまして、

その時にチューニングの候補に考えたものの一つが、Sledgeのセッション用のテーブルをMyISAMからInnoDBに替えてみるということでした。

セッションテーブルはスナップショットを取る必要ないですし、InnoDBにして早くなったらラッキーってのと、Sledgeのセッション用のテーブルは1リクエストで必ず1回書き込みが行われるので、読み込みと書き込みが同程度発生するので、更新系が多い場合はInnoDBがよいというのにあてはまるかなと思ったからです。

そこで実際にSledgeで作ったアプリケーションを使ってセッションテーブルをInnoDBにした場合と、MyISAMにした場合でどれほど性能に差がでるかabを使って簡単にベンチマークしてみました。

以下がabを使って同時10リクエストで合計1000リクエスト実行した際の結果です。

MyISAMの場合

Benchmarking rakuda.localhost (be patient)
Server Software:        Apache/1.3.36
Server Hostname:        rakuda.localhost
Server Port:            80
Document Path:          /
Document Length:        14911 bytes
Concurrency Level:      10
Time taken for tests:   110.009 seconds
Complete requests:      1000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      15167000 bytes
HTML transferred:       14911000 bytes
Requests per second:    9.09 [#/sec] (mean)
Time per request:       1100.09 [ms] (mean)
Time per request:       110.01 [ms] (mean, across all concurrent requests)
Transfer rate:          137.87 [Kbytes/sec] received
Connnection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0     0    0.0      0     1
Processing:   292  1096  223.5   1031  1976
Waiting:      291  1096  223.5   1031  1976
Total:        292  1096  223.5   1031  1976
ERROR: The median and mean for the initial connection time are more than twice the standard
       deviation apart. These results are NOT reliable.
Percentage of the requests served within a certain time (ms)
  50%   1031
  66%   1071
  75%   1109
  80%   1145
  90%   1338
  95%   1753
  98%   1832
  99%   1888
 100%   1976 (last request)

InnoDBの場合

Benchmarking rakuda.localhost (be patient)
Server Software:        Apache/1.3.36
Server Hostname:        rakuda.localhost
Server Port:            80
Document Path:          /
Document Length:        14911 bytes
Concurrency Level:      10
Time taken for tests:   110.730 seconds
Complete requests:      1000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      15167000 bytes
HTML transferred:       14911000 bytes
Requests per second:    9.03 [#/sec] (mean)
Time per request:       1107.30 [ms] (mean)
Time per request:       110.73 [ms] (mean, across all concurrent requests)
Transfer rate:          136.97 [Kbytes/sec] received
Connnection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0     0    0.0      0     0
Processing:   765  1102  273.9   1010  2476
Waiting:      765  1102  273.9   1010  2476
Total:        765  1102  273.9   1010  2476
Percentage of the requests served within a certain time (ms)
  50%   1010
  66%   1059
  75%   1120
  80%   1180
  90%   1466
  95%   1787
  98%   1973
  99%   2198
 100%   2476 (last request)

結果としてMyISAMもInnoDBも速度的にはほとんど変わらなかった(ちょっとMyISAMのほうが速かった)ので、今まで通りMyISAMでいいかという結論に達しました。

Posted by horiuchi at 09:44 | Permalink | Comments (2) | TrackBack (1)