Determine the “max process size”:
1 |
ps -ylChttpd --sort=rss |less |
will give output like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD S 48 21481 20626 0 75 0 9028 75762 semtim ? 00:00:01 httpd S 48 21487 20626 0 75 0 9040 75762 semtim ? 00:00:01 httpd S 48 21482 20626 0 75 0 9064 75762 semtim ? 00:00:01 httpd S 48 21486 20626 0 75 0 9088 75762 semtim ? 00:00:01 httpd S 48 21485 20626 0 75 0 9096 75762 semtim ? 00:00:00 httpd S 48 21488 20626 0 75 0 9104 75762 semtim ? 00:00:01 httpd S 48 21017 20626 0 75 0 9116 75762 semtim ? 00:00:02 httpd S 48 21019 20626 0 75 0 9168 75762 semtim ? 00:00:01 httpd S 48 20645 20626 0 75 0 9188 75762 semtim ? 00:00:03 httpd S 48 20703 20626 0 75 0 9304 75795 semtim ? 00:00:02 httpd S 48 20628 20626 0 75 0 9324 75795 semtim ? 00:00:02 httpd S 48 20629 20626 0 75 0 9376 75829 - ? 00:00:02 httpd S 48 20630 20626 0 75 0 9408 75829 semtim ? 00:00:01 httpd S 48 20633 20626 0 75 0 9412 75829 semtim ? 00:00:02 httpd S 48 20634 20626 0 75 0 9432 75829 - ? 00:00:02 httpd S 48 20631 20626 0 75 0 9448 75829 semtim ? 00:00:01 httpd S 48 20632 20626 0 75 0 9692 75800 semtim ? 00:00:02 httpd S 48 20704 20626 0 75 0 9788 75795 semtim ? 00:00:02 httpd S 48 20635 20626 0 75 0 10016 75964 semtim ? 00:00:02 httpd S 48 20705 20626 0 75 0 10040 75964 semtim ? 00:00:03 httpd S 0 20626 1 0 78 0 14768 75729 - ? 00:00:00 httpd |
Use the largest value in the RSS column. In this case 14768. The number is in KB of memory.
Determine MaxClients by dividing the available memory by the max process size. Keep in mind that MySQL and other applications may need some memory.
Here’s a one liner to get max per process usage:
1 |
ps -ylChttpd --sort=rss | cut -f 16 -d " " | grep -v RSS | sort -n -r | head -1 |