Msg#: 3272242 posted 5:36 am on Mar 6, 2007 (gmt 0)
I need a shell script to kill apache and restart it, in case the number of processes keeps growing. The logic is like the below, but I don't know how to get the number and neither the syntax. Could somebody kindly help?
if no_of_processes (ps ax ¦ grep httpd) > 200 then killall httpd apachectl start
Msg#: 3272242 posted 11:38 am on Mar 6, 2007 (gmt 0)
Thank you so much for the script, bcc1234. It's going to be my first shell script.
Yes the real issue is bigger, but I have no clue why the number of processes keep growing and can't be killed automatically by the system. When that happens, there are accordingly growing number of records like those below in the httpd log file.
[Mon Mar 05 16:08:15 2007] [warn] child process 24829 still did not exit, sending a SIGTERM and [Mon Mar 05 16:08:21 2007] [error] child process 24829 still did not exit, sending a SIGKILL
I think it has something to do with mysql, because at the early stage before the server is brought down, dynamic pages using mysql slow down while static pages of plain text still respond normally.
At the moment I simply don't know what I can do to get closer to finding out what is the origin of the issue. Can anybody give me some advices or suggestions or any comments?
Msg#: 3272242 posted 3:41 pm on Mar 13, 2007 (gmt 0)
In lieu of the shell script you could try something like "monit".
As far as having a large number of open threads - you might want to check your http.conf and make sure keepalive is disabled or has a very low timeout.
Keepalive makes a thread that serves up a page stay open (to respond to other requests for more pages or css or js or images). Generally you will get MUCH improved performance out of apache if you use it for dynamic content only (which makes keepalive useless because apache will be generating only a single request per page) and serve up js, css, images, and other static stuff via something more lightweight (I use squid in reverse proxy mode).