nginx + php = timeout

Jonathan Vanasco jvanasco at 2xlp.com
Fri Mar 9 17:55:43 MSK 2007


On Mar 9, 2007, at 9:05 AM, Anonymous Coward wrote:

> hello,
>
> i just moved yesterday a relatively big Wordpress blog from an old  
> box with apache2 to a new one with nginx
> Everything seemed to work ok until ~30 minutes ago when clients  
> started to complain site is working slow and after few checks i  
> noticed that i was gettting "504 Gateway Time-out" and slow loads  
> on php pages but i had no problem with html pages and i have no  
> clue why this is happening
> im using lighty's spawn-fcgi to spawn php with the following config  
> lines
>
> PHP_FCGI_CHILDREN=5
> PHP_FCGI_MAX_REQUESTS=1000
>
> i don't know how usefull this is but lsof showed me that i had  
> ~1100 established nginx connections (4 workers with 1024  
> connections per worker so this is not an issue) and ~1000  
> connections to the php-cgi port (don't know if this should be a  
> problem as i have 5 childrens with 1000 max requests each but maybe  
> i didn't understand how this exactly works)
>
> thanks in advance


You need more FCGI  children

the MAX_REQUESTSon FCGI are how many requests a child serves before  
it restarts.  think of it like a memory / variable cleansing ritual -  
it deals with clearing out memory leaks and allocated unused memory  
in a persistant state.

your problem is that nginx is queing 1100 fcgi requests across 4  
nginx workers , and into 5 php processes

check to see how much memory you have running per php child - see if  
you can at least double-triple your number of children.

if you're not already -- running a cache like eaccelerator / APC will  
help with getting things a bit faster.

as a ballpark figure -- you'll want at least the same number of FCGI  
processes as you had 'max servers' in apache2

// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
| SyndiClick.com
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|      FindMeOn.com - The cure for Multiple Web Personality Disorder
|      Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|      RoadSound.com - Tools For Bands, Stuff For Fans
|      Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -







More information about the nginx mailing list