• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question max_execution_time not working

Azurel

Silver Pleskian
PHP 7.4.20 as FPM application served by Apache.

I have set in php script
Code:
ini_set('max_execution_time', 600);
in /opt/plesk/php/7.4/etc/php-fpm.d/mydomain.conf
php_value[max_execution_time] = 9999

I want convert some images with imagick, and after 300 seconds the browser report
500 - Internal Server Error.
Please reload the page in a few seconds.
I look in /var/log/plesk-php74-fpm/error.log and there is this line
PHP message: PHP Fatal error: Maximum execution time of 600 seconds exceeded in /script.php on line XXX"
Line XXX is Imagick::writeImage()
But its abort every time in 300 seconds not 600 seconds! That is strange.

Is here something that force abort a script after 300 seconds?

"request_terminate_timeout" is default 0 and I don't find anywhere that plesk has set a value here. Or I just do not find it :)

EDIT:
I have set 500s and its aborted with 250s. I set 400s and aborted with 200s. I set 30 seconds and its aborted after 15 seconds. What the *uck?
 
Last edited:
As far as I know, this max_execution_time value is computation time and if your task runs multithreaded on say two CPU cores, you can get the behavior you are seeing.
The same thing can happen the other way around, when PHP scripts run way longer than this max_execution_time. This is because "waiting" does not count against that limit, and stuff like fopen() to fetch content from Websites can take forever (if that webserver is offline) and thus the PHP script also runs forever.
 
Thanks for your feedback. I have analyzed the problem and noticed a very strange behavior. On my localhost (desktop) with 1:1 source code this problem not exists, only on my centos 8.3 server.

All what it need is this line and max_execution_time is halved.
while(1) { Image::factory('image.PNG'); }

But... when I do this with JPG its running full time.
while(1) { Image::factory('image.JPG'); }

This is 100% reproducible.
Image::factory use imagick to load the file.

multithreaded could be a reasonable explanation. But I don't know where this should start and why only with PNG.
 
Well, imagick does know multithreading (since v3.2) and you can change those limits. (PHP: Imagick::setResourceLimit - Manual)

It's reasonable to assume that somehow the jpg conversion does only work singlethreaded while png does use more/many threads. (maybe more than two, but your server does only have two configured?)

Differences in behavior between your server and desktop can stem from the version of PHP/Imagick, the compiler used to compile PHP/Imagick or the use of the OpenMP flag/feature for the compilation of PHP/Imagick
You may wanna check the output of phpinfo() on both systems and look for "OpenMP"
 
"OpenMP" does not exist in my phpinfo, but imagick will probably be the cause. Thanks!
 
Back
Top