Last active
April 6, 2023 18:25
-
-
Save tbjers/4496984 to your computer and use it in GitHub Desktop.
Script to determine Apache ServerLimit and MaxClients.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
available=$(free --mega -tw | grep "Total:" | awk '{print $4}') | |
ps -ylC httpd --sort:rss | awk -v avail="$available" '{ s += $8; } END { print "Average Size:", s/(NR-1)/1024, "MB,", NR-1, "Processes, Total usage:", (s/(NR-1)/1024)*(NR-1), "MB, Max Servers:", avail/(s/(NR-1)/1024) }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule prefork.c> | |
StartServers 10 | |
MinSpareServers 10 | |
MaxSpareServers 25 | |
ServerLimit 128 | |
MaxClients 128 | |
MaxRequestsPerChild 0 | |
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ free -m | |
total used free shared buffers cached | |
Mem: 7454 1405 6049 0 142 401 | |
-/+ buffers/cache: 860 6594 | |
Swap: 1023 0 1023 | |
$ ./check-apache-instances.sh | |
Average Size: 26.043 MB, 37 servers, Total usage: 963.59 MB, Max Servers: 249.588 |
Thanks for the idea and script. I modified it a little to accept the actual free resources from the output of free -tw
#!/bin/sh available=$(free --mega -tw | grep "Total:" | awk '{print $4}') ps -ylC httpd --sort:rss | awk -v avail="$available" '{ s += $8; } END { print "Average Size:", s/(NR-1)/1024, "MB,", NR-1, "Processes, Total usage:", (s/(NR-1)/1024)*(NR-1), "MB, Max Servers:", avail/(s/(NR-1)/1024) }'
Thank you for this! I have updated the original script with your suggestion.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the idea and script. I modified it a little to accept the actual free resources from the output of free -tw