Solving Slow Apache/PHP; Culprit = ClamAV
posted under I'm a Geek, Linuxism 2.8.2007
I’ve been having a lot of problems recently with my home Debian server locking up, with Apache processes swelling up until all RAM is eaten up and CPU 100% utilised. The box stops responding until I can get local access and restart Apache. This used to happen several times a week, despite actual load on the server being very low with hardly any web requests.

I put this down to the age of the install and some dodgy Apache settings and didn’t look too much into fixing it; I turned the child process settings down a lot which didn’t improve things, so I just set a cron job up to restart apache every so often. It was only when I came to install Debian on a brand-new server at work that I realised something was afoot – the Apache/PHP install on this new server was doing the same thing – locking up several times a day for no apparent reason and in the exact same way. Both servers would suddenly experience massive CPU and RAM utilisation; additionally Apache would take several minutes to get from startup to actually accepting requests, with huge CPU use in that time. Incidentally, my home box is testing/unstable and this new server is Etch (stable).

I spent a few minutes going through the config files for Apache, PHP and MySQL (also installed on my home box) in an effort to optimise the install, and examined the extensions list in php.ini to see if there were any I could remove. I unfortunately suffer from over-enthusiasm when installing things like PHP, XMMS and so on, whereby I read the list of related packages and install everything that I might possibly need someday or that could be useful at some point. In this case this included php4-clamavlib, which I installed thinking it might be good to play with on a rainy day.

A quick apt-get remove php4-clamavlib and I restarted Apache; to my surprise it came up in about two seconds as opposed to the three minutes it was taking before to stop using 100% CPU after being started. I watched the box carefully for the rest of the day and it had no problems. Upon getting home I did the same thing on my own server and it too appears to be cured. So if you’re having problems with Apache suddenly choking, check to see if you’ve got the ClamAV library for PHP installed. If you don’t need it, lose it!


No Comments
RSS feed for comments on this post | trackback

Post a comment
You must be logged in to post a comment.