Posted by muschpusch on May 5, 2011 at 10:41am
Hey!
i just switched to mod_fcgid and the response time of sites is good until i benchmark them :)
Under multiple concurrent requests (ab -c 50 -n10000) i get notices like this:
[Thu May 05 12:16:37 2011] [notice] mod_fcgid: /var/spool/www/user/aegir/drupal-7/index.php total process count 15 >= 15, skip the spawn request
and the server performs really really bad.
My mod_fcgid config:
AddHandler fcgid-script .fcgi .php
# Where to look for the php.ini file?
DefaultInitEnv PHPRC "/etc/php5/cgi"
# Maximum requests a process handles before it is terminated
MaxRequestsPerProcess 1000
# Maximum number of PHP processes
MaxProcessCount 15
# Number of seconds of idle time before a process is terminated
IPCCommTimeout 240
IdleTimeout 240
#Or use this if you use the file above
FCGIWrapper /usr/bin/php-cgi .php
DefaultInitEnv PHP_FCGI_CHILDREN 0My mpm_worker settings:
<IfModule mpm_worker_module>
ServerLimit 2048
ThreadLimit 100
StartServers 10
MinSpareThreads 30
MaxSpareThreads 100
ThreadsPerChild 64
MaxClients 2048
MaxRequestsPerChild 5000
</IfModule>I run a small ubuntu lucid instance at amazon. Benchmark is against a drupal-7 install in combination with apc & memcache.
Categories: mod_fcgid
Comments
MaxRequestsPerProcess
You don't want MaxRequestsPerProcess 1000. Must be < PHP_FCGI_MAX_REQUESTS (500 by default) or there can be an internal error each 500 requests because PHP decides to die and mod_fcgid reports Internal error.
Under load, the most important thing to remember is to not allow memory swapping. Decrease MaxProcessCount until
ab -c 50doesn't cause swapping. Or you can start with 3 and increase.I've written detailed instructions on Apache + mod_fcgid + PHP-CGI on Debian 6 Squeeze but it's in Bulgarian: http://fire.tower.3.bg/node/5 . I have a long TODO list with more than 30 items to fix and add, including ngingx+PHP-FPM, but not ready yet. It will be translated into English some day.
From this article, you can use the
ps axf -o pid,nlwp,%cpu,%mem,rss,vsz,maj_flt,time,start,commto check major faults. It must not increase rapidly during load. These major faults roughly means count of swapped memory pages (= slow disk access).I adjusted
I adjusted MaxRequestsPerProcess and even with MaxProcessCount of 15 the machine isn't swapping on load but the load is raising to fast. My logifles still get flooded with this notices:
[Thu May 05 12:16:37 2011] [notice] mod_fcgid: /var/spool/www/user/aegir/drupal-7/index.php total process count 15 >= 15, skip the spawn request
Any idea how to solve this? Thanks for the link to your blog!
normal
These notices look normal.
ab -c 50wants more parallel execution that what is provided by this MaxProcessCount and requests need to wait. Can you run this test on mpm prefork and compare results?In the end I gave up and
In the end I gave up and switched to linode. There is a Pantheon Mercury StackScript that works out of the box but thanks a lot ogi!