D6-7 note: kbahey was kind enough to grant me permissions to bring life back into this project after it was removed from the Devel project this summer 2011.
A full code review/cleanup has been executed and the integration with prod_check and prod_monitor is finished! Remote performance monitoring is at your fingertips without the need for Nagios!


Note about the 2.x branch: there is a major change in the way the performace summary data is stored, see #1848850: We don't need different data stores - let Drupal's cache backend decide

This module provides performance statistics logging for a site, such as page generation times, and memory usage, for each page load.

This module is useful for developers and site administrators alike to identify pages that are slow to generate or use excessive memory.

Features include:

  • Settings to enable detailed logging or summary logging. The module defaults to no logging at all.
  • Detailed logging causes one database row to be written for each page load of the site.
    The data includes page generation time in milliseconds, and the number of bytes allocated to PHP, time stamp, ...etc.
  • Summary logging logs the average and maximum page generation time, average and maximum memory usage, last access time, and number of accesses for each path.
  • Summary can be logged to memcache, if configured, so as to not cause extra load on the database.
    This works when APC cannot be used (e.g. certain FastCGI configurations, or when you have many web servers on different boxes. This mode is recommended for live sites.
  • Summary can be logged to any cache (in 2.x only!) for which a Drupal caching module is available that transparently integrates with the drupal cache layer. Some examples:
  • A settings option is available when using summary mode, to exclude pages with less than a certain number of accesses. Useful for large sites.
  • Support for normal page cache.

Note that detailed logging is only suitable for a site that is in development or testing. Do NOT enable detailed logging on a live site.

The memory measurement feature of this module depends on the memory_get_peak_usage() function, available only in PHP 5.2.x or later.

Only summary logging with Memcache, APC or similar mechanisms are the recommended mode for live sites, with a threshold of 2 or more.

Note on Completeness

Please note that when summary logging to APC or Memcache, the data captured in the summary will not be comprehensive reflecting every single page view for every URL.

The reason for this is that there is no atomic locking when updating the data structures that store per-URL statistics in this module.

This means that the values you get when using these storage caches are only samples, and would miss some page views, depending on how busy the site is.

For memcache, there is way to implement locking using the $mc->increment and/or $mc->add as well.
However, there is a risk if these are implemented, that there will be less concurrency and we can cause a site to slow down.


To configure the Performance Logging and Monitoring module, navigate to the settings page. By default, this module creates a key for each entry based off of the hostname of the site being accessed. If you have a site with multiple domains, it is recommended to specify a shared key between all sites in your settings.php file:
$conf['performance_key'] = 'example_key';

If you are using memcache, then you need to configure an extra bin for performance.
If you have multiple web server boxes, then it is best to centralize this bin for all the boxes, so you get combined statistics.

Drupal 6 - your settings.php looks like this:

  $conf = array(
    'cache_inc' => './sites/all/modules/memcache/memcache.inc',

    'memcache_servers' => array(
      '' => 'default',
      // More bins here ....
      '' => 'performance',

    'memcache_bins' => array(
      'cache_performance' => 'performance',

Drupal 7 - your settings.php looks like this:

  $conf['cache_backends'][] = './sites/all/modules/memcache/memcache.inc';
  $conf['cache_default_class'] = 'MemCacheDrupal';
  // Prevent special cache_form bin from being assigned to a volatile cache
  // storage implementation
  $conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

  $conf['memcache_servers'] = array(
    '' => 'default',
    // More bins here ....
    '' => 'performance',
  $conf['memcache_bins'] = array(
    'cache_performance' => 'performance',

Note that since version 2.x, you can use any Drupal caching module available
that transparently integrates with the drupal cache layer (like the apc or
filecache modules).

Custom detailed logging implementation

As mentioned before, detailed logging is not recommended on production environments. If you, for whatever reason, do wish detailed logging on production, you can now create a custom detailed logging mechanism, available since the stable 2.0 version, that will not interfere with your live site. You can do this by creating your own versions of the following functions:

  - performance_log_details($params)
    => function that is called to store the performance data
  - performance_view_details()
    => function that is called to view the stored detail log. This function is called from hook_menu() and should return content that Drupal can render as a page.
  - performance_clear_details()
    => function that is called to delete the entire detail log

Have a look at includes/performance.details.inc for more details about these

When you have created those functions, add the location of the file containing
your custom implementation to settings.php like so:

  $conf['performance_detail_logging'] = './sites/all/path/to/your/file';

Note: there is no drush support for your custom detail logging implementation!

Drush support

Drush support has been integrated as well (in the 6.x-1.30-beta and 7.x-1.7-beta releases). You can check the summary and detail logs using the performance-summary (aliased as perf-sm) and performance-detail (aliased as perf-dt) commands. Some examples:

  Retrieve last 15 entries from the detail log:
    drush performance-detail 15

  Retrieve last 20 summary log entries sorted by the number of queries,
    drush performance-summary 20 query_count

  Retrieve last 35 entries from the detail log sorted by size, ascending:
    drush performance-detail 35 bytes asc

Use drush perf-sm --help or drush perf-dt --help to see a full explanation.

Note: the arguments on the summary pages in the 1.x branch work ONLY when logging to the database! With other sources (memcache, Zend, APC) you will see a summary of the last 15 minutes!
Drush support is better in the 2.x branch which is the recommended version to use.


You can see more information and screenshots of the module in this post: Performance logging and monitoring: module to log performance statistics for Drupal.


Khalid Baheyeldin of 2bits.com.

The author can also be contacted for paid customizations of this module as well as Drupal performance tuning, consulting, installation, development, and customizations.

Active Maintainer

malc0mn, sponsored by Nascom

Project information