Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Ok every so often my website which runs on a ubuntu 9.04 vps seems to fall over as apache does not seem to respond.

a simple apache restart solves the issue but obviously it's not a good scenario having to manually restart the server every time this happens.

the site is a wordpress site with minimal traffic (max. 200 visitors a day) i've also got php running as an apache mod with APC caching setup.

i removed some processes which were running on the server like clamav which has reduced memory usage somewhat (server has half a gig of RAM).

users report seeing "out of memory" errors just before apache becomes responsive.

running a top command on the server now shows approx 50% memory usage.

the apache error logs not showing anything interesting either.

but running a top command shows me there are 4 unique instances of apache2 running - each consuming about 15% of memory. The cpu is at 0%

Can anyone explain why there are 4 individual apache processes running and how to manage these correctly?

Thanks all.

Ed

share|improve this question

1 Answer 1

up vote 2 down vote accepted

but running a top command shows me there are 4 unique instances of apache2 running - each consuming about 15% of memory. The cpu is at 0%

What you are probably seeing is Apache with its child processes ready to serve requests. You most likely don't have to manage those (other than make sure you don't have too high MaxClients defined, so a sudden traffic spike won't eat up all the available RAM and other resources).

Instead you need to find out what is taking up so much memory - Apache itself is definitely not the most light-weight web server out there, but it's not THAT heavy. Most likely something causes the PHP take up lots of memory; perhaps you have very high memory limits defined for APC?

Also, with that kind of low traffic, are you sure you really need APC? For me it seems the RAM is the weakest link in your server, so it would make sense to strip out every RAM consuming extension there is now installed.

Here's my suggestion for you:

1) Benchmark your site with APC enabled, use for example siege - it's available in Ubuntu repositories, so apt-get install siege should install it. Let it run for a while, see the results and also see if siege shoots down your Apache.

2) Disable APC, repeat the test. If the results are similar or better to previous one and/or Apache survives this test without running out of memory, leave your server without APC for now.

If you want to try completely different route, lighttpd with fcgi is a more lightweight and also more controllable combination. In that case lighttpd only server the http-requests and PHP parsing is done on fcgi backend. You can define how many fcgi backend processes there are waiting, so even a sudden spike in traffic does not eat up much more RAM, in the worst case it makes the site slower or causes some "500 Server too busy" errors, but you don't need to restart anything.

share|improve this answer
    
thanks Janne for the really detailed reply. I'm going to do as you've suggested and run some benchmarks with and without APC and see what happens. –  Ed Bloom Aug 26 '10 at 16:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.