0

Okay, last night, around 2am on one of my servers the cpu usages went up to 100%. When I checked in this morning, I saw 5 php-fpm processes taking up around 100% cpu together. I've rebooted the server, but everytime the server comes back, the php-fpm processes start again and take 100% cpu.

It a Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-32-generic x86_64) server, I've updated all software and I just can't get any information what's causing this.

Obviously the problem causes the websites hosted on the server to be offline, all the time showing either a 502 Bad Gateway or a 504 Gateway Time-out error...

I'm hoping someone can offer some help in fixing this.

I've got 3 other servers, with the exact same setup who don't have any of these problems.

EDIT 1: When I look at NewRelic, it shows me that around the same time the problems started, there's a huge increase in "Packets per second" in the network tab, That must have something to do with the problem...

5
  • have you tried to check error and access logs, strace the pid, install "mytop" to see whats going on? Commented Oct 3, 2015 at 14:53
  • Yes I have, but not getting getting any wiser. I've install 'htop', it just shows me those 5 php-fpm processes taking +/- 20% cpu. Commented Oct 3, 2015 at 15:06
  • When I look at NewRelic, it shows me that around the same time the problems started, there's a huge increase in "Packets per second" in the network tab, That must have something to do with the problem... Commented Oct 3, 2015 at 15:08
  • forget about htop.. install "mytop", and check/monitor access log with "goaccess" Commented Oct 3, 2015 at 16:39
  • You are most likely under attack, someone is firing lots of requests to resource-hungry PHP scripts on your server. Check your logs, firewall off the offending IPs and consider implementing rate limits or making your app more efficient (caching of DB requests, etc). Commented Oct 6, 2015 at 0:11

1 Answer 1

0

I had similar problem with PHP-FPM and it used to take 100% CPU even during the night time when the traffic was less.

You will have to bit optimize the PHP-FPM configuration files. Make sure that you have this entry present :-

pm = ondemand pm.max_children = 2 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3

If it's not ondemand, then change to ondemand otherwise PHP-FPM will try and take lot of CPU resource. With ondemand , it will start more process when there will be a need for that.

The configuration files for PHP-FPM are located at :-

/etc/php5/fpm/php-fpm.conf

There is also a pool configured at pool.d/www.conf .

Check both of these files for entries and optimize those above settings accordingly and restart your PHP-FPM.

2
  • Meh. This may help but won't do much against what looks like a (D)DoS attack. Rate limits and making the app more efficient is the correct way to fix this. Commented Oct 6, 2015 at 0:12
  • There is no mention or not much indication of DDoS. PHP-FPM takes 100% CPU on default configuration lot of times. It's more about performance tuning then rate limiting. Commented Oct 6, 2015 at 7:37

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.