|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55221 shell_exec works very slow with Apache
Submitted: 2011-07-17 12:56 UTC Modified: 2011-07-17 13:51 UTC
From: osmanungur at gmail dot com Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.3.6 OS: Mac OS X 10.6.8
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: osmanungur at gmail dot com
New email:
PHP Version: OS:


 [2011-07-17 12:56 UTC] osmanungur at gmail dot com
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. 


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:

$start = microtime(1);
$output = shell_exec($executor->getCommandString());
$end = microtime(1);
var_dump($end - $start, $output);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-17 13:51 UTC]
-Status: Open +Status: Bogus
 [2011-07-17 13:51 UTC]
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.
 [2018-01-29 16:24 UTC] fortwebsolutions at gmail dot com
see last answer of
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 01:01:31 2024 UTC