apache2/php5 of macports seem heavy for cacti

http://www.yuyarin.net/screenshot/20110424034956.png

Problem

It takes about 15 sec to draw each graph out by cacti. The web server gets high-load, very heavy, and sometime httpd processes become uninterruptible zombie.

Environment

Hardware.

OS Mac OS X 10.6
Hardware MacMini
CPU Intel Core 2 Duo 2.4GHz
Memory DDR3 8GB

Softwares, from Macports

apache2 2.2.17_1+preforkmpm
php5 5.3.6_0+apache2+pear
cacti 0.8.7g_1+plugins
rrdtool 1.4.4

Investigation

In cacti, the graphs are generated by rdtool_execute() at line 61 in lib/rrd.php, called by rrdtool_function_graph() at line 553. As the result of my debug, the bottleneck is first fgets() at line 172 after popen(), executing a rrdtool graph command. I tried the same rrdtool command in the shell and a php cli script, but it took less than 1 sec. Then I tried system() function in a php script from cli. The result was same. Next, I moved the php script to a directory of apache and accessed the script through my web browser, it took about 15sec.

So, the bottleneck is process execution in php5 on apache2, installed from macports. This problem will be identical to my Mac OS X because my another cacti works well on FreeBSD.

I can suspect my httpd configuration as the cause, but I just inserted one line into httpd.conf:

LoadModule php5_module modules/libphp5.so

or, 32/64-bit mode of Mac OS X, or php module configuration and apache configuration of macports, or else...

I'm now investigating the cause of this bad performance...

If you are onto something about this problem, please let me know.