php-fpm cpu usage problem

Mr-Pro

Verified User
Joined
Dec 19, 2017
Messages
30
Hello guys ,

I don't have many visitors on my wordpress website but today I saw that my website is down and not loading . I logged in to my centos server and using top command I saw that php-fpm cpu usage was 100% and it was stucked on 100% . After I rebooted my server everything is back to normal but I don't want this to happen again since I have adwords ads and down time means wasting my budget . I believe that something is wrong with my php-fpm config . I'm using directadmin's default php-fpm config parameters . Can anyone help me tune my php-fpm config ? If you have better configs , would you send it to me ?

Thanks ,
 
Maybe some high load or misconfiguration in Wordpress with lots of 404 requests? Did you cehck log? What configuration exactly are you running?
Apache 2.4 and NGINX in front as reverse proxy will probably help a lot.
 
Well I'm using nginx as a reverse proxy now and also I have OPcache and w3 total cache together . my php-fpm config file is default and I really want to know if I can change it for better performance but I dont know what those parameters mean . So I was hoping someone could send me a pre configured file . Also I might mention that I checked the access log and it seemed some IPs were requesting too much . seemed like a mild ddos attack . I blocked those IPs too so maybe that helps but still php-fpm configuration is what I'm looking for .

Regards ,
 
What are the specs of your server? Do you have low memory? Running on PHP7?

one example for performance and low memory could be:
Code:
[COLOR="#FF0000"]pm = ondemand[/COLOR]

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
[COLOR="#FF0000"]pm.max_children = 50[/COLOR]

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
[COLOR="#FF0000"];[/COLOR]pm.start_servers = 2

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
[COLOR="#FF0000"];[/COLOR]pm.min_spare_servers = 1

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
[COLOR="#FF0000"];[/COLOR]pm.max_spare_servers = 3

; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
[COLOR="#FF0000"]pm.process_idle_timeout = 10s;[/COLOR]

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
[COLOR="#FF0000"]pm.max_requests = 500[/COLOR]

after this test the validity of your php-fpm conf. with
php-fpm7.0 -t

If good then restart php7.0-fpm

But keep in mind, ideal configuration is server dependent.
 
I'm running centos and directadmin on 8 GB of ram and 4 Cores of cpu ( 6000 Mhz limited ) . Can you edit the config file for my server specs ? thanks .
 
Check your logs for abuse of load-scripts.php. This week a new DoS vulnerability was discovered (Google "WordPress DoS") that currently is working in the latest version. If this is the case for you you have a couple of options;

- Google: WordPress DoS and patch the file with the unofficial patch from the researcher that found the bug.
- IP Whitelist the wp-login.php page.

WordPress says this vulnerability should be fixed by servers admins. That's a weird reply I think because it's an issue in the source.
 
Back
Top