« Return to Thread: require_once performance issue in ZF

require_once performance issue in ZF

by Gea-Suan Lin-2 :: Rate this Message:

Reply to Author | View in Thread

Hello,

We've ported our application from plain PHP to ZF 1.5.3, and notice some
performance issue in require_once().

We run web server in FreeBSD 7-STABLE, apache 2.2 worker, mod_fastcgi,
and php-fcgi 5.2.6. (install from ports)

The original application needs 6 servers (E5405, 8 logical cpu) only, and
most of them are 50% idle. But the ported version needs 17 servers and 0%
idle, with 80% system cpu time, 20% userland cpu time.

I use ktrace (similar with strace in Linux) trying to dig problem, and
find it's because lstat(2), and FreeBSD's lstat(2) call VFS_GIANT_LOCK(9)
to lock VFS. This behavior cause inscalability.

So I also tried to install Debian (testing, 2.6.18 kernel), with same
apache 2.2 worker, mod_fastcgi, php-fcgi 5.2.6. (all installed by
apt-get). CPU usage in system is decreasing, but only 30% performance
better then FreeBSD one.

After reading the following article, I realize that require_once() is a
very important factor, since it calls realpath(3) and realpath(3) calls
lstat(2):

http://www.techyouruniverse.com/software/php-performance-tip-require-versus-require_once

I replace all require_once argument to absolute path in ZF library, and
the performance seems much acceptable. (Down to 50% idle in 17 servers,
still not very happy to me, since it needs change require_once() code,
and our writing pattern)

I've been told by some people that some framework will implement its
require_once to reduce PHP's require_once code, does ZF team have such
plan ?

Thanks,

PS: for people understanding Chinese, you may see my blog to talk about
    this more specifically: http://blog.gslin.org/archives/2008/08/29/1639/

--
* Gea-Suan Lin                                    http://blog.gslin.org/
* If you cannot convince them, confuse them.           -- Harry S Truman

 « Return to Thread: require_once performance issue in ZF