Recommendation for multiple sites with lighttpd
I'm running several sites on my Linode with lighttpd, most of them hosting simple wordpress-esque stuff with low load and one fairly high-load site. Until now, all sites were running under a single lighttpd process as virtual hosts, which made configuration easy.
Now I'm beginning to set up a new site which will hopefully be relatively busy as well. I'm not sure how I'm going to monitor each site individually with all of them using the same php-cgi. On my old host (dreamhost, ugh), the managed lighttpd was set up to run one proxy process and several lighttpd processes with php children attached to each one individually. This was practical for monitoring the sites seperately but seems to be a waste of resources and a pain in the ass to set up (seperate XCache, individual php.inis, the necessity of setting up a proxy, etc…)
So my question(s) is:
What do you do on your servers? Do you run multiple processes? Multiple Linodes? If yes, what method do you use to avoid doing twice the maintenance work?
Thanks in advance!
5 Replies
In my case, I "don't care", so everything goes into one log file. If I needed to see information for one specific domain, then it's pretty simple to just write a quick script to grab only for one domain.
Here's one of my "almost 100% idle" handlers:
$ 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:
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.
When I last used spawn-fcgi, it still had problems with leaking that are rumored to be gone. Do you do scheduled restarts of spawn-fcgi? lighttpd seems to be doing this on its own for the "built-in" php handler.