Hateburo: kazeburo hatenablog

Operations Engineer / Site Reliability / 運用系小姑 / Perl Monger

perl-5.8と5.16でStarletのベンチマークを取って比べてみる

の検証をいろいろついでにやってみた。

環境は Xeon L5630 (2.13GHz) 4コア8スレッド x 2 なサーバ。ベンチマークをクライアントは同じスペックの別のサーバです

perl-5.8はCentOS5のsystem perl

$ /usr/bin/perl -v
This is perl, v5.8.8 built for x86_64-linux-thread-multi

perl-5.16はperlbrewにてインストールしたもの

$perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux

5.16はthreadもoffになっています

ベンチマークにつかったアプリケーションはこちら

use Plack::Builder;

my $content="x"x128;
builder {
    enable 'AxsLog', combined => 1, logger => sub {};
    sub{[200,['Content-Type','text/html'],[$content]]}
};

AxsLogをいれて少し負荷がかかるようにしている

それぞれ依存をインストール

$ curl -kL http://cpanmin.us/ | /usr/bin/perl - -n -lextlib58sys Starlet HTTP::Parser::XS Plack::Middleware::AxsLog
$ curl -kL http://cpanmin.us/ | perl - -n -lextlib Starlet HTTP::Parser::XS Plack::Middleware::AxsLog

Starletの起動オプションはこんな感じ

# perl-5.8
$ /usr/bin/perl -Mlib=extlib58sys/lib/perl5 ./extlib58sys/bin/plackup -E production -Ilib -s Starlet -p 5321 --max-workers 50  --max-reqs-per-child 100000 --max-keepalive-reqs 1000000 -a test.psgi 

# perl-5.16
$ perl -Mlib=extlib/lib/perl5 ./extlib/bin/plackup -E production -Ilib -s Starlet -p 5321 --max-workers 50  --max-reqs-per-child 100000 --max-keepalive-reqs 1000000 -a test.psgi 

abコマンドは

$ ab -c 40 -n 50000 http://10.xx.xx.xx:5321/

結果

perl-5.8

Concurrency Level:      40
Time taken for tests:   1.817 seconds
Complete requests:      50000
Failed requests:        0
Write errors:           0
Total transferred:      12100726 bytes
HTML transferred:       6400384 bytes
Requests per second:    27517.48 [#/sec] (mean)
Time per request:       1.454 [ms] (mean)
Time per request:       0.036 [ms] (mean, across all concurrent requests)
Transfer rate:          6503.54 [Kbytes/sec] received

perl-5.16

Concurrency Level:      40
Time taken for tests:   1.751 seconds
Complete requests:      50000
Failed requests:        0
Write errors:           0
Total transferred:      12100484 bytes
HTML transferred:       6400256 bytes
Requests per second:    28555.40 [#/sec] (mean)
Time per request:       1.401 [ms] (mean)
Time per request:       0.035 [ms] (mean, across all concurrent requests)
Transfer rate:          6748.72 [Kbytes/sec] received


ちょっと速いってところでしょうか。
ついでにkeepaliveでのテストもしてみた。こっちほうが処理系の影響がでやすいはず

perl-5.8

Concurrency Level:      40
Time taken for tests:   0.908 seconds
Complete requests:      50000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    50000
Total transferred:      14350287 bytes
HTML transferred:       6400128 bytes
Requests per second:    55089.07 [#/sec] (mean)
Time per request:       0.726 [ms] (mean)
Time per request:       0.018 [ms] (mean, across all concurrent requests)
Transfer rate:          15440.31 [Kbytes/sec] received

perl-5.16

Concurrency Level:      40
Time taken for tests:   0.788 seconds
Complete requests:      50000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    50000
Total transferred:      14350000 bytes
HTML transferred:       6400000 bytes
Requests per second:    63455.40 [#/sec] (mean)
Time per request:       0.630 [ms] (mean)
Time per request:       0.016 [ms] (mean, across all concurrent requests)
Transfer rate:          17784.86 [Kbytes/sec] received