Bug #55221 [Opn->Bgs]: shell_exec works very slow with Apache
| From: | rasmus@php.net | Date: | Sun, 17 Jul 2011 17:51:32 +0000 |
| Subject: | Bug #55221 [Opn->Bgs]: shell_exec works very slow with Apache | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161939@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55221&edit=1
ID: 55221
Updated by: rasmus@php.net
Reported by: osmanungur at gmail dot com
Summary: shell_exec works very slow with Apache
-Status: Open
+Status: Bogus
Type: Bug
Package: Performance problem
Operating System: Mac OS X 10.6.8
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
There really isn't anything we can do about that. When you run something from the
command line your shell is already running and ready to go. When you do it from
within PHP via any of those calls you need to fork and then exec the shell
executable first and then run the command. That is a huge amount of overhead,
especially if you are low on ram. To avoid the fork+exec overhead you should use
some sort of pre-forking mechanism and simply pass messages to the already
running job worker. You can roll your own, but I would suggest looking at
something like Gearman instead.
Previous Comments:
------------------------------------------------------------------------
[2011-07-17 12:56:31] osmanungur at gmail dot com
Description:
------------
Running commands with shell_exec in browser is working very slower than CLI. I'm
having same problem with system() and proc_open().
Running from shell takes 0.11 sec, but running from browser takes 16.96 second.
I tested out same code in Linux Ubuntu, same problem happens.
CLI
------------
float(0.11125087738037)
string(211) "graph_left = 67
graph_top = 33
graph_width = 800
graph_height = 200
image_width = 882
image_height = 273
graph_start = 1310835249
graph_end = 1310921349
value_min = 0.0000000000e+00
value_max = 1.1000000000e+00
"
Browser / Apache
------------
float 16.960417032242
string 'graph_left = 67
graph_top = 33
graph_width = 800
graph_height = 200
image_width = 882
image_height = 273
graph_start = 1310834364
graph_end = 1310920464
value_min = 0.0000000000e+00
value_max = 1.1000000000e+00
' (length=211)
Test script:
---------------
<?php
$start = microtime(1);
$output = shell_exec($executor->getCommandString());
$end = microtime(1);
var_dump($end - $start, $output);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55221&edit=1