• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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