I have a multiprocessor PHP application (CLI) that runs continuously. I initially used the standard build of Ubuntu 10.04 to build PHP (5.3.2-1ubuntu4.18). However, I am trying to optimize memory usage because the amount of memory used by each process limits the number of forks that I can run at any given time (since I have a limited amount of memory). Following the preinheimer recommendations , I recompiled PHP, disabling all extensions, and then re-enabling only those that are necessary for my application (mysql, curl, pcntl, posix, and json). My configure command:
'./configure' '--prefix=/usr/local/phpbare' '--with-config-file-path=/etc \
/php5/clibare' '--disable-all' '--with-mysql=mysqlnd' '--with-curl' \
'--enable-pcntl' '--enable-posix' '--enable-json'
This new bare-bones design allowed my application to work, but, to my surprise, when I view the current process with top, it uses about the same amount of memory as before, and (even more problematic), it uses a huge amount of CPU time (often 15-20% of the CPU, when before the amount indicated above is usually 0-1%). Is it possible that I am missing some php extension that somehow optimizes the script to use less computing resources ??? Or is the Ubuntu build perhaps optimized for the Ubuntu architecture, while my custom build lacks these optimizations? If so, how can I find out what optimizations are used in the Ubuntu build to recreate them in my bare bones build?
ps aux | grep php, :
root 12952 0.3 0.9 33176 4968 pts/2 S Feb14 11:15 s.php 5
root 12955 0.3 0.9 32664 4732 pts/2 S Feb14 11:12 s.php 5
root 12958 0.3 0.9 32664 4796 pts/2 S Feb14 10:51 s.php 5
root 12961 0.3 0.9 32740 4752 pts/2 S Feb14 11:07 s.php 5
root 14162 0.3 0.9 33000 4904 pts/2 S Feb14 10:51 s.php 5
root 14165 0.3 1.0 33256 5340 pts/2 S Feb14 10:56 s.php 5
root 23426 9.5 1.1 13492 6040 pts/2 S Feb15 151:38 s.php 1