Apache takes all memory
I've been recently having issues with Apache webserver. I found my server frozen, because It had no RAM and Swap memory left. Somehow I managed to log in to SSH and find out where the problem is. I can't understand what could cause this.
How could I limit Apache2 to not use all available resources?
Depending on the MPM, you can limit the started servers and the maximum number of clients.
But looking at your htop output, you would need to limit the maximum number of clients to three, which is a bit low.
I guess, it is not really apache but the application it serves that goes amok.
Multiples scenarios are possible:
1) maybe the app has a memory leak
2) maybe the app really does need that much memory by design.
Then I would question the design or re-read the suggested system requirements.
3) maybe the app can be configured to work in smaller chunks
The first two cases call for developer work, the latter for config changes.
I´m only guessing of course.
A more detailed inspection would be needed.
Yes it's possible that app have some logical errors. Because this isn't happening exactly after starting webserver, this happened only few days later. I think that Apache starts more processes and they keep running in memory.
I guess that this could also be caused by DoS attack.
I'll take a look at app code, it's relatively small website, developed by non-professional :)
Thanks For your fast reply!
If you have monitoring in place, like nagios or xymon, then you would be able to see the memory consumption on a timeline.
Here is an example
green : Xymon - Status @ Sat Aug 13 20:29:24 2011