locked
A strange problem while hosting a PHP site using fastcgi RRS feed

  • Question

  • User-618543858 posted

    Hi, I have a site written by PHP and is hosted on IIS 6. After I used fast-cgi, the site can be accessed very fast usually. But there is also a strange problem ocurring very often: ALL the php-cgi.exe processes will not run, and their CPU usages are all ZERO. If someone access the site at that time, the web will not be opened.

     This phenomenon can last some while, and then suddenly all php-cgi.exe processes continue to run. The CPU usage also seems normal again.

    This problem has been confusing me for years. I have tried adjusted the parameter settings of fast-cgi, php and mysql, hundreds of times. The problem is still there. Fast-cgi, PHP and MySQL software are all updated.

     Is there someone also getting this strange problem?

    Wednesday, April 7, 2010 2:16 AM

Answers

  • User-1405480850 posted

    Hi,

    [25-Jan-2010 14:18:05] PHP Fatal error:  Maximum execution time of 90 seconds exceeded in D:\http\mysite\html\includes\class_core.php on line 408

    This means PHP max_execution_time (which is set to 90 seconds) has been exceeded. Somehow when 7-Zip is running, php is not getting enough CPU. I am not sure why? More about script timeouts can be found at http://blogs.iis.net/donraman/archive/2010/02/08/troubleshoot-my-php-script-is-timing-out.aspx. See if this helps.

    Thanks,

    Don.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Monday, April 12, 2010 1:47 PM

