2

with apache, is it reasonable to reduce MaxClients when KeepAlive is Off? currently, MaxClients is set to 150, which is the default for mpm-worker.

  • nginx serves static files and reverse-proxies to apache
  • we are averaging around 12-15 requests per second
  • cpu load avg is never above 0.8 on a quad-core box

thanks!

1

4 Answers 4

2

Use MaxClients to stop your server from swapping.. that's usually how I handle it.

I try and figure out roughly how big each apache process is, then figure out how many I can fit into memory reasonably -- that's my MaxClients setting.

If your site gets slammed with more than MaxClients worth of requests, you shouldn't end up swapping. Additional clients will sit in the socket queue until a worker becomes available. If it takes too long, the server will time out. If the queue is too long, they'll get a connection refused.

If you have MaxClients set too high, your webserver will start thrashing and swapping. When this happens, each request will take longer to process and you'll end up compounding the problem.

0

Unless you're suffering any problems, I see very little reason to lower MaxClients. If anything, you'd usually raise it from the default if you were getting a lot of traffic.

0

In your setup nginx is handling all the end user connections and Apache is basically an application server. As long as you have enough threads to handle requests you should be fine. Threads should only grow to 150 if you need that many else it'll start at StartServer 5 with MinSpareServers 5 if you've kept the default. Since it's a quad core machine 32 or so threads is probably the most you'd need though that depends on how much latency or blocking happens while Apache is waiting on your backend.

All in all I'd probably leave MaxClients alone and make sure StartServers was 25 (or whatever would support your normal load) rather than 5 so that your server is ready to handle production traffic as soon as it comes up. Then I'd alert on threads over 50 or whatever seems "too high" for your usual load as that might indicate a poorly performing backend or attack on your site.

Edit: Not sure why I assumed you have threads, but it's the same with processes too.

1
  • A value of 25 for StartServers would be rather excessive for worker MPM and the general default setting of 25 threads per process. Starting up 25 server processes means 625 concurrent requests being able to be handled. Consider that requests are generally much less than 1 second in length, that is potentially a much much greater number of requests per second that could be handled, way more than one would usually expect a single system to handle. So, if they were using prefork MPM, then maybe, but not if using worker MPM. Jun 27, 2009 at 10:31
0

Set MaxClients to a value just below the level at which your machine will run out of RAM (assuming it's a dedicated web server)

If you're not expecting a lot of traffic, make sure you monitoring system is checking the number of running apaches. If it goes high, try and work out why.

Keep Alives should normally be on, and set to a very fast time out, for typical high traffic sites.

2
  • since nginx is serving all static content and apache is acting just as an application server, i dont see a need for KeepAlives
    – matt
    Jun 18, 2009 at 22:52
  • Yes, keep alive is a bit pointless if nginx is front end as nging proxy only supports HTTP/1.0 and doesn't implement keep alive. The nginx server as a result should drop connections promptly anyway, but still better to just disable leep alive in Apache if all requests coming via nginx. Jun 27, 2009 at 10:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .