Views: 904 (Data available since 06.02.2017)
Last Modified: 10.10.2012

Even with the two-tier configuration, it is essential to stabilize the system memory consumption irrespective of load degree and prevent server from overload.

We recommend that you set the MaxClients parameter in the Apache settings to 5 to 50 to maintain better memory consumption and minimize the number of running back-end processes.

By setting the MaxClients parameter, you limit the number of simultaneous back-end processes. Thus, you impose a strict limitation on memory consumption and prevent the machine from breakdown at stress loads.

The MaxClients value should be derived from the system resources and load.

You can use the following algorithm to find out the best value. Get the amount of memory consumed by a back-end web server process. Assume you observe the indication of 20 B. If we set MaxClients to 5, the maximum memory allocation is 100. It is recommended to choose 5 to 10 for a 512 MB machine. Having a Front-end properly configured to process static files ensures that the system will easily support 50000 hits a day (10 to 20 thousands unique visitors).

For large scale, twin machine projects or if the server has much RAM, the MaxClients value should be derived from the stress test results.

Important! You should choose the MaxClients value such that the processor load rate is 90% of processor resources at most in stress conditions, and never reach 100%. This will ensure the system will not suffer from performance regression at peak loads.

Another important parameter is the Front-end response timeout which is to be configured to keep the front-end waiting for the release of a back-end web server process if there are no spare processes. This eventually makes up a query queue protecting the back-end from overload.

The back-end process management parameters should respect the MaxClients value. For example, if MaxClients is 5, the following parameters would require changing values:

MinSpareServers 5 
StartServers 5 
MaxClients 5

These settings mean that when the back-end server starts, it will run as many web servers as client connections are possible. The processes will never terminate to be ready to accept and process a front-end request anytime. At the start-up time, the size of allocated memory is readily available which allows to assign the remaining memory to the database.

Suggestion. It is a good idea to begin with a small value of MaxClients, e.g. 5 and monitor the page execution time (?show_page_exec_time=Y). If, on a fast channel, the page execution time is permanently minimum at stress load while a page loads with a significant lag, we can affirm that the current number of back-end processes is insufficient to quickly respond to the front-end requests. In this case, the MaxClients value can be increased taking the memory allocation balance into consideration.

Another advantage of MaxClients is the database connection optimization.

Imposing the limitation allows to enable persistent database connections and avoid wasting time for the database connection, reduce the number of running database processes. The MaxClients parameter ensures that there will not be running back-end processes more than this parameter requiring database connectivity. Apparently, the server will always run MaxClients processes with persistent connections to the database.

Attention! Administrators often neglect this recommendation ignoring the limitation or setting it to unfoundedly large values. This always result in the unbalanced two-tier system and instability at peak loads.

The recommendations given in this lesson can:

  1. stabilize the system memory consumption at whatever load;
  2. avoid the processor overloads and the performance regression;
  3. safely use persistent connections.


Courses developed by «Bitrix», Inc.