locked
PHP execution timeout RRS feed

  • Question

  • User1596942281 posted

    I was using isapi php previously without any problem. Now, I have a "Maximum execution time of 30 seconds" error message with gallery2 under mysql.

    I check all this parameters:

    php.ini (5.2.4nts) --> max_execution_time = 350  ; max_input_time = 340

    fcgiext.ini -->  ActivityTimeout=300 ; IdleTimeout=400

    Metadata of IIS 6 under Win2003 --> cgitimeout = 300

     But my php-cgi.exe process stop working just after 30 seconds. So where can I find the problem ?
     

    Friday, October 26, 2007 7:14 PM

Answers

  • User-679828332 posted

    Hi jadorwin,

    If the quoted string is the exact response you're seeing it doesn't come from FastCGI, so the fcgiext.ini settings are probably not the source of you troubles.

    What does a simple script that calls "ini_get('max_execution_time');" say?

    Cheerz,

    Rick.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Saturday, October 27, 2007 1:56 AM
  • User2093557029 posted

    Hi Jadorwin,

    The first issue I see is if you have set max_execution_time in php.ini as 350 seconds and scripts are timing out at 30 seconds, then what I'd say is happening is that PHP is not loading your php.ini file at startup. Be sure to set the PHPRC environment variable to the directory that contains you php.ini file, as that is one of the first places PHP will look when loading the environment. If it can't find your php.ini file it will simply load the default values which is what I suspect has happened in your case. If you put the following code in a file called phpinfo.php and place it in the root of your Gallery directory and then access it from your browser it should become evident pretty quickly;

    <?php

    phpinfo();

    ?>

    Have a look for "Loaded Configuration File" and see what it says there, then have a look for "PHPRC" which is the value you need to set.

    Second problem I see is that 30 seconds should still be enough for Gallery2 to perform most tasks. What are you doing exactly when these timeout issues come about? Unless you're uploading a large image or something I can't think off the top of my head what else Gallery2 needs to do in a single execution that would take that long (unless your using a heavily loaded/low spec server). You may also find this article I wrote on performance tuning PHP 5.2 on IIS of interest where I actually used Gallery2 as one of the test apps. I found that it is considerably faster to run the thread safe binaries of PHP 5.2.4 with FastCGI and eAccelerator than it is to just run the NTS binaries in FastCGI. I'm about to update the article to also include ISAPI with eAccelerator which I suspect will around the same speed. 

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Saturday, October 27, 2007 6:47 AM
  • User1596942281 posted

     Well, after a lot of test, I pinpoint the slowdown problem: The directive "open_basedir" in php.ini have a hight performance impact. I need to disable it when installing PHP (as I need in fact to install PEAR packages) and in this case, php-cgi is really fast. When I re-enable the restriction, php-cgi is less responsive.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Sunday, October 28, 2007 9:41 AM

