Welcome! Log In Create A New Profile

Advanced

CentOS 6 php-fpm issues

Posted by hymsan 
CentOS 6 php-fpm issues
July 03, 2012 09:49AM
Hello,

I recently moved from an ubuntu 12.04 installation to a CentOS 6.2 installation, and I've been testing some settings with nginx + php-fpm, on ubuntu this issue didn't exist, (I've dealt with this in the past on a small site but it wasn't an issue.)

When someone constantly spams refreshes on the site, eg. holding down F5 on windows. The cpu load on the machine will spike, reviewing top shows the php-fpm children eating up the cpu. I've toyed with the php-fpm settings a ridiculous amount, same with the nginx workers. Currently I have nginx using only 1 worker and 1024 processes which is defaut I believe.

I've tested pretty much every integer for php-fpm children and the other settings. Here are the current settings.

pm = dynamic
pm.max_children = 5
pm.start_servers = 5
pm.min_spare_servers = 1
pm.max_spare_servers = 5

This also happens with the default php-fpm configuration. This is what top looks like with the above settings when I'm spamming F5.

Cpu(s): 25.4%us, 2.9%sy, 0.0%ni, 71.6%id, 0.0%wa, 0.0%hi, 0.2%si, 0.0%st
Mem: 24605412k total, 1869564k used, 22735848k free, 6600k buffers
Swap: 26836984k total, 0k used, 26836984k free, 109704k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23303 apache 20 0 329m 13m 4292 S 39.2 0.1 0:13.22 php-fpm
23307 apache 20 0 329m 13m 4236 S 39.2 0.1 0:13.27 php-fpm
23305 apache 20 0 332m 16m 4300 R 38.5 0.1 0:13.27 php-fpm
23306 apache 20 0 332m 16m 4240 R 36.2 0.1 0:12.78 php-fpm
23304 apache 20 0 331m 15m 3732 S 27.2 0.1 0:12.67 php-fpm
11979 mysql 20 0 2872m 69m 5572 S 21.3 0.3 0:30.94 mysqld


You can see that all of the cpu is being used by php-fpm and mysql. If I increase the amount of children the cpu just continues to go higher based on the amount of them.

Machine specifications:
2x L5420 Xeon Quad Core 2.5GHz
24G Ram
OS: CentOS 6.2
160GB 7200RPM Sata

The website will run fine if someone isn't spamming the refresh button, but since I also run other applications on this machine, and they require a decent amount of cpu I can't have php-fpm "randomly" eating up the cpu like this. Again, this does not happen on Ubuntu, this has been tested multiple times, I moved from a webserver in NY running CentOS 5, which had the issue, to a machine in Chicago using Ubuntu, which didn't reproduce this issue, to another machine in PA running Ubuntu without this issue, and now I'm back on CentOS in Atlanta, and I once again have this issue.

This could just be a configuration mistake, but everything (nginx, mysql, php-fpm) is stock besides php-fpm's children settings.

Thanks for any help in advance.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 112
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready