Documentation for mod_benchmark Apache Module

Version 1.5b, by Jerome Delamarche


1.What is mod_benchmark ?
2.Requirements
3.Configuration Directives
3.1.Server Level Directives
3.2.Directory/Location Level Directives
3.3.Configuration Sample


1.What is mod_benchmark ?

mod_benchmark is an Apache module that can be used to measure the server response time according to the system load.

It is packaged with a web interface that gives some statistics about the performance of your server.

It can also send alerts when time threshold is overrun.


2.Requirements

mod_benchmark works under Linux 2.4.x (should also work for Linux 2.2.x)
it needs Apache 1.3.x or 2.0.x, PHP 4.x with GD for the GUI,
we recommand the use of MySQL but other DBM can be easily interfaced with it. Sybase 11.9.2 is also supported.


3.Configuration Directives

Normally, the installation process (apxs !) should have added the two following lines in your httpd.conf file:

LoadModule benchmark_module /path_for_apache_modules/mod_benchmark.so
AddModule mod_benchmark.c

mod_benchmark behaviour can be customized using the following Apache directives:

3.1.Server Level Directives

LogFormat
  mod_benchmark defines two new variables that can be used to add information to the request log:
BenchmarkElapsed which gives the elapsed time to answer the request. The time format is "seconds.micro-seconds"
BenchmarkScoreBoard gives the count of ready and busy Apache instances at the request time.

BenchmarkTrace debug
  Sets the module in "debug" mode. Debug messages will be added to the Apache error log.

BenchmarkUseScoreBoard on|off
  Using the Apache scoreboard makes each request logged with the count of ready and busy Apache instances at the time it was required by the client. Logging this information can be useful if you want to correlate the response time with the system load.

BenchmarkStore /path_to_db_interface.so:dbserver:dbname:dbuser:dbpwd
Each request measured by mod_benchmark can be logged in the Apache log (using the LogFormat directive) and/or can be stored in a database.
To store the requests in a DB, you must specify the interface for this DB (there is a MySQL interface in the package: benchmark-mysql.c, and it's very easy to clone other DB interface from this file), and then the four parameters that allow the module to connect and store data in the database tables.
Normally, the tables have been created from the mod_benchmark.sql script.

BenchmarkWithSysInfo on|off:statprogram:socketname:interval
For each measured request, the module can also store the current system load and memory usage. Logging this information can be useful if you want to correlate the response time with the system load.
If you specify the "on" value, mod_benchmark will start the sysstat2 process at launch time. This process will then communicate with the module using the socketname Unix socket and will compute the system load at each interval seconds. sysstat2 will be automatically stopped when Apache stops.

BenchmarkAlertAction proc
Each time a request will overrun the threshold specified by the BenchmarkAlertLimit directive (see below), it will run the external proc program with the request and the response time (in milliseconds) as arguments.

3.2.Location Level Directives

Please note that the following directives must be included in a <Location> directive block and will not correctly work in a <Directory> block.

BenchmarkEngine on|off
  Activate or desactivate the module for the current Directory/Location

BenchmarkAccept regexp
  Regular expression that filters the URI to handle.
For example, if you want to measure PHP and PL scripts only, specify:
BenchmarkAccept \.php$|\.pl$

BenchmarkAlertLimit threshold
  If you have inserted a BenchmarkAlertAction direction (see above), you can specify the threshold (in milliseconds) for the generated alerts.

3.3.Configuration Sample

...
LoadModule benchmark_module /usr/lib/apache/mod_benchmark.so
AddModule mod_benchmark.c
...
LogFormat "%t %{BenchmarkElapsed}n %{BenchmarkScoreBoard}n \"%r\" %s %B" benchmark_log
CustomLog logs/benchmark.log benchmark_log
...
BenchmarkTrace debug
BenchmarkUseScoreBoard o
BenchmarkStore /usr/lib/apache/benchmark-mysql.so:localhost:benchmark:wwwrun:wwwpwd
BenchmarkWithSysInfo on:/opt/apache/mod_benchmark/sysstat2:/tmp/bench:5
BenchmarkAlertAction /opt/apache/mod_benchmark/alerter.sh
...
<Location /scripts>
BenchmarkEngine on
BenchmarkAccept \.html$|\.php$
BenchmarkAlertLimit 200
</Location>


Jerome Delamarche - jd@trickytools.com