NanoA を mod_perl で使用する方法
httpd.conf
Alias /nanoa /Users/kazuho/dev/NanoA RedirectMatch permanent ^/nanoa/$ /nanoa/nanoa.pl PerlRequire /Users/kazuho/dev/NanoA/etc/statup.pl <Location "/nanoa/nanoa.pl"> SetHandler perl-script PerlResponseHandler ModPerl::RegistryPrefork PerlOptions +ParseHeaders Allow from All Options +ExecCGI </Location> <Directory /Users/kazuho/dev/NanoA/app> <FilesMatch "(\.(pm|mt|conf)|~)"> Deny from All Order deny,allow </FilesMatch> Allow from All Order allow,deny </Directory> # if .htaccess is being processed, the value is set to 1 SetEnv HTTP_NANOA_USE_HTACCESS 1
startup.pl
use lib map { "/Users/kazuho/dev/NanoA/$_" } qw(MENTA/lib MENTA/extlib lib extlib app); use CGI::ExceptionManager; use Class::Accessor::Lite; use NanoA; use NanoA::Config; use NanoA::Dispatch; use NanoA::TemplateLoader; 1;
ベンチマーク
ちなみに hello world ベンチはこんな感じです。最適化の余地はまだいっぱいありますが。18:43 追記: 少しいじったら4割弱速くなったのでベンチ差し替え。
$ ab -n 10000 -c 10 http://localhost/nanoa/nanoa.pl/example/hello 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 localhost (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests Server Software: Apache/2.2.9 Server Hostname: localhost Server Port: 80 Document Path: /nanoa/nanoa.pl/example/hello Document Length: 11 bytes Concurrency Level: 10 Time taken for tests: 6.789 seconds Complete requests: 10000 Failed requests: 0 Write errors: 0 Total transferred: 2170651 bytes HTML transferred: 110033 bytes Requests per second: 1473.04 [#/sec] (mean) Time per request: 6.789 [ms] (mean) Time per request: 0.679 [ms] (mean, across all concurrent requests) Transfer rate: 312.25 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 1.4 1 15 Processing: 1 6 6.4 5 274 Waiting: 0 5 6.3 5 274 Total: 1 7 6.5 6 275 Percentage of the requests served within a certain time (ms) 50% 6 66% 6 75% 7 80% 7 90% 9 95% 11 98% 14 99% 18 100% 275 (longest request)