Yuk :
Apache 2.2/mod_perl 1828 1128 185
Not sure what those 1128 errors are, but your script does not make use of connection caching, so you are creating a new connection every time. You should use Apache::DBI or connect_cached to make use of persistent connections; the handler I pasted below generates 260 pages per second on my 3 year old laptop (3.8ms/request).
You can also use a proxy (e.g. nginx) in front of mod_perl to serve pages to slow client; see : http://perl.apache.org/docs/1.0/guide/strategy.html (old doc but the principle is still valid).
That still leaves the problem regarding apache 2.4. Is it not possible to install/build 2.2 on your distribution, while you wait for mod_perl to be ready?
package Carnet::bench ;
use lib qw(/home/lib);
use strict ;
use warnings ;
use Apache2::Const -compile => qw( OK REDIRECT ) ;
sub handler {
my $r = shift ;
my $dbh = DBI->connect_cached( "DBI:Pg:dbname=xyz", 'john', undef,
+ {
PrintError => 1,
RaiseError => 1,
AutoCommit => 1,
pg_bool_tf => 1
} )
or die "Cannot connect to db" ;
my $sql = 'select name from names' ;
my $data_set = $dbh->selectall_arrayref($sql) ;
my $list ;
for ( @{$data_set} ) {
$list .= '<li>' . $_->[0] . '</li>' ;
}
my $content = '<html><body><ul>' . $list . '</ul></body></html>' ;
$r->content_type('text/html; charset=utf-8') ;
print $content ;
return Apache2::Const::OK ;
}
1 ;
libremen.com : legal case, contract and insurance claim management software
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|