NotionCommotion Posted December 11, 2021 Share Posted December 11, 2021 When making a request from the browser, I get a 503 Service Unavailable after exactly 60 seconds, however, the I see that PHP is still executing the script. I first tried the following without success. Curiosity question - What is the difference between these two lines? ini_set ('max_execution_time', (string) $container['maxTime']); set_time_limit($container['maxTime']); I then tried making the following changes to my default pool /etc/php-fpm.d/www.conf, but still defaults at 60 seconds. Note that the only reason I added default_socket_timeout is that it is the only item displayed with a value of 60 by phpinfo() and was just hoping. request_terminate_timeout = 120 ;max_execution_time=120 ;results in error php_value[max_input_time] = 120 php_value[max_execution_time] = 120 php_value[default_socket_timeout] = 120 Any ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/314296-maximum-execution-time-with-php-fpm-and-apache/ Share on other sites More sharing options...
kicken Posted December 11, 2021 Share Posted December 11, 2021 It's not PHP that is timing out, it's Apache. It's waiting for the PHP process to provide a response but it eventually gives up. You can set it's timeout duration using Timeout or ProxyTimeout. 1 Quote Link to comment https://forums.phpfreaks.com/topic/314296-maximum-execution-time-with-php-fpm-and-apache/#findComment-1592610 Share on other sites More sharing options...
NotionCommotion Posted December 11, 2021 Author Share Posted December 11, 2021 Thanks kicken, I removed all the settings I showed for the pool and just used Apache's Timeout and it worked perfect. May I ask what if any is the any difference between using ini_set ('max_execution_time', '120') and set_time_limit(120)? Also, I have found that some settings must be made by editing the pool while others are set by php.ini and/or php commands such as ini_set() and set_time_limit(). Is there any general categorization which dictates which must be defined where? Quote Link to comment https://forums.phpfreaks.com/topic/314296-maximum-execution-time-with-php-fpm-and-apache/#findComment-1592613 Share on other sites More sharing options...
kicken Posted December 11, 2021 Share Posted December 11, 2021 I don't think there is a difference between the two lines of code. For the configuration settings, the information is in the manual. Look at the Changable column to find out where a directive can be changed. Quote Link to comment https://forums.phpfreaks.com/topic/314296-maximum-execution-time-with-php-fpm-and-apache/#findComment-1592632 Share on other sites More sharing options...
NotionCommotion Posted December 12, 2021 Author Share Posted December 12, 2021 Thanks again kicken, I thought that php-fpm brought some unique differences but maybe not. Quote Link to comment https://forums.phpfreaks.com/topic/314296-maximum-execution-time-with-php-fpm-and-apache/#findComment-1592649 Share on other sites More sharing options...
gizmola Posted December 13, 2021 Share Posted December 13, 2021 On 12/12/2021 at 5:52 AM, NotionCommotion said: Thanks again kicken, I thought that php-fpm brought some unique differences but maybe not. The old school way of running php with apache was to use the mod_php apache module, which makes php a part of apache. So that was certainly different. You can think of php-fpm as a "php server" process. Using it with apache or nginx or any other http proxy means that php-fpm is running separately and being communicated with from the http server via fastcgi. Fastcgi is a specification that evolved from the original cgi spec, that was the earliest way a web server could be configured to send data to and from an external program. php-fpm is a php server that implements fastcgi, so it can be used with any http server or proxy that also supports fastcgi. One of the obvious things to notice is that the effective user running the php script can be different than the user that the apache process is running as. It also has some efficiency when compared to mod_php, for reasons I won't go into, but that I did examine in a blog post I made. One big problem with mod_php is that the apache child processes tend to grow and absorb memory when serving php, and this pool of child processes has to be used for every request, so even if apache is handling a request to return an image or css file, or other static content, the apache child process might be 500mb in terms of memory usage, because previously it had been used to run a php script. This is a big reason that nginx became popular, as it was always intended to be a high performance proxy, and always used fastcgi. With that said, when php-fpm runs a php process it still does so using the php configuration. It does have its own settings to manage fastcgi, so in that way it's got another group of settings that you have to configure, and areas where the communication between apache and php-fpm can have issues, so in that way it's more complicated. 1 Quote Link to comment https://forums.phpfreaks.com/topic/314296-maximum-execution-time-with-php-fpm-and-apache/#findComment-1592673 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.