You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by mark warren bracher <br...@citysearch.com> on 2002/03/22 00:12:13 UTC

Re: Apache::args vs Apache::Request speed

I didn't ever actually see a post with newer numbers, so here goes......

I tested the same 50 clients/5000 requests as stas' test in the guide. 
one pass with 2 uri params; another with 26.  naturally I ran it all on 
a server big (and quiescent) enough to handle the 50 concurrent 
requests.  I left out CGI since we already know it is slow.

/test/params and /test/args are mod_perl handlers (I don't use 
Apache::Registry for anything) ParamsTest and ArgsTest respectively. 
the code for both handlers and the relevant pieces of ab output are 
pasted in below.

   -------------------------------------------------------------
   name           query_length  | avtime completed failed    rps
   -------------------------------------------------------------
   apache_args              25  |  33.77      5000      0   1481
   apache_request           25  |  33.17      5000      0   1507
   apache_args             337  |  43.51      5000      0   1141
   apache_request          337  |  45.31      5000      0   1103
   --------------------------------------------------------------
   Non-varying sub-test parameters:
   --------------------------------------------------------------
   concurrency : 50
   connections : 5000

so $apr->param is marginally faster than $r->args for the shorter query, 
marginally slower for the longer one.  I think this may be because we 
can return the full hash $r->args whereas we need to map over 
$apr->param to get a hash (so param gets called three times for the 
short query, 27 times for the larger one).  still, much closer numbers 
than the former test...

- mark

package ParamsTest;

use strict;

use Apache;
use Apache::Constants qw( OK );
use Apache::Request;

sub handler {
     my $r = Apache::Request->new( shift );
     $r->send_http_header( 'text/plain' );
     my %args = map { $_ => $r->param( $_ ) } $r->param();
     $r->print( join( "\n",
                      map { join( '',
                                  $_ , ' => ' , $args{$_}
                                ) }
                      keys %args
                    )
              );
     return OK;
}

1;

package ArgsTest;

use strict;

use Apache;
use Apache::Constants qw( OK );

sub handler {
     my $r = shift;
     $r->send_http_header( 'text/plain' );
     my %args = $r->args();
     $r->print( join( "\n",
                      map { join( '',
                                  $_ , ' => ' , $args{$_}
                                ) }
                      keys %args
                    )
              );
     return OK;
}

1;


Document Path:          /test/params?a=eeeeeeeeee&b=eeeeeeeeee
Document Length:        31 bytes

Concurrency Level:      50
Time taken for tests:   3.317 seconds
Complete requests:      5000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      883520 bytes
HTML transferred:       155620 bytes
Requests per second:    1507.39 [#/sec] (mean)
Time per request:       33.17 [ms] (mean)
Time per request:       0.66 [ms] (mean, across all concurrent requests)
Transfer rate:          266.36 [Kbytes/sec] received

Connnection Times (ms)
               min  mean[+/-sd] median   max
Connect:        0     5    1.9      5    16
Processing:    14    27    4.6     27    50
Waiting:        9    27    4.7     27    49
Total:         14    32    3.7     32    54


Document Path:          /test/args?a=eeeeeeeeee&b=eeeeeeeeee
Document Length:        31 bytes

Concurrency Level:      50
Time taken for tests:   3.377 seconds
Complete requests:      5000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      883168 bytes
HTML transferred:       155558 bytes
Requests per second:    1480.60 [#/sec] (mean)
Time per request:       33.77 [ms] (mean)
Time per request:       0.68 [ms] (mean, across all concurrent requests)
Transfer rate:          261.52 [Kbytes/sec] received

Connnection Times (ms)
               min  mean[+/-sd] median   max
Connect:        0     5    1.8      5    18
Processing:    12    27    4.5     28    63
Waiting:        8    27    4.5     27    63
Total:         12    32    3.7     32    65


Document Path: 
/test/params?a=eeeeeeeeee&b=eeeeeeeeee&c=eeeeeeeeee&d=eeeeeeeeee&e=eeeeeeeeee&f=eeeeeeeeee&g=eeeeeeeeee&h=eeeeeeeeee&i=eeeeeeeeee&j=eeeeeeeeee&k=eeeeeeeeee&l=eeeeeeeeee&m=eeeeeeeeee&n=eeeeeeeeee&o=eeeeeeeeee&p=eeeeeeeeee&q=eeeeeeeeee&r=eeeeeeeeee&s=eeeeeeeeee&t=eeeeeeeeee&u=eeeeeeeeee&v=eeeeeeeeee&w=eeeeeeeeee&x=eeeeeeeeee&y=eeeeeeeeee&z=eeeeeeeeee
Document Length:        415 bytes

Concurrency Level:      50
Time taken for tests:   4.531 seconds
Complete requests:      5000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      2810640 bytes
HTML transferred:       2082885 bytes
Requests per second:    1103.51 [#/sec] (mean)
Time per request:       45.31 [ms] (mean)
Time per request:       0.91 [ms] (mean, across all concurrent requests)
Transfer rate:          620.31 [Kbytes/sec] received

Connnection Times (ms)
               min  mean[+/-sd] median   max
Connect:        0     7    2.9      6    22
Processing:    18    37   11.2     36   496
Waiting:       12    36   11.1     36   495
Total:         18    44   10.8     43   501


Document Path: 
/test/args?a=eeeeeeeeee&b=eeeeeeeeee&c=eeeeeeeeee&d=eeeeeeeeee&e=eeeeeeeeee&f=eeeeeeeeee&g=eeeeeeeeee&h=eeeeeeeeee&i=eeeeeeeeee&j=eeeeeeeeee&k=eeeeeeeeee&l=eeeeeeeeee&m=eeeeeeeeee&n=eeeeeeeeee&o=eeeeeeeeee&p=eeeeeeeeee&q=eeeeeeeeee&r=eeeeeeeeee&s=eeeeeeeeee&t=eeeeeeeeee&u=eeeeeeeeee&v=eeeeeeeeee&w=eeeeeeeeee&x=eeeeeeeeee&y=eeeeeeeeee&z=eeeeeeeeee
Document Length:        415 bytes

Concurrency Level:      50
Time taken for tests:   4.381 seconds
Complete requests:      5000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      2808960 bytes
HTML transferred:       2081640 bytes
Requests per second:    1141.29 [#/sec] (mean)
Time per request:       43.81 [ms] (mean)
Time per request:       0.88 [ms] (mean, across all concurrent requests)
Transfer rate:          641.17 [Kbytes/sec] received

Connnection Times (ms)
               min  mean[+/-sd] median   max
Connect:        0     7    3.0      7    35
Processing:    13    36    6.5     35    86
Waiting:        8    35    6.5     35    86
Total:         13    42    5.6     42    90

Stas Bekman wrote:
> Joe Schaefer wrote:
>> Right- param() was rewritten as XS about 6-8 months ago; since then
>> I've benchmarked it a few times and found param() to be a bit faster than
>> args().  We'll be releasing a 1.0 version of libapreq as soon as Jim 
>> approves of the current CVS version.  Here's what I got using it on 
>> your benchmark (some differences: the tests were run against localhost 
>> running perl 5.00503 + mod_perl 1.26 + apache 1.3.22 and using Perl 
>> handlers instead of Apache::RegistryLoader scripts):
> 
> Great! Now we have an even broader benchmark. Please tell me when 1.0 is 
> released (in case I get carried away with other things and don't notice 
> the announce) and I'll make sure to update my benchmarking package, 
> re-run the benchmarks and correct the results in the guide.
> 
> Thanks Joe!


Re: Apache::args vs Apache::Request speed

Posted by Stas Bekman <st...@stason.org>.
mark warren bracher wrote:
> I didn't ever actually see a post with newer numbers, so here goes......
> 
> I tested the same 50 clients/5000 requests as stas' test in the guide. 
> one pass with 2 uri params; another with 26.  naturally I ran it all on 
> a server big (and quiescent) enough to handle the 50 concurrent 
> requests.  I left out CGI since we already know it is slow.
> 
> /test/params and /test/args are mod_perl handlers (I don't use 
> Apache::Registry for anything) ParamsTest and ArgsTest respectively. the 
> code for both handlers and the relevant pieces of ab output are pasted 
> in below.
> 
>   -------------------------------------------------------------
>   name           query_length  | avtime completed failed    rps
>   -------------------------------------------------------------
>   apache_args              25  |  33.77      5000      0   1481
>   apache_request           25  |  33.17      5000      0   1507
>   apache_args             337  |  43.51      5000      0   1141
>   apache_request          337  |  45.31      5000      0   1103
>   --------------------------------------------------------------
>   Non-varying sub-test parameters:
>   --------------------------------------------------------------
>   concurrency : 50
>   connections : 5000
> 
> so $apr->param is marginally faster than $r->args for the shorter query, 
> marginally slower for the longer one.  I think this may be because we 
> can return the full hash $r->args whereas we need to map over 
> $apr->param to get a hash (so param gets called three times for the 
> short query, 27 times for the larger one).  still, much closer numbers 
> than the former test...

Thanks Mark for pushing me to rerun the benchmark :)

Actually from the tests that I just run Apache::Request::param is 
actually kicks $r->args on long inputs, and a bit faster on the short 
query strings. Even though as you have noticed we call $q->param() 2 x 
keys times more for each request.

Here are the results:

  concurrency connections name                 query_length |  avtime 
completed failed    rps
--------------------------------------------------------------------------------------------

           50        5000 apache_request_param           25 |      53 
    5000      0    900
           50        2000 apache_request_param           25 |      54 
    2000      0    884
           50        5000 r_args                         25 |      55 
    5000      0    879
           50        2000 apache_request_param          105 |      54 
    2000      0    879
           10        5000 apache_request_param           25 |      10 
    5000      0    878
           50        5000 r_args                        105 |      55 
    5000      0    876
           10        2000 r_args                        105 |      10 
    2000      0    869
           50        5000 apache_request_param          105 |      56 
    5000      0    865
           10        5000 apache_request_param          105 |      10 
    5000      0    855
           10        5000 r_args                         25 |      11 
    5000      0    850
           10        2000 apache_request_param          105 |      11 
    2000      0    836
           10        2000 r_args                         25 |      11 
    2000      0    835
           10        2000 apache_request_param           25 |      11 
    2000      0    832
           50        2000 r_args                         25 |      58 
    2000      0    827
           10        5000 r_args                        105 |      11 
    5000      0    810
           50        5000 apache_request_param          207 |      64 
    5000      0    754
           50        2000 apache_request_param          337 |      64 
    2000      0    750
           10        2000 apache_request_param          207 |      12 
    2000      0    749
           10        2000 apache_request_param          337 |      12 
    2000      0    749
           50        2000 apache_request_param          207 |      64 
    2000      0    749
           10        5000 apache_request_param          207 |      12 
    5000      0    746
           50        2000 r_args                        105 |      64 
    2000      0    744
           10        5000 apache_request_param          337 |      12 
    5000      0    732
           50        5000 r_args                        207 |      72 
    5000      0    671
           10        2000 r_args                        337 |      14 
    2000      0    665
           10        5000 r_args                        207 |      14 
    5000      0    661
           50        2000 r_args                        337 |      73 
    2000      0    660
           10        2000 r_args                        207 |      14 
    2000      0    657
           50        5000 apache_request_param          337 |      74 
    5000      0    647
           50        2000 r_args                        207 |      75 
    2000      0    645
           10        5000 r_args                        337 |      15 
    5000      0    627
           50        5000 r_args                        337 |      81 
    5000      0    601

I'll update this and other benchmarks. Something that should be done 
once in a while since the software's performance tend to change over the 
time :)
I'll probably run many more tests and build graphs, so it'll be much 
easier to see what's happening, than from looking at many numbers.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com