Skip to content

Instantly share code, notes, and snippets.

@moraleslevi
Created May 9, 2017 20:17
Show Gist options
  • Save moraleslevi/4c286c5f385c8aca91f352ef9a8b6e46 to your computer and use it in GitHub Desktop.
Save moraleslevi/4c286c5f385c8aca91f352ef9a8b6e46 to your computer and use it in GitHub Desktop.
This is a script you can run on apache servers to help calculate MaxRequestWorkers/ServerLimit based on available free memory.
#!/bin/bash
echo -e "\n*** Memory Output ***\n"
free -m
echo -e "\nEnter the amount of free memory (in MB), followed by [ENTER]:"
read FREE
ps -G www-data -ylC apache --sort:rss | awk -v free="$FREE" '{ s += $8; } END \
{ print "\nAverage Size:", s/(NR-1)/1024, "MB\n Num Servers:", NR-1, \
"\n Total Usage:", (s/(NR-1)/1024)*(NR-1), "MB\n Max Servers:", \
free/(s/(NR-1)/1024) }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment