I’ve had a somewhat recurring problem that Apache on my server is a memory hog. The machine has a full GB of RAM now, but even so, heavy activity from spidering bots or reddit can bring it to its knees.
I’ve been trying to figure out what to do about it. I run Apache on there, and here’s an idea of what it hosts:
- This blog, and two others like it, using WordPress
- Several sites that are nothing but static files
- A redmine (ruby on rails) site
- Several sites running MoinMoin
- A set of tens of thousands of redirects from mailing list archives I used to host over to gmane (this had negligible impact on resource use when I added it)
- A few other smaller PHP apps
Due to PHP limitations, it will only work with the Apache prefork or itk MPMs. That constrains the entire rest of the system to those particular MPMs. Other than PHP, most of the rest of these sites are running using FastCGI — that includes redmine and MoinMoin, although gitweb is a plain cgi. Many of these sites, such as this blog, have changed underlying software over the years, and I use mod_rewrite to issue permanent redirects from old URLs to their corresponding new ones as much as possible.
I do have two IPs allocated to the server, and so I can run multiple webservers if desired.
lighttpd is a lightweight webserver. I’ve browsed their documentation some, and I’m having a lot of trouble figuring out whether it would help me any. The way I see it, I have four options:
- Keep everything as it is now
- Stick with Apache, discard mod_php and use FastCGI for PHP, and pick some better MPM (whatever that might be)
- Keep Apache for PHP and move the rest to lighttpd
- Move everything to lighttpd, with FastCGI for PHP
I know Apache pretty well, and lighttpd not at all, so if all else is equal, I’d want to stick with Apache. But I’m certainly not above trying something else.
One other wrinkle is that right now everything runs as www-data — PHP, MoinMoin, static sites, everything. That makes me nervous, and I’d like to run some sites under different users for security. I’m not sure if Apache or lighttpd is better for that.
If anybody has thoughts, I’m all ears.