Created
June 2, 2024 22:52
-
-
Save mrevjd/4ce4ef1c98cb52376f5c5dc68854d90a to your computer and use it in GitHub Desktop.
Calculate FPM Workers
This file contains hidden or 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
| #!/usr/bin/env bash | |
| RESERVED_MEM_GB=${1:-0} | |
| PHP_FPM_MEM=$(ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | grep php-fpm|grep pool| awk '{sum+=$1; count++} END {print sum/count}') | |
| TOTAL_MEM_GB=$(free -m | awk '/^Mem:/{print $2}') | |
| MEM_RATIO=$(echo "scale=2; ($TOTAL_MEM_GB - $RESERVED_MEM_GB) / $PHP_FPM_MEM" | bc) | |
| echo "Total Workers: $MEM_RATIO" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment