Understanding the MaxClients/MaxRequestWorkers Apache is capable of handling
Environment
- Red Hat Enterprise Linux (RHEL) 7.x,8.x,9.x
- httpd-2.4.x
- Red Hat JBoss Core Services (JBCS) Apache httpd
- httpd-2.4.x
Issue
- I have a server with 128 GB RAM, 8 CPU Cores is there a good way to determine how many connections my server can handle.
- How to calculate the MaxRequestWorkers for Apache httpd 2.4.6 in RHEL7 based on physical memory and cpu core in the system?
- How to calculate the MaxClients for Apache httpd?
- How to determine the max number of connection Apache httpd process can handle it.
- How to determine the max number of concurrent connection for Apache httpd?
Resolution
Yes there is a way for you to determine the max number of connection your Apache process can handle.
In short the determining factor for this is determined by the Stack Size of the system. For each System this value is different depending on the OS an limitation set by the Admin (for various security and performance reasons).
- Apache (httpd) has a way for you to adjust what it uses for the Content from httpd.apache.org is not included.ThreadStack size however it can not exceed what the system uses.
Because the Stack Size is the main factor in determining what the system can handle, you need to take your total (max) memory limit for the system (minus overhead for other system resources) and divided it by the Thread Stack Size to get the theoretical max number of connections a system could handle.
System Memory / Thread Stack Size = Theoretical Max number of connections
Example:
4194304 KB (4 GB) / 8192 KB = 512 Theoretical Max number of connections/clients
- Keep in mind that MaxClients is optimal at 200 * (# of cpu cores) for the prefork mpm and around 300 * (# of cpu cores) for the worker mpm.
With this and the above note I would need a minimum of 5 cpu's if I was running the prefork mpm module and 3 if I was running the worker mpm to reach this max limit and use the total amount of memory my system has.
Root Cause
With 128 GB RAM, the calculation would look like:
134217728 / 8192 = 16384
However if you note this would require a minimum of 81 cpu's if I was running the prefork mpm module and 54 if I was running the worker mpm to reach this max limit.
It is why in most cases you work from the point of view of the CPU and not the amount of memory a system has as described in Knowledge Base Article 218353.
Diagnostic Steps
- Use the LB config tool (This content is not included.This content is not included.https://access.redhat.com/labs/lbconfig/) to help you configure or play with what these values might look like in your Apache (httpd) Configuration.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.