Skip to content

Instantly share code, notes, and snippets.

@mjsorribas
Forked from moraleslevi/apache-prefork-tune.sh
Created April 7, 2018 20:58
Show Gist options
  • Save mjsorribas/76305d23c4c2acb703adaa9245ed25ec to your computer and use it in GitHub Desktop.
Save mjsorribas/76305d23c4c2acb703adaa9245ed25ec 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