PHP with open_basedir performance problem

Arkadi Shishlov arkadi at mebius.lv
Sat Mar 1 22:15:15 UTC 2008


Stanislav Sedov wrote:
> On Thu, Feb 14, 2008 at 07:22:46PM +0200 Arkadi Shishlov mentioned:
>> Stanislav Sedov wrote:
>>> Most basedir problems are linked with the fact it produce a lot of lstast/
>>> readlinks on every require, include or open command. On Linux it pereforms
>>> even worse, as they implemented readlink there by hand, and, of course,
>>> their implementation isn't particulry good.
>> But there is no high sys cpu usage on Linux in contrary to FreeBSD, as 
>> reported by original author of the thread..?
>> Do you have numbers or benchmark ready? I see the number of syscalls 
>> required is astonishing (on Linux) but doesn't cause any problem at first 
>> look.
> 
> I don't have specific benchmark numbers, and it's true, that top on Linux
> don't show such sys time usage, as on FreeBSD boxes. However, the overall
> performance of boxes on FreeBSD is 30-40% higher, that Linux ones. This numbers
> is empirical, but I'm pretty sure in them: in past I migrated Linux hosting
> to FreeBSD-based, and after that, I was able to add a bunch of new users to
> that boxes without performance impact. In fact, the load average on these
> boxes are MUCH lower, that was on Linux. Also, I notices, that stat() costs
> much more on Linux, that FreeBSD. I don't certainly know, why Linux shows low
> sys time usage, probably it's just bugs in accounting.

I can confirm the FreeBSD was significantly faster than Linux in the 
open_basedir test I just conducted. With open_basedir check enabled, FreeBSD 
throughput dropped 2x, Linux 3x, and FreeBSD is 2x faster than Linux in this 
situation.

The test system is Pentium4 3.8GHz HT, 2MB cache, 2.5GB RAM.
FreeBSD 7.0-RELEASE i386.
Linux kernel 2.6.24.2 i386.
Both kernels are SMP.
Software is lighttpd 1.4.18, PHP 5.2.5 in FastCGI mode, without op-code cache.

The index.php that was tested by ApacheBench is a do-nothing script, that just 
includes other scripts (in sub-dir.), that in turn include other scripts, 
bringing total count of includes to 25 - like in a typical PHP application. 
Website document root depth is 4 (/usr/local/www/data).

I've varied test parameters and filesystem setup (tmpfs, mdmfs), but in overall 
the picture is:

http         | no open_basedir     | with open_basedir
response size>    25kB  |     50B  |    50B
-------------+----------+----------+------------------
FreeBSD      | 192/125  | 243/ 89  | 99/247
Linux        | 165/116  | 152/126  | 50/382
         [Requests per second / 99% of requests served within N ms]

ApacheBench concurency level is 15.
10 FastCGI processes.
TOP shows approximatelly  20% user / 80% system time split for both Linux and 
FreeBSD in all tests (so accounting is likely correct on Linux).



More information about the freebsd-performance mailing list