PHP with open_basedir performance problem

Miroslav Lachman 000.fbsd at quip.cz
Sat Jan 26 03:12:53 PST 2008


Hi all,

I found a painful performance problem with Apache + PHP 5 when
open_basedir directive is enabled.
Application performance drops by more than 50% with open_basedir enabled.
There is also significant disproportion between usr / sys CPU load. (sys
is much higher than usr)
I do not know if this is problem on FreeBSD side or in PHP code itself.
This problem exists on FreeBSD 6 and 7 (maybe older versions too - I did
not check).
I tested both shedulers on FreeBSD 7, no big difference (application
performance is little better with 4BSD).
Is there anyone with enough knowledge and time to look at it?

This problem affects Mac OS X as well, but does not seem to appear on Linux.
http://lists.apple.com/archives/macos-x-server/2006/Nov/msg00623.html


Application workload - tested by http_load (on dual Xeon 3GHz!)
with open_basedir: 11.5403 fetches/sec
without open_basedir: 4.53845 fetches/sec


Synthetic test:
## with open_basedir
CPU states: 17.5% user,  0.0% nice, 82.3% system,  0.2% interrupt,  0.0%
idle

# http_load -parallel 10 -fetches 1000 load.urls
1000 fetches, 10 max parallel, 2000 bytes, in 29.3449 seconds
2 mean bytes/connection
34.0775 fetches/sec, 68.155 bytes/sec
msecs/connect: 0.302057 mean, 0.441 max, 0.156 min
msecs/first-response: 292.693 mean, 525.471 max, 159.389 min
HTTP response codes:
  code 200 -- 1000

## without open_basedir
CPU states: 54.0% user,  0.0% nice, 45.2% system,  0.8% interrupt,  0.0%
idle

http_load -parallel 10 -fetches 1000 load.urls
1000 fetches, 10 max parallel, 2000 bytes, in 4.47231 seconds
2 mean bytes/connection
223.598 fetches/sec, 447.196 bytes/sec
msecs/connect: 0.297157 mean, 0.442 max, 0.153 min
msecs/first-response: 44.3433 mean, 157.334 max, 8.044 min
HTTP response codes:
  code 200 -- 1000



Simple testcase:

---- content of index.php ----
<?php
$num = 100;
for ($i = 0; $i < $num; $i++) {
    require_once('whatever.php');
}
?>


---- content of whatever.php ----
<?php
// whatever, does not matter
?>

http_load is instructed to do 1000 fetches of index.php in 10 parallel
connections.


Miroslav Lachman



More information about the freebsd-performance mailing list