mod_perliteを試してみた


PHPのようにファイルを置くだけで実行されてCGIより速くてmod_perlより簡単なapache moduleだそうです。去年からのCGI frameworkブームを補完する上でも試してみるっきゃないということで

まずはソースの取得

svn co http://code.sixapart.com/svn/mod_perlite/trunk modperlite
cd modperlite

ちなみにもうすぐgithubに移行されるようです。

コンパイルとインストールはapxsにパスを通して

./Build.PL
./Build
./Build install

httpd.confとかconf.d/modperlite.confとかに

LoadModule perlite_module    modules/mod_perlite.so
AddType application/x-httpd-perlite .pl

これで.plの拡張子のファイルがmod_perlite下で動くようになります。

最後にapacheリスタート

例によってこんなCGIでベンチ取って見た。

#!/usr/bin/perl

use strict;
use warnings;

use CGI;

my $q = CGI->new;
print $q->header;
print "HelloWorld $ENV{MOD_PERLITE}";

$ENV{MOD_PERLITE}でmod_perlite下で動いていればバージョン番号が取れる。
この時は0.08と表示されてた。

ab -n 1000 -c 10の結果

CGI

Server Software:        Apache
Server Hostname:        localhost
Server Port:            80

Document Path:          /~hide/test.cgi
Document Length:        11 bytes

Concurrency Level:      10
Time taken for tests:   49.72042 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      159120 bytes
HTML transferred:       11000 bytes
Requests per second:    20.38 [#/sec] (mean)
Time per request:       490.720 [ms] (mean)
Time per request:       49.072 [ms] (mean, across all concurrent requests)
Transfer rate:          3.16 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.6      0      13
Processing:   114  489 226.7    452    4286
Waiting:      114  485 224.6    447    4286
Total:        114  489 226.6    452    4286

Percentage of the requests served within a certain time (ms)
  50%    452
  66%    521
  75%    577
  80%    609
  90%    715
  95%    821
  98%    991
  99%   1118
 100%   4286 (longest request)

modperlite

Server Software:        Apache
Server Hostname:        localhost
Server Port:            80

Document Path:          /~hide/test.pl
Document Length:        15 bytes

Concurrency Level:      10
Time taken for tests:   35.646800 seconds
Complete requests:      1000
Failed requests:        500
   (Connect: 0, Length: 500, Exceptions: 0)
Write errors:           0
Total transferred:      85500 bytes
HTML transferred:       7500 bytes
Requests per second:    28.05 [#/sec] (mean)
Time per request:       356.468 [ms] (mean)
Time per request:       35.647 [ms] (mean, across all concurrent requests)
Transfer rate:          2.33 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     7  354 340.5    252    2025
Waiting:        0  250 355.2     93    2025
Total:          7  354 340.5    252    2025

Percentage of the requests served within a certain time (ms)
  50%    252
  66%    355
  75%    466
  80%    564
  90%    841
  95%   1120
  98%   1316
  99%   1659
 100%   2025 (longest request)

超劇的!ってわけでもないけど確かにパフォーマンスの向上が見られます。
しかもソース改変時に最初の呼び出しはコンパイルが発生して遅いけどapacheのリロードがいらないのが良いです。
これから楽しみなモジュールです。