What's the downside of limiting the number of php-cgi.exe *32 processes with maxinstances?RSS

2 replies

Last post Oct 15, 2013 09:46 AM by pl2013

  • What's the downside of limiting the number of php-cgi.exe *32 processes with maxinstances?

    Oct 08, 2013 12:32 PM|pl2013|LINK

    <div class="post-text" itemprop="description">

    We have a busy website that hangs periodically when running a popular open source php program. When hanging (inaccessible 500 error) the cpu and ram look fine on the server, the only odd thing is the 200 or so php-cgi.exe *32 processes that are running, usually we have about 16.

    When I RESET IIS the problem goes away and the number of php processes becomes normal.

    The IIS maxInstances setting is 0 at the moment, which lets Windows dynamically adjust the value. Some forums have suggested setting it to 10 X #cpu (ie 40 for us) but don't seem to have much reasoning to back up the limiting value.

    Whats the downside of limiting the number of php processes, will users be restricted from viewing webpages when that limit is reached? I'ld like to stop my website from hanging or getting 500 error messages but not at the cost of making it inaccessible to some.

    Am i managing exisiting php processes incorrectly, should they be recycled or terminated more frequently if not doing anything? (when I load a single page 6 php processes can be spawned and linger for awhile even though they dont appear to be doing anything)

    UPDATE: reviewed Zabbix logs during the a recent outage, it shows number of threads and processes increasing every 10 minutes, then decreasing every 10 minutes, presumably due to activity timeout & request timeout being set to 600 seconds. Memory and cpu looked fine at this time. Should I reduce my Activity Timeout value, I think it kills processes that are hung?

    Environment:
    IIS 7.5
    php 5.3.16
    14gb Memory
    4 cpu
    Windows 2008 R2 64-bit
    Zend Extension Build API220090626, NTS, VC9
    PHP Extension Build API20090626, NTS, VC9
    Thread Safety disabled

    </div>

    php-cgi iis7.5 php phpcgi

  • Re: What's the downside of limiting the number of php-cgi.exe *32 processes with maxinstances?

    Oct 09, 2013 07:34 AM|Pengzhen Song - MSFT|LINK

    Hi,

    Ensure that FastCGI always recycles the php-cgi.exe processes before the native PHP recycling kicks in. The FastCGI process recycling behavior is controlled by the configuration property instanceMaxRequests.

    For more information, you can refer here about Using FastCGI to Host PHP Applications on IIS 7

    http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/using-fastcgi-to-host-php-applications-on-iis

    And please refer the document about Tuning Windows Server 2008 for PHP

    http://blogs.technet.com/b/winserverperformance/archive/2008/07/25/tuning-windows-server-2008-for-php.aspx

    Hope it can hlep you.

    iis7.5 php phpcgi

    We are trying to better understand customer views on social support experience. Click HERE to participate the survey.
    Thanks!
  • Re: What's the downside of limiting the number of php-cgi.exe *32 processes with maxinstances?

    Oct 15, 2013 09:46 AM|pl2013|LINK

    I've already set instance maxrequests and PHP_FCGI_MAX_REQUESTS to 10000 to ensure proper recycing behavior.
    The article above does not indicate maxinstances of 0 as the default, is that a difference between IIS 7 and IIS 7.5 (my environment), is it better to let windows 2008 manage it dynamically in IIS7.5 or should I change the default of 0 to something like 40 (seeing as our ram and cpu are typically fine)?

    Here's my other fast-cgi settings in case that helps:

    PHP_FCGI_MAX_REQUESTS 10000
    instance maxrequests 10000
    max instances 0
    activity timeout 600
    idle timeout 300
    queue length 1000
    rapid fails perminuyte 10
    request timeout 600

    Thanks

    iis7.5 php phpcgi