Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: PSGI/Plack unsatisfactory performance

by trwww (Priest)
on Dec 07, 2021 at 01:09 UTC ( [id://11139451] : note . print w/replies, xml ) Need Help??


in reply to PSGI/Plack unsatisfactory performance

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

Replies are listed 'Best First'.
Re^2: PSGI/Plack unsatisfactory performance
by vincent_veyron (Sexton) on Dec 09, 2021 at 00:47 UTC
    mod_perl It makes me sad people aren't using it.

    Hear! Hear!

    I reproduced your script on my lowly kimsufi and online servers; I'm getting awful numbers compared to yours, do you have any idea why that is? something in the hardware maybe?

    KIMSUFI Intel ATOM N2800 2c/4t 1,86GHz 4Go DDR3 1066MHz Server Software: Apache Server Hostname: vincentveyron.com Server Port: 80 Document Path: /rocks Document Length: 20 bytes Concurrency Level: 3 Time taken for tests: 2.081 seconds Complete requests: 2500 Failed requests: 0 Total transferred: 437500 bytes HTML transferred: 50000 bytes Requests per second: 1201.57 [#/sec] (mean) Time per request: 2.497 [ms] (mean) Time per request: 0.832 [ms] (mean, across all concurrent reques +ts) Transfer rate: 205.35 [Kbytes/sec] received ONLINE Intel(R) Atom(TM) CPU C2338 @ 1.74GHz 4Go Server Software: Apache Server Hostname: vincentveyron.com Server Port: 80 Document Path: /rocks Document Length: 20 bytes Concurrency Level: 3 Time taken for tests: 83.870 seconds Complete requests: 25000 Failed requests: 0 Total transferred: 4375000 bytes HTML transferred: 500000 bytes Requests per second: 298.08 [#/sec] (mean) Time per request: 10.064 [ms] (mean) Time per request: 3.355 [ms] (mean, across all concurrent reques +ts) Transfer rate: 50.94 [Kbytes/sec] received

    https://compta.libremen.com

    Logiciel libre de comptabilité générale en partie double

Re^2: PSGI/Plack unsatisfactory performance
by beautyfulman (Sexton) on Dec 07, 2021 at 12:28 UTC