Bug #48403 [Com]: shell_exec() is much slower than running from shell

From: Date: Mon, 29 Jan 2018 16:41:51 +0000
Subject: Bug #48403 [Com]: shell_exec() is much slower than running from shell
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213742@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=48403&edit=1 ID: 48403 Comment by: spam2 at rhsoft dot net Reported by: gregor at hostgis dot com Summary: shell_exec() is much slower than running from shell Status: Not a bug Type: Bug Package: Performance problem Operating System: Linux PHP Version: 5.2.9 Block user comment: N Private report: N New Comment: https://stackoverflow.com/questions/14277910/php-exec-performance/48505455#48505455 is nonsense because the command on the left side is ececuted and than the output piped to "nice" which is way too late Previous Comments: ------------------------------------------------------------------------ [2018-01-29 16:21:26] fortwebsolutions at gmail dot com I believe i have solved this, it is not an out right problem with either PHP or apache, rather a process prioritization problem that cane be solved by adding `nice -n -20' before the command to be executed. for the full answer see https://stackoverflow.com/questions/14277910/php-exec-performance/48505455#48505455 ------------------------------------------------------------------------ [2018-01-20 14:35:38] oliver at openbrackets dot net @ spam2 at rhsoft dot net Ok, calm down. The final comment was intended as a "joke", thought that might have been obvious? I know that php's most popular deployment SAPI is still apache, probably. Your usage is 100% opposite from ours. We have multiple own-iron app-servers running the same app for a single domain/app with load balancer in front. So we switched from apache 15yrs ago and never looked back. Hence the joke. The whole php process per webserver process/worker is completely unsuitable for our type of usage, so php-fpm was the obvious choice. Peace and love...enjoy. ------------------------------------------------------------------------ [2018-01-20 13:08:59] spam2 at rhsoft dot net > Moral of story: Who runs php on apache anyway? Use nginx/lighttpd + php-fpm! laughable attitude! php-fpm brings a ton of other troubles (php-options per directory/htaccess and so on) and as long as a benchmark on a 6 years old 4-core desktop machine with current patchlevel (metldown/spectre) shows 10000 requests/second on our core-cms show me *one* valid reason for rebuild many hundret of vhost-configs with your perfered toy ------------------------------------------------------------------------ [2018-01-20 13:01:36] oliver at openbrackets dot net TL;DR this problem does not occur in php-fpm Just for the record, I did some testing with Imagick cmd line calls: (the Fill Area Flag "^" is not supported via Imagick extension) convert img.jpg -resize 200x200^ -gravity center -extent 200x200 thumb.jpg 100 operations on a 2MB jpeg image. Results below: bash loop: for i in {1..100}; do convert ... ; done : 4.4s php-cli : for ($i = 0; $i<100; $i++) { exec($cmd); } : 4.4s php-fpm : for ($i = 0; $i<100; $i++) { exec($cmd); } : 4.4s No difference whatsoever for this workload in the 3 environments. - No slow performance of "convert" - shell forking for each exec() call is insignificant for this test case php -v PHP 7.2.1 Moral of story: Who runs php on apache anyway? Use nginx/lighttpd + php-fpm! ------------------------------------------------------------------------ [2014-08-15 13:08:36] info at sistemasgsl dot com 15/08/2014 Same problem. It's a bug. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=48403 -- Edit this bug report at https://bugs.php.net/bug.php?id=48403&edit=1

« previous php.bugs (#213742) next »