|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
require_once performance issue in ZFHello,
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 |
|
|
Re: require_once performance issue in ZFyou can write a script to remove all require_once that non dynamically load
Zend Framework classes and rely on Autoload to solve your problems, which can use require only. This is quite easy to do. As I understood 2.0 will have some changes regarding require and autoloadings. Also PHP 5.3 will implement a new require_once that reduces overhead (somewhat). On Friday 29 August 2008 13:24:49 Gea-Suan Lin wrote: > 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/ -- Benjamin Eberlei http://www.beberlei.de |
|
|
Re: require_once performance issue in ZFAre you using any kind of opcode cache like APC? That should help you a lot.
If you cannot use an opcode cache try putting your PHP files onto a ramdisk instead of your harddisk. You can also determine the set of files that are used by most requests and place all code into one combined code file and include this one file instead of all the individual files. You need to remove the appropriate require statements in this case or play with the autoloader. One last option is to determine which pages take most of the resources and streamline the code for these pages. Even if that means porting them back to plain PHP with minimal ZF use. I did this for one high traffic app and only needed to convert the code for two different URL's (REST calls) and was able to reduce the number of servers for the whole app. Christoph Gea-Suan Lin wrote: > 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/ > > |
|
|
Re: require_once performance issue in ZF+1 for APC
|
| Free embeddable forum powered by Nabble | Forum Help |