1 fcgi cannot work well but 5 fcgi process does

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.


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
only variable to play with is the timeout.

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
restarting itself. Thus if your ab benchmark exceeds the maximum number
requests that your single php-fcgi is set to handle then the fcgi
will restart in the middle of the benchmark most likely giving you a

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
unsure about this” I usually run 16 to 24 php-fcgi’s and set the max
per fcgi to 50 or less. That way they restart frequently and won’t go
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
something like 50 - 250.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs