I use nginx/0.6.31+fastcgi to deploy ruby on rails. then I use ab to do 'ab -n1000 -c500' for the pressure test. when it only run with 1 fastcgi process. It works well with ab -n1000 -c1 to -c100 but in -c500,after about 800 request, the response suddenly returns very slowly even timeout. I use 'top' to see the process status, fcgi process isn't busy any more. then I try add 4 more process, then it works well. Can anyone could help me understand how it happens and how to setup nginx let it could finish -c500 test with only 1 fcgi process. Thanks Miao
on 2008-12-30 20:21
on 2009-01-05 08:14
It's simple math: if the time to generate your test page is bigger than timeout * number-of-fastcgi-processes/number-of-concurrent-requests you'll be getting timeouts. If you fix the number of processes and the concurrency the only variable to play with is the timeout.
on 2009-01-05 13:18
I believe you need at least 2 fcgi's running minimum. Because the fcgi process is usually set to handle only a limited number of requests before restarting itself. Thus if your ab benchmark exceeds the maximum number of requests that your single php-fcgi is set to handle then the fcgi process will restart in the middle of the benchmark most likely giving you a timeout. If you have 2 running I think it will hand off the requests to the next process. "though it may actually share the load between all the fcgi's I'm unsure about this" I usually run 16 to 24 php-fcgi's and set the max request per fcgi to 50 or less. That way they restart frequently and won't go wild with ram usage. I've actually seen vps setups with max requests per child @ 10 then runnning 25 or more php-fcgi processes. They kill themselvs off before consuming any real ammount of ram. I'm unsure how well this would work with a extremely busy site but the idea is interesting for sure. Try running at least 2 php-fcgi's and set your max request's per child to something like 50 - 250.