Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using Nginx + PHP5-FPM and all PHP files loaded over port 80 are extremely slow - they take several minutes to load, even a simple phpinfo file.

php -i over shell is lightning quick, and the server itself is pretty powerful and has a very low load.

I've also tried Apache and Litespeed with the same results as Nginx. Flat HTML fiLes are also very quick.

This has been happening since a power outage and a hard reboot.

Has anyone got any ideas why this server could be so slow at processing PHP files?

share|improve this question
    
Are you using any special settings for sessions or file prepend? –  Kyle May 15 '12 at 2:21
    
Nothing at all. –  user1265313 May 15 '12 at 2:23

2 Answers 2

up vote 1 down vote accepted

This one isn't easy to diagnose, but the best way to do it if you have made NO changes to the stock php.ini file is to run strace against one of the child php fpm processes.

First reduce the max/min/start number of FPM children down to 1 and restart FPM.

Grab the PID of the FPM Child process and run strace -p PID as root.

Then hit the slow PHP page with your browser and watch the strace output to see where you process is hanging. It'll give you all the system calls made by PHP and you can see if its doing something stupid.

share|improve this answer
    
This is basically what I've been trying to do. It seems to hang after the last line here every time, but I'm not sure how to make sense of this: socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 9 fcntl(9, F_GETFL) = 0x2 (flags O_RDWR) fcntl(9, F_SETFL, O_RDWR|O_NONBLOCK) = 0 connect(9, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("66.199.138.142")}, 16) = -1 EINPROGRESS (Operation now in progress) poll([{fd=9, events=POLLIN|POLLOUT|POLLERR|POLLHUP}], 1, 60000 <unfinished ...> –  user1265313 May 15 '12 at 2:36
    
It is opening a socket, assigning 9 as the file handle, then connecting it to port 80 on 66.199.138.142. It then waits until that connection times out and returns. –  Kyle May 15 '12 at 2:38
    
Thanks. That's actually consistent with a lot of SYN_SENT requests shown on lsof -i :80, so I'm guessing that it's waiting for something from the server at 66.199.138.142? Any ideas how I can check for what, or why it may be impacting on simple phpinfo files? The IP and IP Whois don't really ring any bells –  user1265313 May 15 '12 at 2:41
    
Is there any indication where in the execution that happens? Is it right after reading the PHP file? –  Kyle May 15 '12 at 2:45
    
How can I check? –  user1265313 May 15 '12 at 2:49

This is a long shot, but you might want to install webgrind and have a look at where the execution hangs, it might at least give you an hint as to the source of the problem, given that it's not immediately apparent.

webgrind screenshot

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.