README.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. By Khalid Baheyeldin
  2. Copyright 2008 http://2bits.com
  3. Description
  4. -----------
  5. This module provides performance statistics logging for a site, such as page
  6. generation times, and memory usage, for each page load.
  7. This module is useful for developers and site administrators alike to identify
  8. pages that are slow to generate or use excessive memory.
  9. Features include:
  10. * Settings to enable detailed logging or summary logging. The module defaults to
  11. no logging at all.
  12. * Detailed logging causes one database row to be written for each page load of
  13. the site. The data includes page generation time in milliseconds, and the
  14. number of bytes allocated to PHP, time stamp, etc.
  15. * Summary logging logs the average and maximum page generation time, average and
  16. maximum memory usage, last access time, and number of accesses for each path.
  17. * Summary can be logged to any cache for which a Drupal caching module is
  18. available that transparently integrates with the drupal cache layer. Some
  19. examples:
  20. http://drupal.org/project/apc
  21. http://drupal.org/project/memcache
  22. http://drupal.org/project/filecache
  23. * A settings option is available when using summary mode, to exclude
  24. pages with less than a certain number of accesses. Useful for large sites.
  25. * Support for normal page cache.
  26. Note that detailed logging is only suitable for a site that is in development or
  27. testing. Do NOT enable detailed logging on a live site.
  28. The memory measurement feature of this module depends on the
  29. memory_get_peak_usage() function, available only in PHP 5.2.x or later.
  30. Only summary logging with Memcache, APC or similar mechanisms are the
  31. recommended mode for live sites, with a threshold of 2 or more.
  32. Note on Completeness:
  33. ---------------------
  34. Please note that when summary logging to APC or Memcache, the data captured in
  35. the summary will not be comprehensive reflecting every single page view for
  36. every URL.
  37. The reason for this is that there is no atomic locking when updating the data
  38. structures that store per-URL statistics in this module.
  39. This means that the values you get when using these storage caches are only
  40. samples, and would miss some page views, depending on how busy the site is.
  41. For memcache, there is way to implement locking using the $mc->increment and/or
  42. $mc->add as well. However, there is a risk if these are implemented, that there
  43. will be less concurrency and we can cause a site to slow down.
  44. Configuration:
  45. --------------
  46. To configure the Performance Logging and Monitoring module, navigate to
  47. /admin/config/development/performance-logging. By default, this module creates a
  48. key for each entry based off of the hostname of the site being accessed. If you
  49. have a site with multiple domains, it is recommended to specify a shared key
  50. between all sites in your settings.php file:
  51. $conf['performance_key'] = 'example_key';
  52. If you are using memcache, then you need to configure an extra bin for
  53. performance. If you have multiple web server boxes, then it is best to
  54. centralize this bin for all the boxes, so you get combined statistics.
  55. Your settings.php looks like this:
  56. $conf['cache_backends'][] = './sites/all/modules/memcache/memcache.inc';
  57. $conf['cache_default_class'] = 'MemCacheDrupal';
  58. // Prevent special cache_form bin from being assigned to a volatile cache
  59. // storage implementation
  60. $conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
  61. $conf['memcache_servers'] = array(
  62. '127.0.0.1:11211' => 'default',
  63. // More bins here ....
  64. '127.0.0.1:11311' => 'performance',
  65. );
  66. $conf['memcache_bins'] = array(
  67. 'cache_performance' => 'performance',
  68. );
  69. Note that since version 2.x, you can use any Drupal caching module available
  70. that transparently integrates with the drupal cache layer (like the apc or
  71. filecache modules).
  72. Statistics:
  73. -----------
  74. You can view the recorded performance statistics (summary and details) at
  75. /admin/reports/performance-logging
  76. Drush support
  77. -------------
  78. Drush support has been integrated as well. You can check the summary and detail
  79. logs using the performance-summary (aliased as perf-sm) and performance-detail
  80. (aliased as perf-dt) commands. Some examples:
  81. Retrieve last 15 entries from the detail log:
  82. drush performance-detail 15
  83. Retrieve last 20 summary log entries sorted by the number of queries,
  84. descending:
  85. drush performance-summary 20 query_count
  86. Retrieve last 35 entries from the detail log sorted by size, ascending:
  87. drush performance-detail 35 bytes asc
  88. Use drush perf-sm --help or drush perf-dt --help to see a full explanation.
  89. Bugs/Features/Patches:
  90. ----------------------
  91. If you want to report bugs, feature requests, or submit a patch, please do so at
  92. the project page on the Drupal web site at http://drupal.org/project/performance
  93. Author
  94. ------
  95. Khalid Baheyeldin (http://baheyeldin.com/khalid and http://2bits.com)
  96. If you use this module, find it useful, and want to send the author a thank you
  97. note, then use the Feedback/Contact page at the URL above.
  98. The author can also be contacted for paid customizations of this and other
  99. modules.