nginx and php (fast-cgi) hangs the connection

Reinis Rozitis r at roze.lv
Thu Oct 15 23:04:59 MSD 2009


In my past experience usually its just because all the spawned php processes 
are doing something (or are just some hanged state (you could use 'strace' 
to see what the php childs are doing at the moment nginx stops to deliver 
the php content)) and there is no free child to assign the incoming dynamic 
request from nginx.

And while you may think that from php side the ini setting 
'max_execution_time' would help it is not always the case (especially if you 
are dealign with sockets or other (tcp) connections within the php code) - 
sooner or later all the childs are being used and no new spawned.


The thing to do would be instead of spawn-cgi use php-fpm http://php-fpm.org

While it involves patching php (then again it is planned to implement as 
core in future php releases (there is even a seperate branch in php.net 
svn)) it gives you the possibility http://php-fpm.org/Configuration_File to 
monitor ( request_slowlog_timeout ) and kill ( request_terminate_timeout  ) 
the php processes which take too long to finish.

Has helped me a lot to find site bottlenecks and point those out to 
development team.

rr



----- Original Message ----- 
From: "yacenty" <nginx-forum at nginx.us>
To: <nginx at sysoev.ru>
Sent: Thursday, October 15, 2009 8:45 PM
Subject: nginx and php (fast-cgi) hangs the connection


> Hello
> from about month (moving to the nginx 7.61) I had a very big problem.
> My server suddenly stops to serving dynamic content.
> Static files are handled in regullar way but asking for php files gives 
> nothing in the web browser, and sometimes in the benchmarking site in ab 
> we receive broken sockets.
> Some days ago I had moved to 7.62 and spawn-cgi 1.6.3 - then I thought 
> everything is solved, but I realized that site hangs in the peak of the 
> site.
> There is nothing in the nginx logs, nothing in php logs.
> What could I do?
> What could be wrong?
> Could You help me somehow?
>
> Best regards
> YacentY
>
> Posted at Nginx Forum: 
> http://forum.nginx.org/read.php?2,14052,14052#msg-14052
>
>
>
> 






More information about the nginx mailing list