mod_perl

It makes me sad people aren't using it.

I just did a hello world test on my system, a bare apache with mod_php 7, and then that same apache with mod_perl loaded instead. I got 1,500 requests per second more with mod_perl

The following was performed on a relatively low traffic Intel E3-1230 v6 with 64gb of RAM

mod_php for a baseline:

config:

ServerRoot "/opt/apps/apache" PidFile /home/me/modapache/apache/logs/modphp.pid Listen 11208 LoadModule authn_file_module modules/mod_authn_file.so LoadModule authn_core_module modules/mod_authn_core.so LoadModule authz_host_module modules/mod_authz_host.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule authz_core_module modules/mod_authz_core.so LoadModule access_compat_module modules/mod_access_compat.so LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule reqtimeout_module modules/mod_reqtimeout.so LoadModule filter_module modules/mod_filter.so LoadModule mime_module modules/mod_mime.so LoadModule log_config_module modules/mod_log_config.so LoadModule env_module modules/mod_env.so LoadModule headers_module modules/mod_headers.so LoadModule setenvif_module modules/mod_setenvif.so LoadModule version_module modules/mod_version.so LoadModule unixd_module modules/mod_unixd.so LoadModule status_module modules/mod_status.so LoadModule autoindex_module modules/mod_autoindex.so LoadModule dir_module modules/mod_dir.so LoadModule alias_module modules/mod_alias.so LoadModule rewrite_module modules/mod_rewrite.so LoadModule php7_module modules/libphp7.so ServerAdmin me@example.com <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/home/me/modapache/root" <Directory "/home/me/modapache/root"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.php index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "/home/me/modapache/apache/logs/modphp.error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agen +t}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> # You need to enable mod_logio.c to use %I and %O LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Ag +ent}i\" %I %O" combinedio </IfModule> CustomLog "/home/me/modapache/apache/logs/modphp.access_log" commo +n </IfModule> <IfModule headers_module> RequestHeader unset Proxy early </IfModule> <IfModule mime_module> TypesConfig conf/mime.types AddType application/x-httpd-php .php AddType application/x-compress .Z AddType application/x-gzip .gz .tgz </IfModule>

script:

<?php echo '<p>Hello World</p>'; ?>

test:

$ curl -v http://127.0.0.1:11208/hello.php < HTTP/1.1 200 OK < Server: Apache/2.4.25 (Unix) PHP/7.4.2 < <p>Hello World</p>

apache bench:

$ /opt/apps/apache/bin/ab -n 250000 -c 3 http://127.0.0.1:11208/hello. +php This is ApacheBench, Version 2.3 <$Revision: 1757674 $> Server Software: Apache/2.4.25 Server Hostname: 127.0.0.1 Server Port: 11208 Document Path: /hello.php Document Length: 18 bytes Concurrency Level: 3 Time taken for tests: 14.386 seconds Complete requests: 250000 Failed requests: 0 Total transferred: 54500000 bytes HTML transferred: 4500000 bytes Requests per second: 17377.86 [#/sec] (mean) Time per request: 0.173 [ms] (mean) Time per request: 0.058 [ms] (mean, across all concurrent reques +ts) Transfer rate: 3699.58 [Kbytes/sec] received

now mod_perl:

config:

ServerRoot "/opt/apps/apache" Listen 127.0.0.1:11208 LoadModule authn_file_module modules/mod_authn_file.so LoadModule authn_core_module modules/mod_authn_core.so LoadModule authz_host_module modules/mod_authz_host.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule authz_core_module modules/mod_authz_core.so LoadModule access_compat_module modules/mod_access_compat.so LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule reqtimeout_module modules/mod_reqtimeout.so LoadModule filter_module modules/mod_filter.so LoadModule mime_module modules/mod_mime.so LoadModule log_config_module modules/mod_log_config.so LoadModule env_module modules/mod_env.so LoadModule headers_module modules/mod_headers.so LoadModule setenvif_module modules/mod_setenvif.so LoadModule version_module modules/mod_version.so LoadModule unixd_module modules/mod_unixd.so LoadModule status_module modules/mod_status.so LoadModule autoindex_module modules/mod_autoindex.so LoadModule dir_module modules/mod_dir.so LoadModule alias_module modules/mod_alias.so LoadModule perl_module modules/mod_perl.so LoadModule apreq_module modules/mod_apreq2.so ServerAdmin me@example.com <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/home/me/modapache/root" <Directory "/home/me/modapache/root"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "/home/me/modapache/apache/logs/modperl.error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agen +t}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Ag +ent}i\" %I %O" combinedio </IfModule> CustomLog "/home/me/modapache/apache/logs/modperl.access_log" comm +on </IfModule> <IfModule mime_module> TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz </IfModule> PidFile /home/me/modapache/apache/logs/modperl.pid <Perl> use lib qw(/home/me/modapache/lib); use MyApache2::Rocks (); </Perl> <Location /> SetHandler modperl PerlResponseHandler MyApache2::Rocks </Location> <Location /robots.txt> SetHandler None </Location> <Location /favicon.ico> SetHandler None </Location>

script:

package MyApache2::Rocks; use strict; use warnings; use Apache2::RequestRec (); use Apache2::RequestIO (); use Apache2::Const -compile => qw(OK); sub handler { my $r = shift; $r->content_type('text/plain'); $r->print( "mod_perl 2.0 rocks!\n" ); return Apache2::Const::OK; } 1;

test:

$ curl -v http://127.0.0.1:11208/foo/bar < HTTP/1.1 200 OK < Server: Apache/2.4.25 (Unix) mod_apreq2-20090110/2.8.0 mod_perl/2.0. +10 Perl/v5.24.1 < mod_perl 2.0 rocks!

apache bench:

$ /opt/apps/apache/bin/ab -n 250000 -c 3 http://127.0.0.1:11208/foo/ba +r This is ApacheBench, Version 2.3 <$Revision: 1757674 $> Server Software: Apache/2.4.25 Server Hostname: 127.0.0.1 Server Port: 11208 Document Path: /foo/bar Document Length: 20 bytes Concurrency Level: 3 Time taken for tests: 13.204 seconds Complete requests: 250000 Failed requests: 0 Total transferred: 51500000 bytes HTML transferred: 5000000 bytes Requests per second: 18934.11 [#/sec] (mean) Time per request: 0.158 [ms] (mean) Time per request: 0.053 [ms] (mean, across all concurrent reques +ts) Transfer rate: 3809.01 [Kbytes/sec] received


In reply to Re: PSGI/Plack unsatisfactory performance by trwww
in thread PSGI/Plack unsatisfactory performance by locked_user beautyfulman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.