Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug nginx/php-fpm for site that hangs?

Tags:

php

nginx

drupal

I need some tips on how to debug a new server config that hangs. This site itself is a very big instance of Drupal. Big as in a 45+ MB of PHP memory per page load with APC functioning.

The site itself does run on another server with nginx/php-fpm/apc. The new server I'm setting up has a custom PHP 5.3 build.

nginx is configured to listen on port 80, and passes the fastcgi request to 127.0.0.1:9000. This works.

In the Drupal root directory, I have a plain PHP file with phpinfo(); in it. I can load this PHP file directly and confirm the PHP build looks good.

There is no nginx error, but the php-fpm error log will show this as the page hangs:

[22-Dec-2012 17:41:16] WARNING: [pool www] child 19760, script '/var/www/mysite/public_html/index.php' (request: "GET /index.php") executing too slow (5.068781 sec), logging

Besides this error, there's nothing.

So I'm looking for advice on ways to debug this considering a normal PHP script loads fine, but loading a Drupal app (directly to index.php, not even trying clean urls) hangs.

like image 557
Coder1 Avatar asked Dec 22 '12 17:12

Coder1


People also ask

How do I know if PHP-FPM is working?

First open the php-fpm configuration file and enable the status page as shown. Inside this file, find and uncomment the variable pm. status_path = /status as shown in the screenshot. Save the changes and exit the file.

How do I restart FPM?

Log into WHM as root. Search “PHP-FPM” and select PHP-FPM service for Apache. Select Yes to restart the PHP-FPM service.


1 Answers

When you see that error log entry in your php-fpm error log, it's actually providing a helpful stack trace of the slow php process.

In your php-fpm configuration file (e.g. /etc/php-fpm.d/www.conf), take a look at the request_slowlog_timeout and slowlog settings. The first defines how many seconds until a request is considered "slow", and the latter defines the file that stack traces will be written to.

If you look at the php-fpm slowlog file, you'll get a better idea of exactly where in the method call stack your processes are hanging up at.

like image 79
Tharsan Avatar answered Sep 22 '22 17:09

Tharsan