"Christopher L. Everett" wrote:
>
> Adi wrote:
> >
> > martin langhoff wrote:
> > >
> > > Chris,
> > >
> > > i'd bet my head a few months ago someone announced an apache::bench
> > > module, that would take a log and run it as a benchmarking secuence of
> > > HTTP requests. just get to the list archives and start searching with
> > > benchmarks and logs. CPAN is your friend, also.
> >
> > It was HTTPD::Bench::ApacheBench. It is a Perl API to ab. It doesn't take a
> > log per se, it simply sends sequences of HTTP requests and benchmarks the
> > results. I'm sure you could very easily write a script to parse a log and then
> > make a benchmarking run out of it.
>
> Yes, I considered ab and I did find HTTPD::Bench::ApacheBench, while
> excellently
> done and copiously documented, isn't quite what I need:
>
> 1) I want to spoof the IP addresses of the browsers (I just realized
> that
> since I'm using mod_proxy_add_forward anyway, I can make the
> requester
> script behave as a proxy; the rest is cookbook). I can't find
> provision
> for that in the interface for HTTPD::Bench::ApacheBench.
Yeah, that would require adding arbitrary HTTP headers to each benchmark
request... that's currently on our to-do list (I think).
> 2) Record the query parameters as well as the response's MD5 checksum
> directly in a database table on the fly.
This is all possible with ApacheBench. It wouldn't be stored in real-time (i.e.
as the request is sent) but you set up the benchmarking runs, so you know all
the query parameters (which are all either in the URI or the postdata for each
request), and ApacheBench returns all the response data, which you can then pass
thru an MD5 hash and store in the database.
> 3) The interface is more suited to setting up, then executing a batch
> run
> programmatically, rather than replaying a log.
Right.. it was designed to be generally useful. To replay a log you simply need
to set up a batch that exactly duplicates your log.
>
> Having examined the ApacheBench.pm source, I don't see how I can make it
> do
> what I want by subclassing it. Also the code is a little bit mystifying
I didn't really intend it to be subclassed, because basically all it is is a
single XS function with a little perl to set it up and store the results. You
should be able to inherit it's methods if you want, though I don't see what it
would get you over just instantiating an ApacheBench object.
package MyModule;
@ISA = qw(HTTPD::Bench::ApacheBench);
MyModule->add({urls => ["http://url.one/", "http://url.two/"]});
my $r = MyModule->execute;
> to
> me in that the last line in the execute method, "return $self->ab;" is
> the
> only mention of the class method "ab" in the entire file. Obviously I
That's because "ab" is the XS function that sends the HTTP requests and builds
up a hash with all the response data and times. All the looping is done in C
for speed. Take a look at ApacheBench.xs. (especially if you feel like adding
the arbitrary HTTP request header functionality, hint hint :)
> have
> _much, much_ more to learn ... :)
No, actually you pointed out some good feature additions that we should think
about making to ApacheBench. Thanks.
-Adi