mod_mpmstats

mod_mpmstats provides two capabilities:

  1. check if the web server is at or near the MaxClients setting
  2. optionally report the IHS worker thread usage at a specified interval

Often this type of monitoring has been performed with mod_status, which requires that a request be sent to the web server from a browser or script, and then be viewed or parsed to record the web server activity.

mod_mpmstats can eliminate the need to constantly monitor the mod_status report to determine the current thread usage.

Here is an example section of the error log when mod_mpmstats reports that most or all of the web server threads are busy handling clients:

[Thu Aug 19 14:14:00 2004] [notice] mpmstats: approaching MaxClients (48/50)
[Thu Aug 19 14:14:05 2004] [error] server reached MaxClients setting, consider raising the MaxClients setting

(The second message would appear even without mod_mpmstats.)

Without this module, the web server will only report the busy condition when it actually reaches MaxClients, and it will only report it once per restart of the server. mod_mpmstats will check every second, and will report the busy condition as often as once every 90 seconds.

Here is an example section of the error log when mod_mpmstats has been configured to report the thread usage every two seconds with the ReportInterval 2 directive:

[Thu Aug 19 14:01:52 2004] [notice] mpmstats: rdy 712 bsy 312 rd 121 wr 173 ka 0 log 0 dns 0 cls 18
[Thu Aug 19 14:01:54 2004] [notice] mpmstats: rdy 718 bsy 306 rd 120 wr 169 ka 0 log 0 dns 0 cls 17
[Thu Aug 19 14:01:56 2004] [notice] mpmstats: rdy 729 bsy 295 rd 123 wr 135 ka 0 log 0 dns 0 cls 37
[Thu Aug 19 14:01:58 2004] [notice] mpmstats: rdy 759 bsy 265 rd 130 wr 67 ka 0 log 0 dns 0 cls 68
[Thu Aug 19 14:02:00 2004] [notice] mpmstats: rdy 809 bsy 215 rd 131 wr 44 ka 0 log 0 dns 0 cls 40
[Thu Aug 19 14:02:02 2004] [notice] mpmstats: rdy 781 bsy 243 rd 117 wr 106 ka 0 log 0 dns 0 cls 20
[Thu Aug 19 14:02:04 2004] [notice] mpmstats: rdy 813 bsy 211 rd 118 wr 72 ka 0 log 0 dns 0 cls 21
[Thu Aug 19 14:02:07 2004] [notice] mpmstats: rdy 685 bsy 339 rd 177 wr 122 ka 0 log 0 dns 0 cls 40
[Thu Aug 19 14:02:09 2004] [notice] mpmstats: rdy 707 bsy 317 rd 193 wr 97 ka 0 log 0 dns 0 cls 27
[Thu Aug 19 14:02:11 2004] [notice] mpmstats: rdy 731 bsy 293 rd 196 wr 39 ka 0 log 0 dns 0 cls 58
[Thu Aug 19 14:02:11 2004] [error] [client 9.27.164.15] File does not exist: /home/trawick/testihsbuild/install/htdocs/en_US/jakdsljadslkfjalkfdsasf
[Thu Aug 19 14:02:13 2004] [notice] mpmstats: rdy 747 bsy 277 rd 186 wr 71 ka 0 log 0 dns 0 cls 20
[Thu Aug 19 14:02:15 2004] [notice] mpmstats: rdy 749 bsy 275 rd 162 wr 89 ka 0 log 0 dns 0 cls 24
[Thu Aug 19 14:02:17 2004] [notice] mpmstats: rdy 764 bsy 260 rd 156 wr 83 ka 0 log 0 dns 0 cls 21
[Thu Aug 19 14:02:19 2004] [notice] mpmstats: rdy 784 bsy 240 rd 158 wr 33 ka 0 log 0 dns 0 cls 49
[Thu Aug 19 14:02:21 2004] [notice] mpmstats: rdy 788 bsy 236 rd 159 wr 59 ka 0 log 0 dns 0 cls 18
[Thu Aug 19 14:02:23 2004] [notice] mpmstats: rdy 735 bsy 289 rd 161 wr 117 ka 0 log 0 dns 0 cls 11

Note: If the web server is not actively processing any requests, the report will not be written.

The fields logged are described in the table below:

field description
rdy (ready) the number of web server threads started and ready to process new client connections
bsy (busy) the number of web server threads already processing a client connection
rd (reading) the number of busy web server threads currently reading the request from the client
wr (writing) the number of busy web server threads that have read the request from the client but are either processing the request (e.g., waiting on a response from WebSphere Application Server) or are writing the response back to the client
ka (keepalive) the number of busy web server threads that are not processing a request but instead are waiting to see if the client will send another request on the same connection; refer to the KeepAliveTimeout directive to decrease the amount of time that a web server thread remains in this state
log (logging) the number of busy web server threads that are writing to the access log
dns (dns lookup) the number of busy web server threads that are performing a dns lookup
cls (closing) the number of busy web server threads that are waiting for the client to acknowledge that the entire response has been received so that the connection can be closed

Here's a comparison of displays by mod_mpmstats vs. mod_status for the same server state:

mod_mpmstats would simply write

[Thu Aug 19 15:22:43 2004] [notice] mpmstats: rdy 5 bsy 45 rd 10 wr 3 ka 0 log 0 dns 0 cls 31

The mod_status report would look like this:

Apache Server Status for b80-2.raleigh.ibm.com

Server Version: IBM_HTTP_Server/2.0.47.1-PQ90698 Apache/2.0.47 (Unix)
Server Built: Jun 28 2004 10:32:12

Current Time: Thursday, 19-Aug-2004 15:22:43 EDT
Restart Time: Thursday, 19-Aug-2004 15:22:03 EDT
Parent Server Generation: 0
Server uptime: 40 seconds
Total accesses: 372 - Total Traffic: 5.7 MB
CPU Usage: u44.02 s8.66 cu0 cs0 - 132% CPU load
9.3 requests/sec - 146.9 kB/second - 15.8 kB/request
45 requests currently being processed, 5 idle workers
CCCCCCCCRRCCRR___RWCCCCCCCCCCW_CCRCWRC_CCCCCRCCRRC..............
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

If ExtendedStatus On were specified in httpd.conf, the actual requests being processed would be listed in the mod_status report.

The mod_status report is easier to read but it is not in a form that is easy to save at intervals and easily see the thread use.

Supported server versions:

IHS 2.0.42.2 and above on AIX and Linux (x86)

(Some other platforms are expected to be supported in the future.)

IBM recommendation

Enable this module if you need to track web server thread usage over time but you don't need extensive details such as what requests are being processed.

Note that mod_status provides more details, including actual requests being processed, so we recommend that mod_status be enabled as well in case that information is necessary.

Installation

Copy mod_mpmstats.so for your platform to the modules directory in the web server installation location (e.g., to /opt/IBMIHS/modules).

Activation

  1. Add the following directive to the end of your configuration file:
    loadmodule mpmstats_module modules/mod_mpmstats.so
    
  2. If you want a report of thread usage written to the error log at intervals, add this after the loadmodule directive.
    <IfModule mod_mpmstats.c>
    ReportInterval 15
    </IfModule>
    

    (or change "15" to the desired report interval, in seconds)

    Without the ReportInterval directive, mod_mpmstats will only report when most or all web server threads are busy processing requests.

  3. Restart the server so that the updated configuration takes effect.

This module does not require ExtendedStatus On.

Deactivation

  1. Comment out the LoadModule directive added as part of the activation step.
  2. Restart the server so that the updated configuration takes effect.