On 6/21/2012 6:01 AM, Laurent Bercot wrote:
I have an application that runs well using lighttpd with PHP. In an effort
to reduce the memory footprint I tried porting it to the busybox ( 1.20.1 )
httpd. It was easy to get this working and it seems to work properly. What
isn't good enough is performance when executing PHP scripts. It looks like
the httpd is using fork/exec for each cgi, and that fork/exec can use a lot
of CPU.
  httpd itself, and on a fast machine with a decent OS, fork/exec themselves,
don't use *that* much CPU. I suspect that your bottleneck might be the
startup time of the PHP interpreter, since busybox httpd is indeed spawning
a new PHP intepreter per request.

$ time perl -e '$i=1000; system("sh","-c","") while $i--;'

real    0m1.213s
user    0m0.004s
sys     0m0.120s

$ time perl -e '$i=1000; system("perl","-e","") while $i--;'

real    0m1.845s
user    0m0.012s
sys     0m0.112s

$ time perl -e '$i=1000; system("ruby","-e","") while $i--;'

real    0m35.341s
user    0m28.954s
sys     0m3.176s

$ time perl -e '$i=1000; system("php","empty.php") while $i--;'

real    2m25.559s
user    2m18.189s
sys     0m6.000s


This is probably because PHP doesn't use modules, and links to *everything* it has compiled support for. PHP is linked against 41 libraries on my system. The startup cost is probably just the dynamic linking and initialization of libraries. (To be fair, other scripting languages would take longer to load than PHP if you loaded all those modules.)

George: you might want to try recompiling php with the minimum features needed for your application, and maybe linking with uClibc . It will help in the CGI case, but also help your memory usage if you use lighttpd and a pool of php processes.

-Mike
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to