1

at some point apache seems to hang up and not serve requests anymore or they take forever. i checked the error log. doesnt show any errors when i do apachctl stop and start apache again it works again

4 Answers 4

1

WHAT DO YOUR ERROR LOGS SAY?

grep -i maxclient /var/log/httpd/error_log*

(thinking it might be a maxclient issue.. thus the reason for that search)

Chances are your httpd.conf file needs to be tuned. That being said let's get started.

Virtually almost always httpd.conf is located @ the same place - I am hoping you are comfortable with shell as well as the editor of your choice... I will use NANO in this explanation..

First complete this command:

cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.bkup.beforeItuned

Next use the following command to open the original httpd.conf file in your editor:

nano /etc/httpd/conf/httpd.conf 

Then use "Control-W" to open the search command and type Timeout - you should see something similar to this

Timeout = 120

Change that to

Timeout = 20 

Press the Control-X key and then save the file overwriting the original

Finally - restart Apache using:

/etc/init.d/apache2 restart

Following the aformentioned directions - you can also edit a few other settings:

Be Sure to only do one change at a time to make sure each works... slow is better than major changes and major crashes

Search for the following section: prefork MPM (or just prefork )

<IfModule prefork.c>
StartServers       2
MinSpareServers    1
MaxSpareServers    5
MaxClients         10
MaxRequestsPerChild  1000
</IfModule>

and change to something one of the following - based upon the level of your server:

basic level servers (small resources):

<IfModule prefork.c>
StartServers       1
MinSpareServers    1
MaxSpareServers    3
MaxClients         50
MaxRequestsPerChild  1000
</IfModule>

Medium level servers (medium resources):

<IfModule prefork.c>
StartServers       2
MinSpareServers    2
MaxSpareServers    5
MaxClients         100
MaxRequestsPerChild  1000
</IfModule>

Larger level servers (larger resources):

<IfModule prefork.c>
StartServers       2
MinSpareServers    2
MaxSpareServers    5
MaxClients         200
MaxRequestsPerChild  1000
</IfModule>

Anyhow - these should be a decent start - of course you will want to continue to fine tune to get the best solution.

Happy Editing :-)

did this help you? be sure to vote on this answer

1

Apache can crash for a number of reasons. The possibilites include

  1. Improper configuration in the httpd.conf or .conf includes
  2. Traffic
  3. Memory usage
  4. Improper module configuration
  5. Time to update?
  6. Perhaps you're being hit because of an exploit?

Your question is pretty vague, so I'd start by taking a look at your httpd.conf and, if you're using a modular compilation, try preventing modules you don't need from loading. The lines look like this: LoadMoudle mod_rewrite modules/mod_rewrite.so Something to that effect. If you're not using them, turn them off.

Next, take a look at which version you're running. If it's a PHP app, tune script memory usage to something attainable. Also take a look at how many clients you've configured to allow to serve at any one moment.

Let's get real: the list could be a mile long, and is far beyond my ability to explain at this given moment in time. I highly recommend the Apache Performance Tuning documentation, which goes into better detail and comes from, well, a rebutable source.

I've personally experienced many server problems over the years -- they happen. Automate how you respond to them. Give the computer a chance to handle events before you need to get involved. I highly recommend Monit as a robust and capable tool, without the headache of Nagios configuration. Monit configuration uses clear, concise syntax.

Best of luck.

0

Check for number of request it can handle concurrently. look in HTTPD.CONF file .

0

There can be many reasons for Apache hanging. Not enough connections is just one potential cause, so don't assume anything. The first things I check if Apache is acting weird:

  1. Error log of course.
  2. Tail the access log to see if any requests are being processed at all.
  3. Check system load with htop or top to see if Apache is busy or not.
  4. Use strace -p $APACHE_PID to snoop and see what Apache is doing.
  5. Enable PHP error logging to file. Many Linux distributions don't log PHP errors by default.

You must log in to answer this question.