On Fri, Mar 18, 2022 at 8:27 AM Marc Serra <mse...@manxa.net> wrote:
>
> Thank's for your comments Frank,
>
> Reading the Apache documentation
> (https://httpd.apache.org/docs/2.4/en/mod/mpm_common.html#threadlimit)
> I cannot find the way to calculate an optimal value for ThreadLimit
> and ThreadsPerChild directives for that reason I kept the default
> values (64 and 25).
>
> Can you (or anyone) help me to find the right values?

This script might help for an MPM event configuration based on
MaxRequestWorkers:
```
#!/bin/bash

if [ $# -lt 1 ]; then
    echo>&2 "usage: `basename $0` <MaxRequestWorkers>"
    exit 1
fi

# Some pre-computations
numWorkers=$1
if [ $numWorkers -lt 1000 ]; then
    numProcesses=10
elif [ $numWorkers -lt 10000 ]; then
    numProcesses=$(($numWorkers / 100))
else
    numProcesses=100
fi
numThreads=$(($numWorkers / $numProcesses))

cat <<EOF
# MPM event settings
StartServers             1
ServerLimit              $(($numProcesses * 3))
ThreadLimit              $numThreads
ThreadsPerChild          $numThreads
MinSpareThreads          $numThreads
MaxSpareThreads          $(($numWorkers / 2))
MaxRequestWorkers        $numWorkers
#ThreadStackSize         524288
MaxConnectionsPerChild   0
EOF
```

For a MaxRequestWorkers of 1500, it gives:
# MPM event settings
StartServers             1
ServerLimit              45
ThreadLimit              100
ThreadsPerChild          100
MinSpareThreads          100
MaxSpareThreads          750
MaxRequestWorkers        1500
#ThreadStackSize         524288
MaxConnectionsPerChild   0

But you didn't describe your workload: static resources, dynamic
content (local with mod_cgid or offloaded with mod_proxy_fcgi),
proxying (HTTP, websocket), etc.
Since your system looks quite capable (RAM/CPU), the limit for
MaxRequestWorkers depends mainly on the average request time (bounded
by timeouts) which you probably should measure for your workload.


Regards;
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org

Reply via email to