I'm running a CentOS 5.3 server with a basic LAMP stack. I've optimized LAMP and my code to run efficiently as possible, but Apache has a memory leak somewhere that kills my server every hour or so. What is the best way to write a script that will monitor the memory usage and if it peaks over, say, 450MB kill all the Apache processes and restart Apache. I know C++/PHP and basic Linux server administration but I'm not familiar with Perl or bash scripting. I'd be open to learn any solutions, though, as a temporary solution while I find the issue.
|
feedback
|
migrated from stackoverflow.com May 13 '10 at 19:45
This question came from our site for professional and enthusiast programmers.
|
Monit is a straightforward server-monitoring utility that can do this sort of thing. | |||
feedback
|
|
Try setting the PHP (especially mod_php) is known to do this. Alternatives include running PHP under FastCGI, which will prevent Apache from restarting and only restart the PHP interpreters. You should also insure that you always have RAM available. If this means less Apache forks running, then so be it. Clamp down on | |||
feedback
|