Apache going down

Hello,

First of all, thanks a lot for having a GPL version of this excelent piece of software. I use virtualmin for a single website and never had any issue with it. I have an issue with apache at this moment however - and it’s been happening for a week now.

Apache It’s going down from time to time. The logs can tell us this:

[Mon Feb 15 17:26:37 2010] [notice] caught SIGTERM, shutting down

[Mon Feb 15 17:26:38 2010] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

[Mon Feb 15 17:26:38 2010] [notice] Digest: generating secret for digest authentication …

[Mon Feb 15 17:26:38 2010] [notice] Digest: done

[Mon Feb 15 17:26:38 2010] [notice] mod_python: Creating 4 session mutexes based on 10 max processes and 0 max threads.

[Mon Feb 15 17:26:38 2010] [notice] Apache/2.2.3 (CentOS) configured – resuming normal operations

[Mon Feb 15 17:26:43 2010] [error] server reached MaxClients setting, consider raising the MaxClients setting

I have searched a lot about this and couldn’t find anything usefull, the web server it’s already with 256 MaxClients configured. Take a look at the configurations:

IfModule prefork.c

StartServers 15

MinSpareServers 15

MaxSpareServers 21

ServerLimit 256

MaxClients 256

MaxRequestsPerChild 0

IfModule

IfModule worker.c

StartServers 15

MaxClients 256

MinSpareThreads 50

MaxSpareThreads 100

ThreadsPerChild 100

MaxRequestsPerChild 0

IfModule

KeepAlive is turned off and if I’m not mistaken, apache doesn’t support more than 256 MaxClients. The server have 2GB of RAM and the load is always below 1. Anyone with a good solution to solve this? Thanks in advance.

Regards

Howdy,

Hmm… well, whenever you see Apache restarting – is it always at the same time? Or does it seem “random”?

Are there by chance corresponding entries in /var/webmin/miniserv.log around the same time of day?

Virtualmin would need to reload the config or restart Apache in certain situations, such as when adding new Virtual Servers, or making changes to the Apache config.

As far as the MaxClients error you’re getting above – I suspect that’s not related to the Apache restart, and is a different issue.

Does your server get a lot of traffic? Seeing 256 simultaneous connections is a pretty busy server :slight_smile:

A few notes though –

  • I don’t believe Apache has a limit of 256 there, you should be able to raise it higher if you like. That said, there are RAM limitations you need to be careful of. Make sure that your value here doesn’t cause your server to run out of available RAM.

  • The KeepAlive setting may actually be a useful one to keep enabled; that means a browser retrieving a webpage doesn’t need to open new connections to obtain all the images and scripts found on that page, it can continue to re-use the same connection. That should cut down on how many connections are being made to your server.

  • You may want to lower some of the timeout settings to free up Apache instances sooner. There’s various timeout values throughout the config that you can tune. For example, one named “Timeout” defaults to 300, when you can probably lower that to 60, or maybe even 30 or 45. Similar with “KeepAliveTimeout”, you may want to lower than to, say, 10 or so.

-Eric

Hmm… well, whenever you see Apache restarting – is it always at the same time? Or does it seem “random”?

It is random.

Are there by chance corresponding entries in /var/webmin/miniserv.log around the same time of day?

I didn’t find anything.

Virtualmin would need to reload the config or restart Apache in certain situations, such as when adding new Virtual Servers, or making changes to the Apache config.

This is not the case since nothing was added or removed. =)

Does your server get a lot of traffic? Seeing 256 simultaneous connections is a pretty busy server :slight_smile:

I have turned on the apache-status now. And I have found out that, I never have more than “10 requests currently being processed”. However, the site have 250 of people clicking on it.

Thank you for your reply.

Regards

Howdy,

Yeah, you may want to start by tuning the timeouts. Apache thinks that 256 are being used. If you aren’t seeing 256 simultaneous connections being processed, then something may be holding onto it’s connections for some reason. Tuning the timeout values may help with that.

Also, I don’t have much experience with the differences between Apache’s PreFork MPM versus the Worker MPM, but I’m under the impression that the Worker has the ability to be more efficient.

You may want to do some research there before making any changes, but that might be an avenue to explore if you aren’t using mod_php (which may have issues handling the threading well).

This description of the two is available on the Apache site:

* The worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time. Worker generally is a good choice for high-traffic servers because it has a smaller memory footprint than the prefork MPM. * The prefork MPM uses multiple child processes with one thread each. Each process handles one connection at a time. On many systems, prefork is comparable in speed to worker, but it uses more memory. Prefork's threadless design has advantages over worker in some situations: it can be used with non-thread-safe third-party modules, and it is easier to debug on platforms with poor thread debugging support.

http://httpd.apache.org/docs/2.2/misc/perf-tuning.html

Here’s some additional docs to get you started:

http://httpd.apache.org/docs/2.2/mod/prefork.html

http://httpd.apache.org/docs/2.2/mod/worker.html

Lastly, as to why Apache is restarting – the only other idea I have is that there may be something in one of the cron files that’s causing it. Logrotate restarts Apache, for example. However, it does so at the same time each day, and is typically early in the morning. However, perhaps there’s other things running that are causing Apache to restart?

-Eric

7 minutes and 46 seconds later, after a quick reboot of the server. We can see the following information:

  • Some details related with the web server:

Server uptime: 7 minutes 46 seconds
9 requests currently being processed, 0 idle workers
WWCWWCCWC.

  • The website (that is actually a forum) reports:

Currently Active Users: 181 (33 members and 148 guests)

Thank you for any additional help.

I have tried with Keepalive On and the result it’s worst - websites doesn’t even open since apache doesn’t create more than 10 processes. I have then put Keepalive off again.

Timeout was set to 120, and I have changed it to 60. I have disabled prefork and changed some settings on worker. It’s better, but apache still doesn’t create more than 10 processes. Many connections are put on queue due to this “limit”.

I believe this is related because I couldn’t access the website now eitheir, after 5m of runtime. Apache stucks due to the high queue list of clients trying to access the site I believe.

Thank you for any additional help.