0

I'm unable to determine, how many users my apache instance can handle.

I installed Apache 2.4.18 from Ubuntu repository, as far as I remember, all settings are default ones.

I did a server stress test and discovered, that when exceeding 300 ongoing requests, server start to drop new ones, serving response code 502 or 504.

I tried to find an explanation for that in server configuration file and documentation, but I was unable to discover where that "300" came from.

I'm using mpm_prefork, with config file like this:

<IfModule mpm_prefork_module>
        StartServers                     5
        MinSpareServers           5
        MaxSpareServers          10
        MaxRequestWorkers         150
        MaxConnectionsPerChild   0
</IfModule>

Some of the properites from apache2.conf:

Timeout 300
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 5

So the question is what is Apache DEFAULT max concurrent clients limit in my (default) configuration? I'm not interested in tuning Apache to handle as many connections as possible - only to understand, how Apache calculates max concurrent clients limit.

  • IMHO, you are looking at this wrong. Apache doesn't determine this, you set it. Whether or not Apache will handle it without crashing has nothing to do with Apache, but everything to do with (1) your available RAM, (2) the average size of your application's Apache processes, and (3) RAM required for other things. – Colt Aug 17 '16 at 19:55
  • @Colt So the answer is like "Apache will start dropping requests when it runs out of RAM"? – Greg Witczak Aug 17 '16 at 19:57
  • It will queue requests when it hits the limit that you set, which will result in a short processing delay. When it runs out of ability to handle requests (because your limit is set too low and it is not queuing), it will start trying to swap to disk, will slow way down, start throwing 50x errors, and then crash. Once it starts swapping, it is usually all over – Colt Aug 17 '16 at 20:02
  • Here is one article describing this. NOTE: MaxClients is the old terminology for MaxRequestWorkers – Colt Aug 17 '16 at 20:08
3

Per the Apache documentation,

For non-threaded servers (i.e., prefork), MaxRequestWorkers translates into the maximum number of child processes that will be launched to serve requests. The default value is 256.

Depending on your available RAM, the default settings are often too high.

To determine the correct setting, look at your average Apache process size to get usage x MB. Consider how much memory you want to keep available for other processes y MB and use this formula for prefork.

(Total RAM – yMB)/xMB = MaxRequestWorkers

NOTE: the "y" value will always be at least 500 MB just for Apache itself and the operating system, and may well need to be more depending on other applications.

As to the other values, the Apache documentation repeatedly advises against raising these values except "on very busy sites," of which by definition a site having, for example, only 2-4 GB total RAM will never be. The following will be good:

StartServers         2
MinSpareServers      5
MaxSpareServers     10

For additional reference, you can look at the Apache Documentation for performance tuning this issue.

  • Thanks for your answer, but that's just copy-paste from other Apache question you answered - and does not answer my question in any way. – Greg Witczak Aug 17 '16 at 14:59
  • Except that it does. Under prefork, the MaxRequestWorkers determines how may concurrent requests the server will handle. If you set it too high, the server will start to use swap space and then (quickly) die. If set correctly, it will queue additional requests and handle them as earlier requests are processed (usually quickly). The "slow, painful death" of Apache resulting from getting this value wrong is well documented. Also, becuase the number is dependent on your average process size, you have to monitor and do the math. There is no standard answer. – Colt Aug 17 '16 at 16:34
  • See also: MaxRequestWorkers Directive documentation, describing the directive as setting the "Maximum number of connections that will be processed simultaneously" – Colt Aug 17 '16 at 19:45
  • I don't ask what is the correct value - but what is the default value. I need it for the research, as a reference value for default Apache configuration. Maybe I haven't pointed that clearly in the question, I'll fix it. – Greg Witczak Aug 17 '16 at 19:48
  • Same reference to documentation, for "For non-threaded servers (i.e., prefork), MaxRequestWorkers translates into the maximum number of child processes that will be launched to serve requests. The default value is 256" .... WHICH, by the way, is often too high! – Colt Aug 17 '16 at 19:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.