PHP-FPM: finding thin places (what does slow down your site?)

Lulu's picture

Apache is usual and convenient for most of website owners, but as far i'm not aware if you can find slowly executing scripts with mod_php, with php-fpm you can, sometimes it may even surprize you with discovering some things in scripts you wasnt aware. So how to find what makes your site slow?

Its very simple, just open your php-fpm.conf and set 2 directives for your pool :


request_slowlog_timeout = 90s ; log slow operations for WP
slowlog = /var/logs/slow.log ; log here

this will trace and log anything that takes more than 90 seconds.

the trace will look like this:

[06-Jul-2011 09:02:38] [pool POOLNAME] pid 23929
script_filename = index.php
ql_query() wp-db.php:1074
query() wp-db.php:1357
get_results() query.php:2623
get_posts() query.php:2904
query() class-wp.php:454
query_posts() class-wp.php:501
main() functions.php:1567
wp() wp-blog-header.php:14

(this one is not a good example, its happened occasionally, but i dont have anything else in slowlog to show)

so if some script is repeteadly or occasionally slow and you see it in logs - its better to check why it is so, fix that script, or even remove it, when setting request_slowlog_timeout to short values, you can profile and find slowly executing scripts and ( an good example ) wordpress plugins. So i've found that "Meet Your commenters" plugin makes WordPress dashboard load slower a lot, there are other tools for finding what makes your site slow, but php-fpm slowlog is simple and efficient one.
Hoping this tip will be useful. Enjoy.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img><i><b><h1><h2><h3>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions. There is no CAPTCHA shown for registered and logged in users.
Image CAPTCHA
Enter the characters shown in the image.