All replies

  • User-679828332 posted

    Hi jadorwin,

    If the quoted string is the exact response you're seeing it doesn't come from FastCGI, so the fcgiext.ini settings are probably not the source of you troubles.

    What does a simple script that calls "ini_get('max_execution_time');" say?

    Cheerz,

    Rick.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Saturday, October 27, 2007 1:56 AM
  • User2093557029 posted

    Hi Jadorwin,

    The first issue I see is if you have set max_execution_time in php.ini as 350 seconds and scripts are timing out at 30 seconds, then what I'd say is happening is that PHP is not loading your php.ini file at startup. Be sure to set the PHPRC environment variable to the directory that contains you php.ini file, as that is one of the first places PHP will look when loading the environment. If it can't find your php.ini file it will simply load the default values which is what I suspect has happened in your case. If you put the following code in a file called phpinfo.php and place it in the root of your Gallery directory and then access it from your browser it should become evident pretty quickly;

    <?php

    phpinfo();

    ?>

    Have a look for "Loaded Configuration File" and see what it says there, then have a look for "PHPRC" which is the value you need to set.

    Second problem I see is that 30 seconds should still be enough for Gallery2 to perform most tasks. What are you doing exactly when these timeout issues come about? Unless you're uploading a large image or something I can't think off the top of my head what else Gallery2 needs to do in a single execution that would take that long (unless your using a heavily loaded/low spec server). You may also find this article I wrote on performance tuning PHP 5.2 on IIS of interest where I actually used Gallery2 as one of the test apps. I found that it is considerably faster to run the thread safe binaries of PHP 5.2.4 with FastCGI and eAccelerator than it is to just run the NTS binaries in FastCGI. I'm about to update the article to also include ISAPI with eAccelerator which I suspect will around the same speed. 

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Saturday, October 27, 2007 6:47 AM
  • User1596942281 posted

    Hi,

     Thanks for all these answers :)

    <?php echo ini_get('max_execution_time'); ?> gives 350 as expected and PHPRC is correct (phpinfo() gives the php.ini file).

    I try to access the plugins page of gallery2 in the administration page. In fact, I will try to optimize my php installation and I am quite concerned in your articles but I don't understand why the php-cgi.exe process stop working after 30 seconds. I can see the time execution of this process and just after 30 seconds, php-cgi.exe disapear. I am just asking myself why !

    The error appears in the error log of php therefore it clearly stops itself despite the max_execution_time. Is this a php-cgi problem in fact ?
     

    Saturday, October 27, 2007 9:28 AM
  • User2093557029 posted

    That is a weird one you have there. Do you have display_errors turned on? Also, do you have output_buffer set, as Gallery2 can have problems with this turned on. Another thing you could try is to install filemon.exe and use it to trace php-cgi.exe activity. It might show that there are some external issues causing PHP to terminate early, but the fact that it occurs at precisely 30 seconds seems too neat for this I feel. One last suggestion would be to try the thread safe binaries and see if that makes any difference. I have read some blog posts around the net referring to the NTS binaries causing issues, but I've not seen any myself as yet.

    Saturday, October 27, 2007 9:54 AM
  • User1596942281 posted

     Ok, I just switch php from nts to ts and php is amazingly faster now (and I can see the plugins page of gallery2).

    Why can I read: "Be sure to download a non-thread-safe build flavor for use with FastCGI, as this will give you a significant boost over thread-safe builds needed for the PHP ISAPI." here http://mvolo.com/blogs/serverside/archive/2007/10/09/IIS-FastCGI-and-PHP_3A00_-What-you-absolutely-need-to-know-to-host-PHP-applications-on-IIS-6-and-IIS-7.aspx

     or "it is recommended that you download and install non-thread-safe PHP build available for Windows." here http://www.iis.net/articles/view.aspx/IIS7/Hosting-Web-Applications/PHP/Using-FastCGI-to-Host-PHP-Applications-on-IIS-6-0-?Page=2

     It seems that nts is really slower !

    I will try to test the 30 seconds time out now by uploading a really big file to the server.
     

    Saturday, October 27, 2007 10:05 AM
  • User2093557029 posted

    I can only speculate jadorwin, but I would say those recommendations were given purely on the basis of the performance increase of the NTS builds. You can see in the testing I did in the article I linked to above that the NTS builds always out perform (if only slightly in my tests) the thread safe builds. This says nothing about the reliability of the NTS build though. On paper they should be more reliable, but they are still very young to the Windows world.

    Saturday, October 27, 2007 10:42 AM
  • User1596942281 posted

     Well, after a lot of test, I pinpoint the slowdown problem: The directive "open_basedir" in php.ini have a hight performance impact. I need to disable it when installing PHP (as I need in fact to install PEAR packages) and in this case, php-cgi is really fast. When I re-enable the restriction, php-cgi is less responsive.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Sunday, October 28, 2007 9:41 AM
  • User2093557029 posted

    Glad you got it sorte jadorwin! I've never had any issues like that when using the open_basedir directive and set it on most of my Internet facing systems to aid security. Mind you I've never tried testing processing speed before and after enabling it, and I guess there must be some overhead involved.   

    Sunday, October 28, 2007 10:02 AM
  • User-1444643443 posted

     How do you run thread safe binaries with fastcgi? I download thread safe but there's no php-cgi.exe only isapi? Confused.

    Thursday, January 8, 2009 6:46 AM
  • User-1444643443 posted

    Or are there any links or quick tips on loading EA with thread safe PHP on fastcgi?

    Thanks

    Thursday, January 8, 2009 3:44 PM
  • User823117371 posted

    @ hyndn: you can watch the video tutorial here : http://learn.iis.net/page.aspx/375/setting-up-fastcgi-for-php/

    In my case, using Magento and Magento connect update utility, I'm still having trouble of timeout, even with both modification within the loaded php.ini :

    max_execution_time = 120     ; Maximum execution time of each script, in seconds
    max_input_time = 120 ; Maximum amount of time each script may spend parsing request data

    (IIS restarted, values verified with phpinfo()). Within IIS7, CGI Timeout seems to be 15 minutes. I didn't find any "fcgiext.ini" file on my computer. Where should it be ? Is it IIS related or solution related ?
    Any help welcome !

    Monday, February 9, 2009 6:21 AM