For privilege separation and isolation reasons, I run one lighttpd and a php-cgi for each different subsystem (currently 3 on my Linode 360) that uses PHP. I keep the -C (children) option tuned relatively low, and in my situation, all three of the subsystems are completely unique so I'm not "wasting" that much from xcache duplication.
Here's one of my "almost 100% idle" handlers:
Code:
$ cat /etc/event.d/fcgi-asterisk
# spawns fcgi handler
start on startfcgi
stop on stopped lighttpd
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
pre-start exec sleep 5
respawn
exec /usr/bin/spawn-fcgi -n -f /usr/bin/php-cgi -a 127.0.0.1 -p 4001 -C 2 -u asterisk -g asterisk
For b2evolution and gallery2, I have -C 4. Of course, the -p, -u, and -g are different for each.
This results in:
Code:
blogs 24634 0.0 0.0 38496 336 ? Ss 2009 0:00 /usr/bin/php-cgi
blogs 26781 0.0 3.8 43724 13584 ? S Jan28 0:19 \_ /usr/bin/php-cgi
blogs 23116 0.0 3.7 42848 13328 ? S 09:42 0:06 \_ /usr/bin/php-cgi
blogs 27015 0.0 3.9 43480 14176 ? S 10:20 0:06 \_ /usr/bin/php-cgi
blogs 22731 0.0 3.0 40868 10880 ? S 14:43 0:01 \_ /usr/bin/php-cgi
asterisk 24635 0.0 0.0 38496 268 ? Ss 2009 0:00 /usr/bin/php-cgi
asterisk 24640 0.0 3.3 42428 11888 ? S 2009 0:02 \_ /usr/bin/php-cgi
asterisk 24642 0.0 2.8 41272 10216 ? S 2009 0:01 \_ /usr/bin/php-cgi
gallery2 24636 0.0 0.1 38496 372 ? Ss 2009 0:00 /usr/bin/php-cgi
gallery2 4453 0.0 5.4 43224 19300 ? S 06:46 0:05 \_ /usr/bin/php-cgi
gallery2 4972 0.0 5.1 41816 18520 ? S 06:50 0:06 \_ /usr/bin/php-cgi
gallery2 7655 0.0 4.8 41552 17232 ? S 07:20 0:05 \_ /usr/bin/php-cgi
gallery2 10281 0.0 5.0 41528 17892 ? S 07:41 0:05 \_ /usr/bin/php-cgi
total used free shared buffers cached
Mem: 348 323 24 0 57 98
-/+ buffers/cache: 167 180
Swap: 255 122 133
... which ain't too bad. IMHO, one of the major advantages of doing the lighttpd/fcgi method is being able to run php scripts on different uids, so you might as well do it.
