Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


php-fpm eating all of the cpu
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

php-fpm eating all of the cpu

gurugrvgurugrv Member

Hello, I have a strange issue with one of my wordpress installation. I am using nginx with php-fpm and it is using all of the cpu. A lot of php-fpm processes run and they consume all of the cpu. The RAM is fine. I disabled all the plugins and switched to default theme too but the problem still exists. Also tinkered around with php-fpm.conf changing process to ondemand but still no change. Due to all of the consumed cpu the server keeps throwing not found errors making the site totally unusable. Will any experienced guy please help me ? Thanks in advance.

Comments

  • AlbaHostAlbaHost Member, Host Rep
    edited April 2015

    @gurugrv said:
    Hello, I have a strange issue with one of my wordpress installation. I am using nginx with php-fpm and it is using all of the cpu. A lot of php-fpm processes run and they consume all of the cpu. The RAM is fine. I disabled all the plugins and switched to default theme too but the problem still exists. Also tinkered around with php-fpm.conf changing process to ondemand but still no change. Due to all of the consumed cpu the server keeps throwing not found errors making the site totally unusable. Will any experienced guy please help me ? Thanks in advance.

    We have had the same issue with one of our client, the main problem was to wordpress admin Comments section There was more than 12 million comments. Our solution was by connecting to phpmyadmin and disable/drop the table wp_commentmeta. This have fixed everything, hope it helps.

  • High cpu usage without high RAM usage for php-fpm tend to mysql issue (you can see with 'top' where '%wa' tend to high).

  • Maybe a HTTP flood?

  • Comments are all clear.

    @AlbaHost said:
    We have had the same issue with one of our client, the main problem was to wordpress admin Comments section There was more than 12 million comments. Our solution was by connecting to phpmyadmin and disable/drop the table wp_commentmeta. This have fixed everything, hope it helps.

  • gurugrvgurugrv Member
    edited April 2015

    top output

    801 mysql 20 0 329m 144m 4456 S 1.3 14.1 27:53.14 mysqld 1639 gurugrv 20 0 113m 56m 3900 R 1.0 5.5 4:06.78 php-fpm 1645 gurugrv 20 0 113m 56m 3904 R 1.0 5.5 4:06.96 php-fpm 1666 gurugrv 20 0 120m 62m 3876 R 1.0 6.1 4:06.46 php-fpm 1793 gurugrv 20 0 119m 62m 3876 S 1.0 6.1 4:04.66 php-fpm 1807 gurugrv 20 0 119m 62m 3900 R 1.0 6.1 4:03.59 php-fpm 1504 gurugrv 20 0 120m 62m 3884 S 0.6 6.1 4:10.37 php-fpm 1643 gurugrv 20 0 113m 56m 3876 R 0.6 5.5 4:06.60 php-fpm 1946 gurugrv 20 0 113m 56m 3876 R 0.6 5.5 3:59.82 php-fpm 2361 gurugrv 20 0 113m 56m 3908 R 0.6 5.5 3:49.81 php-fpm 10548 gurugrv 20 0 113m 56m 3876 R 0.6 5.5 0:34.65 php-fpm 1 root 20 0 2900 868 796 S 0.0 0.1 0:00.02 init 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd/123676 3 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper/123676 176 root 16 -4 2464 352 348 S 0.0 0.0 0:00.00 udevd 545 root 20 0 25696 1076 844 S 0.0 0.1 0:00.54 rsyslogd 564 named 20 0 54316 2628 1616 S 0.0 0.3 0:03.77 named 601 root 20 0 8628 648 548 S 0.0 0.1 0:00.03 sshd 610 gurugrv 20 0 5972 312 308 S 0.0 0.0 0:00.00 fastcgi-wrapper 618 root 20 0 3044 1148 1144 S 0.0 0.1 0:00.01 mysqld_safe 838 root 20 0 12452 1008 844 S 0.0 0.1 0:02.70 sendmail 847 smmsp 20 0 12240 792 676 S 0.0 0.1 0:00.01 sendmail 874 root 20 0 4556 320 264 S 0.0 0.0 0:00.06 pure-ftpd 884 root 20 0 3608 712 636 S 0.0 0.1 0:00.29 crond 896 root 20 0 4764 352 248 S 0.0 0.0 0:00.00 nginx 899 emps 20 0 5004 1052 832 S 0.0 0.1 0:00.06 nginx 903 root 20 0 39460 1436 1216 S 0.0 0.1 0:08.41 php-fpm 909 emps 20 0 39372 1020 872 S 0.0 0.1 0:00.00 php-fpm 910 emps 20 0 39372 1020 872 S 0.0 0.1 0:00.00 php-fpm 911 emps 20 0 39372 1020 872 S 0.0 0.1 0:00.00 php-fpm 912 gurugrv 20 0 39372 1020 872 S 0.0 0.1 0:00.00 php-fpm 913 gurugrv 20 0 39372 1020 872 S 0.0 0.1 0:00.00 php-fpm 914 gurugrv 20 0 39372 1020 872 S 0.0 0.1 0:00.00 php-fpm 915 root 20 0 2008 432 428 S 0.0 0.0 0:00.00 mingetty 916 root 20 0 2008 432 428 S 0.0 0.0 0:00.00 mingetty 10099 root 20 0 39372 988 736 S 0.0 0.1 0:00.00 php-fpm 10100 root 20 0 39372 988 736 S 0.0 0.1 0:00.00 php-fpm 11352 root 20 0 39372 988 736 S 0.0 0.1 0:00.00 php-fpm 11353 root 20 0 39372 988 736 S 0.0 0.1 0:00.00 php-fpm 11959 root 20 0 12072 4072 3304 S 0.0 0.4 0:00.11 sshd 11963 root 20 0 11940 3756 2996 S 0.0 0.4 0:00.11 sshd 11964 root 20 0 3048 1548 1308 S 0.0 0.1 0:00.00 bash 11980 root 20 0 7864 1748 1312 S 0.0 0.2 0:00.00 sftp-server 11986 root 20 0 2568 1100 892 R 0.0 0.1 0:00.00 top 15875 root 20 0 65276 2112 1196 S 0.0 0.2 0:08.73 php-fpm 15877 gurugrv 20 0 65232 1732 884 S 0.0 0.2 0:00.00 php-fpm 15878 gurugrv 20 0 65232 1732 884 S 0.0 0.2 0:00.00 php-fpm 15879 gurugrv 20 0 65232 1732 884 S 0.0 0.2 0:00.00 php-fpm 16358 root 20 0 4808 424 260 S 0.0 0.0 0:00.00 nginx 16360 emps 20 0 5464 1712 912 S 0.0 0.2 0:32.55 nginx 16686 root 20 0 93596 880 680 S 0.0 0.1 0:01.58 varnishd 16687 varnish 20 0 1205m 91m 87m S 0.0 8.9 0:39.90 varnishd

    @mustafaramadhan said:
    High cpu usage without high RAM usage for php-fpm tend to mysql issue (you can see with 'top' where '%wa' tend to high).

  • Can that be done 24X7 ? On different servers too ?

    @tr1cky said:
    Maybe a HTTP flood?

  • gurugrv said: Can that be done 24X7 ? On different servers too ?

    I doubt you have http flood here :)

    Most probably you have some mistake on the configuration or PHP scripts. If you fine with root access or teamviewer (less preferred), i may take a look.

  • edited April 2015

    I mean:

    Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
    Mem: 16288368k total, 3193444k used, 13094924k free, 361592k buffers
    Swap: 4194300k total, 169108k used, 4025192k free, 936872k cached

    where in this illustration %wa is 0.0.

  • @Profforg said:
    Most probably you have some mistake on the configuration or PHP scripts. If you fine with root access or teamviewer (less preferred), i may take a look.

    Sent you a pm

  • RolterRolter Member
    edited April 2015

    Can you post php-fpm.conf ? Or the pools php-config file if you are using a separate pool file ?

  • gurugrvgurugrv Member
    edited April 2015

    @Rolter said:
    Can you post php-fpm.conf ? Or the pools php-config file if you are using a separate pool file ?

    I was running this installation of wordpress with another one on a server. The other installation was running fine without any issues. So I guess its not something with configuration. As soon as I switched servers the same problems started with the other server too.

    The php-fpm.conf is as follows


    ;;;;;;;;;;;;;;;;;;;;;
    ; FPM Configuration ;
    ;;;;;;;;;;;;;;;;;;;;;

    ;;;;;;;;;;;;;;;;;;
    ; Global Options ;
    ;;;;;;;;;;;;;;;;;;

    [global]
    ;emergency_restart_threshold 10
    ;emergency_restart_interval 1m
    ;process_control_timeout 10s

    ;;;;;;;;;;;;;;;;;;;;
    ; Pool Definitions ;
    ;;;;;;;;;;;;;;;;;;;;

    [index]
    listen = 127.0.0.1:9000
    user = gurugrv
    group = gurugrv
    request_slowlog_timeout = 5s
    slowlog = var/log/php-fpm-slowlog-index.log
    listen.allowed_clients = 127.0.0.1
    pm = ondemand
    pm.max_children = 10
    pm.start_servers = 3
    pm.min_spare_servers = 2
    pm.max_spare_servers = 4
    pm.max_requests = 500
    listen.backlog = -1
    request_terminate_timeout = 120s
    rlimit_files = 131072
    rlimit_core = unlimited
    catch_workers_output = yes
    security.limit_extensions = FALSE
    env[HOSTNAME] = $HOSTNAME
    env[TMP] = /tmp
    env[TMPDIR] = /tmp
    env[TEMP] = /tmp

    [regular]
    listen = 127.0.0.1:9001
    user = gurugrv
    group = gurugrv
    request_slowlog_timeout = 5s
    slowlog = var/log/php-fpm-slowlog-regular.log
    listen.allowed_clients = 127.0.0.1
    pm = ondemand
    pm.max_children = 10
    pm.start_servers = 3
    pm.min_spare_servers = 2
    pm.max_spare_servers = 4
    pm.max_requests = 500.
    listen.backlog = -1
    request_terminate_timeout = 120s
    rlimit_files = 131072
    rlimit_core = unlimited
    catch_workers_output = yes
    security.limit_extensions = FALSE
    env[HOSTNAME] = $HOSTNAME
    env[TMP] = /tmp
    env[TMPDIR] = /tmp
    env[TEMP] = /tmp
    pm.status_path = /php5-status.php

  • tomsfarmtomsfarm Member
    edited April 2015

    Try the following for the www pool that comes default with php-fpm

     [www]
     listen = /var/run/php-fpm.sock
     listen.backlog = -1
     user = nginx
     group = nginx
     listen.mode = 0666
     pm = dynamic
     pm.max_children = 16
     pm.start_servers = 1
     pm.min_spare_servers = 1
     pm.max_spare_servers = 16
     pm.max_requests = 1536
     request_terminate_timeout = 500s
     request_slowlog_timeout = 10s
     slowlog = /var/log/php-slow.log
     rlimit_files = 65536
     rlimit_core = unlimited
     catch_workers_output = no
    

    Add the following into the default virtual host

     upstream php-fpm-sock {
          server unix:/var/run/php-fpm.sock;
     }
    

    And then change fastcgi_pass with the following in every virtualhost

     fastcgi_pass php5-fpm-sock;
    

    Also here is a optimized nginx.conf

     http://paste.ee/p/JDdyo
    

    You can copy the php-fpm.conf files into a separate directory and create a pool for each vhost. but if you are having issues I'd suggest that you find someone who knows what they are doing.

    ClamHost uses the configuration above for our Managed clients with various other modules enabled. Such as mod_pagespeed but you should notice major improvements by using the gzip configurations that is provided in the nginx config above.

    I hope this helps you :)

  • gurugrvgurugrv Member
    edited April 2015

    @clamhost said:

    Thank your for your input. Already using a similar nginx config. Also using varnish. But the problem still exists.

  • Is the php version same as the one on your last server ?

    I know php 5.3* had some performance issues which were only fixed in php 5.6* , so may be it is that ?

    Do both the servers have the same php extensions/modules running ?

    Thanked by 1wwabbit
  • @Rolter said:

    Yes, the same version and the same modules. Infact this issue occurs on almost all servers I migrate the site to. I even tried just migrating the db and doing a fresh wordpress installation with only the uploads folder copied over so that there is no room for any configuration error. My another wordpress website, which has more plugins and a heavier theme is running perfectly in a similar environment, infact it is using only less than 10% of the resources.
    I am really puzzled at this anomaly.

  • @gurugrv Have you fixed the issue?

  • RazzaRazza Member

    @yogeshzade said:
    @gurugrv Have you fixed the issue?

    Wtf wrong with you relying to a 3 year old post.

    Thanked by 3mksh raindog308 vmp32k
This discussion has been closed.