PHP FPM a lot of pid's

Mattpl

Verified User
Joined
Jun 28, 2017
Messages
84
Location
ZS
HI! In my case I have a lot of pids in php-fpm56 (pid 3420 3435 20792 21225 21227 21230 21246 21253 21304 21305 21308 21309 21312 21314 22719 22745 23035 23055 25155 28493 28505 32684 32685 32692 32694 32717 32731 )

I check a CPU usage and RAM and this pids take to much from my machine (in CPU, sometims is 90%), could you tell me how Can i optimize this service?
 
That's normal. Every connection to your website which load a php script is forking a php-fpm worker process. When it is compiling files, it utilizes the CPU as hard as the OS allows it (it tries to do it as fast as possible) so it is OK to see 90%+ CPU usage on one core every time somebody hits your website. That does not mean that your CPU is loaded 90% all the time - look at the averages in top.

When the file is compiled, its output is returned back to Apache and it then return it back to the user. The php-fpm process is NOT killed - it will stay for a while. The reason for that is that sometimes (many times) users click on another link on the website or load another linked resource automatically. Instead of forking a new process, php-fpm reuses the old one - that's speedier.

This is why there are lots of php-fpm processes staying idle and doing nothing. They take ram and that's normal.

if you want to reduce the ram (thus reducing some performance), you can do that in the php-fpm config by changing it to not leave idle processes. Usually you should not do that unless you are really out of ram and your server is swapping.
 
That's normal. Every connection to your website which load a php script is forking a php-fpm worker process. When it is compiling files, it utilizes the CPU as hard as the OS allows it (it tries to do it as fast as possible) so it is OK to see 90%+ CPU usage on one core every time somebody hits your website. That does not mean that your CPU is loaded 90% all the time - look at the averages in top.

When the file is compiled, its output is returned back to Apache and it then return it back to the user. The php-fpm process is NOT killed - it will stay for a while. The reason for that is that sometimes (many times) users click on another link on the website or load another linked resource automatically. Instead of forking a new process, php-fpm reuses the old one - that's speedier.

This is why there are lots of php-fpm processes staying idle and doing nothing. They take ram and that's normal.

if you want to reduce the ram (thus reducing some performance), you can do that in the php-fpm config by changing it to not leave idle processes. Usually you should not do that unless you are really out of ram and your server is swapping.

Wattie, thanks for this post. Usage of RAM (all pids ) is about 1.5GB. I'm using phpfpm v.5.6 should I use v7?? I read that v.7 is more opt.
 
It won't show much difference in the ram usage. Yes, it will run a bit faster; however make sure that your software is compatible as there are some differences (deprecated features removed completely for example).
 
It won't show much difference in the ram usage. Yes, it will run a bit faster; however make sure that your software is compatible as there are some differences (deprecated features removed completely for example).

Yeap, First, I will contact with programers. Thanks!
 
really need fast help! Have problem with mysql is not working error : Error connecting to MySQL: Can't connect to local MySQL server through socket '/usr/local/mysql/data/mysql.sock' (2)
 
I make new symlink for socket and database run but roundcube have error
DATABASE ERROR: CONNECTION FAILED!

Unable to connect to the database!
Please contact your server-administrator.

error log:
[31-Aug-2017 15:18:33 +0200]: <kgjcik70> DB Error: SQLSTATE[HY000] [1045] Access denied for user 'da_roundcube'@'localhost' (using password: YES) in /var/www/html/roundcubemail-1.2.5/program/lib/Roundcube/rcube_db.php on line 173 (GET /$
[31-Aug-2017 15:18:33 +0200]: <kgjcik70> DB Error: SQLSTATE[HY000] [1045] Access denied for user 'da_roundcube'@'localhost' (using password: YES) (GET /roundcube/)
Make for now
DROP DATABASE da_roundcube;
quit

cd /usr/local/directadmin/custombuild
./build roundcube
Found outdated /usr/local/directadmin/conf/my.cnf. Rewriting from /usr/local/directadmin/conf/mysql.conf
Inserting data to mysql and creating database/user for roundcube...
Database created, da_roundcube password is pass
Editing roundcube configuration...
Roundcube 1.3.0 has been installed successfully.
Executing database schema update.
done.
This instance of Roundcube is up-to-date.
Have fun!
in my.cnf and mysql.cnf - correct pass

All right it's something wrong with htacces becasue when I add to url /public_html/index.php roundcube load normaly.
 
Last edited:
Again problem with mysql is inactive ;/ Please help!
mysqld.service - MySQL database server
Loaded: loaded (/etc/systemd/system/mysqld.service; enabled)
Active: inactive (dead) since Fri 2017-09-01 00:45:52 CEST; 1min 36s ago
Process: 16507 ExecStart=/usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysqld.pid --socket=/usr/local/mysql/data/mysql.sock (code=exited, status=0/SUCCESS)
Main PID: 16507 (code=exited, status=0/SUCCESS)

Sep 01 00:45:52 serwer.szukampracypl.kylos.net.pl systemd[1]: Started MySQL database server.
Sep 01 00:45:52 serwer.szukampracypl.kylos.net.pl mysqld_safe[16507]: 170901 00:45:52 mysqld_safe Can't log to error log and syslog at the same time. Remove ...effect.
Sep 01 00:45:52 serwer.szukampracypl.kylos.net.pl mysqld_safe[16507]: 170901 00:45:52 mysqld_safe Logging to '/var/log/mysql/error.log'.
Sep 01 00:45:52 serwer.szukampracypl.kylos.net.pl mysqld_safe[16507]: 170901 00:45:52 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
Sep 01 00:45:52 serwer.szukampracypl.kylos.net.pl mysqld_safe[16507]: 170901 00:45:52 mysqld_safe mysqld from pid file /usr/local/mysql/data/mysqld.pid ended
H
 
Back
Top