Skip to content

Instantly share code, notes, and snippets.

@iamstoick
Created July 26, 2017 07:03
Show Gist options
  • Save iamstoick/a4eafe359107b6bd41b6529a07f803a0 to your computer and use it in GitHub Desktop.
Save iamstoick/a4eafe359107b6bd41b6529a07f803a0 to your computer and use it in GitHub Desktop.
How to check an average memory usage by single PHP-FPM process
ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
ps --no-headers -o "rss,cmd" -C apache2 | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
@iamstoick
Copy link
Author

iamstoick commented Jul 26, 2017

pm.max_children = Total RAM dedicated to the web server / Max child process size

@hamedbaftam
Copy link

hi
i run this command:
ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
but return negative number
-2147483647M

@chicongst
Copy link

hi
i run this command:
ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
but return negative number
-2147483647M

hi
i run this command:
ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
but return negative number
-2147483647M

Check your PHP-fpm version.
ps --no-headers -o "rss,cmd" -C php-fpm{version-here} | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

@lessmore92
Copy link

For PHP 7.3

ps --no-headers -o "rss,cmd" -C php-fpm7.3 | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment