So my lighttpd was running fine for more than a year. Two days ago I decided to install Wordpress 3.0.1 (PHP was already in use by other tools).
So after some hours of very few hits (i might get 10 unique visitors per day at max), the system almost hangs with a load of 25-35, lighttpd eating all CPU and RAM (see top
at the end of the post).
I read of similar problems, but none seemed to be exactly what occurs here. The "solutions" on the web were like installing a Wordpress Caching Plugin, which i did (W3 Total Cache). As the problem didn't occur during the night, I thought that was the problem. But right now the machine is totally overloaded, even OOM Killer is kicking in.
A lighttpd restart helps, but that's not a real solution.
System specs:
- Intel Celeron2Duo 2.2GHz
- 4GB RAM
- Debian Lenny 5.0.6
- Kernel: 2.6.26-2-amd64
- lighttpd 1.4.19
- MySQL 5.0.51a
- PHP 5.2.6-1+lenny
Changing the hardware is no option, as it's a home server made for low power consumption. Ideas? Thanks in advance.
top - 10:34:04 up 19:03, 1 user, load average: 25.98, 22.97, 12.51
Tasks: 155 total, 15 running, 140 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.5%us, 95.6%sy, 0.0%ni, 0.0%id, 3.6%wa, 0.0%hi, 0.3%si, 0.0%st
Mem: 4062488k total, 4039436k used, 23052k free, 264k buffers
Swap: 979956k total, 979956k used, 0k free, 3012k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3648 debian-t 20 0 136m 6972 116 R 7 0.2 30:48.27 transmission-da
2569 root 20 0 196m 900 108 S 5 0.0 4:51.94 rsyslogd
316 munin 20 0 30592 548 136 D 4 0.0 0:04.68 sendmail
3377 root 20 0 66292 6864 208 D 4 0.2 2:01.44 python
3188 www-data 20 0 4074m 3.1g 124 R 4 81.2 12:20.23 lighttpd
Edit: I installed a temporary restart script as suggested by LatinSuD. So probably tomorrow I can tell details about the interval of that issue.
Can you update to a newer version of lighttpd? 1.4.19 is very old (the newest 1.4 branch is 1.4.28). I know there have been a number of memory leaks fixed in that interval.
http://redmine.lighttpd.net/projects/lighttpd/repository/entry/branches/lighttpd-1.4.x/NEWS
How do you have php installed? If you're using fastcgi, do you have too many worker processes starting? Make sure you haven't done something problematic with mod_rewrite that's causing an endless loop. Normally lighttpd detects those, but Bug 1775 was fixed in 1.4.20, and might be your issue.
I'm running lighttpd on a TonidoPlug, so it's vital for me to watch memory consumption. To that end, I've cron'd the following script to run every 30 minutes. There's probably a better way to do it, but it works for me :-)
The column headers are: "datetime,used,free,buffers,cached" and the output records look like this: 20110613 1002,184716,329092,30548,129496
You can then import the file into Excel/OpenOffice at regular intervals to produce graphs.
In my case, I run a "sync && echo 3 > /proc/sys/vm/drop_caches" on a regular basis - hence the "heartbeat" style graph above. It's a work in progress and I'm making further tweaks.