All replies

  • User-1405480850 posted

    Hi,

    Can I know how did you install FastCGI and if you have 'extension=php_wincache.php' present in php.ini file?

    Thanks,

    Don.

    Wednesday, April 7, 2010 2:31 AM
  • User-618543858 posted

    At the beginning, I downloaded and installed "fcgisetup32.msi" from the official site. After successful configuration, my web site ran on IIS 6 with fast-cgi 1.0 + PHP for a long time. Until several months ago, I found a new version of fast-cgi had been released. For I suffered the problem I mentioned for a long long time, I hoped to upgrade the fast-cgi software to solve this problem. So I downloaded and installed "fcgisetup_1.5_rtw_x86.msi" from the official site. After upgrading the fast-cgi to 1.5, I found the problem was still there.

    Here is my fast-cgi config file:

    [Types]
    PHP=C:\php-5.2.13nts\php-cgi.exe
    [C:\php-5.2.13nts\php-cgi.exe]
    Exepath=C:\php-5.2.13nts\php-cgi.exe
    QueueLength=2000
    IdleTimeout=120
    ActivityTimeout=60
    RequestTimeout=60
    MaxInstances=16
    InstanceMaxRequests=1000
    EnvironmentVars=PHP_FCGI_MAX_REQUESTS:1200
    RapidFailsPerMinute=480
    UnhealthyOnQueueFull=1
    FlushNamedPipe=1

    The only extension used in PHP is php_mysql.dll .

     

    Wednesday, April 7, 2010 2:50 AM
  • User-1405480850 posted

    Sorry this is some other problem. Are you getting a crash?

    Thanks,

    Don.

    Wednesday, April 7, 2010 2:58 AM
  • User-618543858 posted

    If many users are accessing my site when this problem occurs, they will get a request time out error. But meanwhile, the load of the server is very low, for all php-cgi.exe processes do not use CPU. It seems like they are waiting for something or maybe a deadlock.

    Is there any log output for the fast-cgi ?

    Wednesday, April 7, 2010 3:13 AM
  • User-1405480850 posted

    You can look at IIS log if there is anything written there. It also seems your value for RequestTimeout/ActivityTimeout/IdleTimeout is very less. try increasing that. More about script time out can be found at http://blogs.iis.net/donraman/archive/2010/02/08/troubleshoot-my-php-script-is-timing-out.aspx. It may also happen that when many users are present request is taking more time and since your request timeout is just set to 60 seconds, it's timing out.

    Thanks,

    Don.

    Wednesday, April 7, 2010 12:18 PM
  • User-618543858 posted

    Thank you for your help. I will analysis IIS log these days.

    Normally, the time for opening the web page of my site is less than a few seconds. I have a time counter on the web page, which shows the execution time for the page. Usually the execution time is about 0.05 second. So I think my time out setting of fast-cgi is reasonable and it won't cause the problem.

    Wednesday, April 7, 2010 10:06 PM
  • User50249615 posted

    Hi, did u find some solution for this problem ?

    I've been having this same problem, I have a 2008 R2 web server, and I have a website that have a heavy traffic, sometimes all of fastcgi processes seems to "hang" and that website stops to responding PHP requests.

    If I kill all of the fastcgi processes, all of the processes are re-created and then the website back to normal.

    If u have some information, please let me know.

    Thanks,

     

     

    Monday, April 12, 2010 10:22 AM
  • User-1617257213 posted
    Hi all,
    I also have the exact same problem. I've been hosting a vbulletin forum on Windows since fastcgi 1.0 was released in late 2007. The hangs didn't start happening until I upgraded to fastcgi 1.5RTW.

    Windows Server 2003 R2
    Quad-core Xeon
    4GB RAM
    Fastcgi 1.5RTW
    PHP 5.2.13nts

    fastcgi ini:
    [Types]
    php:1=PHP Default

    [PHP Default]
    ExePath=C:\Programs\PHP\php-cgi.exe
    MaxInstances=10
    InstanceMaxRequests=10000
    EnvironmentVars=PHPRC:D:\http\mysite\config,PHP_FCGI_MAX_REQUESTS:10000
    RequestTimeout=90
    ActivityTimeout=70


    http error log and php log:
    2010-01-25 19:17:54 ***.***.***.*** 2038 ***.***.***.*** 80 HTTP/1.1 GET /showthread.php?t=258296 - 1 Connection_Dropped MyAppPool
    2010-01-25 19:17:54 ***.***.***.*** 42729 ***.***.***.*** 80 HTTP/1.1 POST /search.php?do=process - 1 Connection_Dropped MyAppPool
    2010-01-25 19:17:54 ***.***.***.*** 60677 ***.***.***.*** 80 HTTP/1.1 GET / - 1 Connection_Dropped MyAppPool

    [25-Jan-2010 14:18:05] PHP Fatal error:  Maximum execution time of 90 seconds exceeded in D:\http\mysite\html\includes\class_core.php on line 408


    One thing I can do to set off the hangs 100% of the time is create a large zip archive (thousands of files, 1-2GB total) with 7-Zip. Over the course of the ten minutes or so while 7-Zip is running, the hangs will come every few minutes for maybe 30 seconds in duration. During that time, CPU and memory use of the php processes just freezes - no CPU use, no memory change. Not sure what would cause this as 7-Zip is only using one core - IIS/fastcgi/php have plenty of resources left.
    Monday, April 12, 2010 11:57 AM
  • User-1405480850 posted

    Hi,

    I've been having this same problem, I have a 2008 R2 web server, and I have a website that have a heavy traffic, sometimes all of fastcgi processes seems to "hang" and that website stops to responding PHP requests.

    And you also mentioned once you kill all the php-cgi.exe, things come back to normal. Are you using WINCACHE? Which version? You might have encountered a bug in WINCACHE. You can set wincache.debuglevel to 301 and use DbgView.exe to see what WINCACHE is printing. Ensure that under Capture menu, Capture Global WIN32 is checked.

    Alternatively try disabling WINCACHE and see if the problem still persists. Give us the details and we would love to fix it.

    Thanks,

    Don.

    Monday, April 12, 2010 1:42 PM
  • User-1405480850 posted

    Hi,

    [25-Jan-2010 14:18:05] PHP Fatal error:  Maximum execution time of 90 seconds exceeded in D:\http\mysite\html\includes\class_core.php on line 408

    This means PHP max_execution_time (which is set to 90 seconds) has been exceeded. Somehow when 7-Zip is running, php is not getting enough CPU. I am not sure why? More about script timeouts can be found at http://blogs.iis.net/donraman/archive/2010/02/08/troubleshoot-my-php-script-is-timing-out.aspx. See if this helps.

    Thanks,

    Don.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Monday, April 12, 2010 1:47 PM
  • User-1617257213 posted

    Somehow when 7-Zip is running, php is not getting enough CPU. I am not sure why?

    It's very strange. I can even run 7-Zip in low priority and the hangs still occur.

     

    Sorry if I wasn't clear about the logs I posted. Our script timeouts are tuned properly for our scripts. The only timeouts occur in conjunction with the hangs - probably as a result of them.

    Wednesday, April 14, 2010 12:04 PM
  • User-1405480850 posted

    Hi,

    Are you saying that page works fine unless you run 7-Zip? If that is the case timeout is because of php-cgi.exe not getting enough CPU cycle and hence running slow. You can try increasing the time-outs value and see if it works. This will ensure that probably 7-Zip is doing something which is denying CPU cycles to php-cgi.exe.

    If you are randomly getting hangs irrespective of 7-Zip, you will need to dig further. ADPLUS can help you doing that. Details at http://support.microsoft.com/kb/286350. If you can get us a crash dump, we can fix it provided the bug is in IIS FastCGI.

    Thanks,

    Don.

    Wednesday, April 14, 2010 12:17 PM
  • User50249615 posted

    ok Don, thanks for the reply.

    yes, I'm using wincache 1.01 version, well, I'm going to disable wincache to see if the same behavior will happen.

    Thanks for now,

    Wednesday, April 14, 2010 1:17 PM
  • User-1617257213 posted

    Are you saying that page works fine unless you run 7-Zip?

    Correct, the website can run weeks without a hitch but as soon as I create a large archive with 7-Zip, the hangs occur.

     

    If that is the case timeout is because of php-cgi.exe not getting enough CPU cycle and hence running slow.

    Not slow, all php-cgi.exe processes are frozen and site is inaccessible for 30-90 seconds like others have reported above. That's with 7-Zip forced to run at low priority and 75% CPU left.

     

    I'm thinking about uninstalling fastcgi 1.5 and returning to 1.0 and see if the problem goes away.

     

    Thanks for your help

    Wednesday, April 14, 2010 2:28 PM
  • User50249615 posted

    And you also mentioned once you kill all the php-cgi.exe, things come back to normal. Are you using WINCACHE? Which version? You might have encountered a bug in WINCACHE. You can set wincache.debuglevel to 301 and use DbgView.exe to see what WINCACHE is printing. Ensure that under Capture menu, Capture Global WIN32 is checked.
     

     

    Well, I did the test, and definitly is not a wincache problem, because I disabled it, and the same error persists.

    Do you know if I can "downgrade" the fastcgi installation back to 1.0 ? I'm in a 2008 R2 server, and I don't know what to do anymore.

    Thanks again,

     

    Wednesday, April 14, 2010 4:24 PM
  • User-1405480850 posted

    Hi,

    There is no FastCGI 1.5 for Windows 2008 R2. FastCGI 1.5 (http://www.iis.net/download/fastcgi) is only for IIS6.0.

    Thanks,

    Don.

    Wednesday, April 14, 2010 6:03 PM
  • User50249615 posted

    There is no FastCGI 1.5 for Windows 2008 R2. FastCGI 1.5 (http://www.iis.net/download/fastcgi) is only for IIS6.0.
     

     

    Ok, is there some place where I can see fastcgi's debug logs ?

    because there's no log in event viewer, and I don't know what to do to discovery the source of this problem.

    Thanks,

     

    Thursday, April 15, 2010 10:36 AM
  • User-1405480850 posted

    Hi,

    When a process hangs or crashes, you can create a dump using ADPLUS. Details at http://support.microsoft.com/kb/286350. Since you are using Windows 2008 R2, you can also take dump in an easy way when the process hangs as explained at http://support.microsoft.com/kb/931673.

    Once you have a dump, share it and let me know.

    Thanks,

    Don.

    Thursday, April 15, 2010 12:21 PM
  • User50249615 posted

    Once you have a dump, share it and let me know.
     

    ok, thanks.

    I sent you the links to download the dump files as a private message.

    thanks again,

    Friday, April 16, 2010 2:05 PM
  • User-1405480850 posted

    Hi,

    Thanks for the dump. We will analyze it and let you know.

    Regards,

    Don.

    Friday, April 16, 2010 3:26 PM
  • User-1405480850 posted

    Hi,

    While we are analyzing the dumps can you ensure that you have IIS URL Rewrite installed. Details at http://www.iis.net/download/URLRewrite. Let me know how it goes after URL Rewrite installation.

    Thanks,

    Don.

    Friday, April 16, 2010 6:34 PM
  • User-1653247517 posted

    Hi,

    Do you have URLRewrite installer on your server? If not, can you pls install URLRewrite from http://www.iis.net/download/urlrewrite and see if problem persists? You don't need to make any configuration changes. Just install urlrewrite and let us know if you still see the error.

    Thanks,
    Kanwal

    Friday, April 16, 2010 7:29 PM
  • User-1617257213 posted

    Hi,

    Is URLRewrite recommended for Win2003/IIS6 also?

    Thanks!

    Friday, April 16, 2010 10:39 PM
  • User50249615 posted

    yes, we have url rewrite installed in the server.

    I tested both versions (1.1 and 2.0) and the behavior is exacly the same.

    thanks,

    Friday, April 16, 2010 10:46 PM
  • User-1405480850 posted

    Is URLRewrite recommended for Win2003/IIS6 also?

    Microsoft URL Rewrite is only availablae on IIS7 platforms. So one cannot install it on Windows XP or 2003.

    Thanks,

    Don.

    Saturday, April 17, 2010 12:28 PM
  • User-618543858 posted

    Hi, I'll send you the dump data. Thank you very much for the help~

    Tuesday, April 20, 2010 1:01 AM
  • User1425016384 posted
    hi hello
    Tuesday, April 20, 2010 2:48 AM
  • User-1405480850 posted

    I sent you the links to download the dump files as a private message.

    My developer analyzed the dump files. It seems dump was taken after php already crashed. So the dumps were not of any help. We also observed that PHP SOAP extension was crashing. I am not sure why and this is beyond the scope of IIS. You can try disabling the extension and see how PHP behaves.

    Thanks,

    Don.

    Wednesday, April 21, 2010 12:06 AM
  • User-1405480850 posted

    I got your dump. I will get back to you with details. I have asked my developer to take a look at it.

    Thanks,

    Don.

    Wednesday, April 21, 2010 12:07 AM
  • User50249615 posted

     

    My developer analyzed the dump files. It seems dump was taken after php already crashed. So the dumps were not of any help. We also observed that PHP SOAP extension was crashing. I am not sure why and this is beyond the scope of IIS. You can try disabling the extension and see how PHP behaves.

    Yes, because the crash happen very sporadically, about once or twice per day, I don't know how I can send you more helpful information, please tell me if you have another way.

    But about the SOAP extension, I'm trying to disable, to see what happen.

    Thanks a lot,

     

    Wednesday, April 21, 2010 6:26 PM
  • User-1405480850 posted

    See if ADPLUS helps. Details at http://support.microsoft.com/kb/286350.

    Thanks,

    Don.

    Wednesday, April 21, 2010 7:41 PM
  • User-135760635 posted

    Was this ever resolved?

     

    I had the same problem with IIS6 on W2K3 - upgraded to a new MUCH more powerful machine with 2008r2 and all the latest PHP updates etc, but STILL the problem happens :(

    Wednesday, August 18, 2010 12:06 PM
  • User-1405480850 posted

    Hi,

    There were too many problems discussed here. Regarding abrupt crash, no we did analyze the dump but that was not useful. We didn't get any important data to make a fix.

    I would suggest to start a new thread with your problem. If there is a crash happening try creating a dump file and send it to us.

    Thanks,

    Don.

    Wednesday, August 18, 2010 12:58 PM
  • User-1672167363 posted

    Hello @ steve,

    Just so you know Don has left the IIS Team.

    His last reply "There were too many problems discussed here. "

    "Regarding abrupt crash, no we did analyze the dump but that was not useful. We didn't get any important data to make a fix."

    "I would suggest to start a new thread with your problem."  - quote from Don.

    I suggest that if you have problems open a new thread with problems and system information

    so Forum members can help.

    Thanks, 

    Martin

     

     

    Friday, June 17, 2011 6:08 PM