pksteyn / php-fpmpal

PHP-FPM script that makes recommendations on max_children
GNU General Public License v3.0
55 stars 23 forks source link

Broken in Ubuntu 20.04 #22

Open robbrandt opened 3 years ago

robbrandt commented 3 years ago

This looks like it would be an awesome tool but it's output is broken for Ubuntu 20.04. For example:

===== Recommendations per pool ===== (standard_in) 1: syntax error (standard_in) 1: syntax error --- 134936920328761 --- Current usage: 1.20% Recommended max_children: (current: 5)Config file: /etc/php/5.6/fpm/pool.d/134936920328761.conf

RichardTMiles commented 8 months ago

curl -L https://raw.githubusercontent.com/pksteyn/php-fpmpal/master/php-fpmpal.sh | sed 's/phpfpm_installed=0/phpfpm_installed=1/' | sudo bash

I've used the above to temporarily suppress the exec (php-fpm) not being available in ubuntu-2204-lts

the exec is a launcher (/usr/lib/php/php-fpm-socket-helper) for a service that takes conf args. It does not provide a help menu or version and is not included in the PATH by default.

RichardTMiles commented 8 months ago

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 ( ) ( ( ( *
)\ ) ( /( )\ ) )\ ) )\ ) ( ( (()/( )\())(()/( (()/( (()/( )\))( ) )\ /(_))((_)\ /(_)) /(_)) /(_))((_)()\ ) ( /( (() ()) (()()) ())|()) (()(() /(/( )())
| \ | || || \ | | | \ | \/ |(()\ (() | |
|
/ |
|| _/|_|| _| | / | |\/| || ' )/ ` || |
|| |||||| || || || ||| .
/ _,||_|
100 23999 100 23999 0 0 209k 0 --:--:-- --:--:-- --:--:-- 209k

===== List of PHP-FPM pools ===== --- www --- Configuration file: /etc/php/8.3/fpm/pool.d/www.conf List of processes: 23258 23259 Number of processes: 2 Current max_children value: 5 Total memory usage for pool in KB: 15188 Average memory usage per process in KB: 7594 Total potential memory usage for pool (based on average process) (KB): 37970 Largest process in this pool is (KB): 7596 Total potential memory usage for pool (based on largest process) (KB): 37980

===== Server memory usage statistics ===== Total server memory in KB: 3739852 =Total Apache memory usage in KB: 859520 =Total nginx memory usage in KB: 0 =Total Varnish memory usage in KB: 0 =Total MySQL memory usage in KB: 0 =Total PHP-FPM memory usage in KB: 15188

Memory available to assign to PHP-FPM pools in KB: (standard_in) 1: syntax error (total free memory + PHP-FPM's current memory usage)

Total potential PHP-FPM memory usage based on largest processes (KB): 37980(standard_in) 2: syntax error (%)bash: line 455: [: 37980: unary operator expected ...GOOD :-) Total potential PHP-FPM memory usage based on average process size (KB): 37970(standard_in) 2: syntax error (%)bash: line 467: [: 37970: unary operator expected ...GOOD :-)

===== Recommendations per pool ===== (standard_in) 1: syntax error (standard_in) 1: syntax error -- www -- currently uses 15188 KB memory (100.00% of all PHP-FPM memory usage). It should be allowed to use about KB of all available memory. Its average process size is 7594 KB so this means max_children should be set to ~. It is currently set to 5 (this can be changed in /etc/php/8.3/fpm/pool.d/www.conf).

===== Other considerations to take into account ===== No other recommendations at this stage.

Note: It is not ideal to run PHP-FPMpal shortly after restarting PHP-FPM or your webservices. This is because PHP-FPMpal makes recommendations based on the average pool process size, and if PHP-FPM was restarted a short while ago then the likelihood is high that there won't have been many requests made to the sites since the restart, and metrics will be skewed and not show a normalised average. It is also worth noting that if you've recently restarted any services that normally use up a large amount of memory then you probably want to wait a while before running PHP-FPMpal (e.g. if MySQL normally uses 50% of memory, but you've just restarted it then it may only use 10% of memory right now, thus the recommendations will be very skewed).

============================================================