Welcome! Log In Create A New Profile

Advanced

Nginx + php-fpm Slow Response When Busy

Posted by godius 
Nginx + php-fpm Slow Response When Busy
July 02, 2009 03:19PM
Hello im running a quad core 8GB machine with fast scsi drives with 64bit centos 5.

Now on that site i run a site that get about 750.000 unique visitors, and the site uses ajax intensively. every pageview uses about 15 ajax http requests. I used to run my site on apache, but because of the insanely high load i decided to move to nginx.

I have setup nginx with php-fpm, and it is running quite good, only when it gets really busy (around 25 pageviews per second), i sometimes notice that i have to wait a few seconds before the server sends a response. This only happens when its busy, so i think ive hit some kind of limit in nginx. It is probably possible to resolve this by changing a certain value somewhere.

The server load is always low, around 1. Below i have posted some of the settings i have already modified.

[code]
[b]nginx.conf[/b]
events {
worker_connections 6000;
}
worker_processes 12;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
gzip on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
[/code]


[code]
[b]php-fpm.conf[/b]
<value name="max_children">3000</value>
<value name="StartServers">200</value>
<value name="MinSpareServers">600</value>
<value name="MaxSpareServers">2000</value>
<value name="request_terminate_timeout">10s</value>
[/code]

before on apache my site used to get busier because it was able to handle up to 35 pageviews per second, now i never see it go over 25, because i think nginx can not handle more with my current setup.

Please advice how to tune/optimize/improve my settings.

Kind regards,

Godius
Re: Nginx + php-fpm Slow Response When Busy
July 02, 2009 08:34PM
Two things:

[list=1]
[*] Igor always suggests having no more workers than cores. You can increase the number of connections per worker (use a multiple of 1024 preferably) if you need to, but make certain that you have enough file descriptors available (most likely 2/connection).
[*] Your php-fpm.conf is attempting to use a feature which has never been implemented and that is the Apache style configuration. I'm guessing that you have 3000 php-cgi processes running at all times. That may be more than you need. I would suggest lowering that number to something more manageable as each process is consuming resources. You'll need to play with it so that you aren't overloading your system with unused php-cgi processes and not getting 504's.
[/list]

--
Jim Ohlstein
Re: Nginx + php-fpm Slow Response When Busy
July 03, 2009 01:56AM
Is there away for me to see how much nginx is actually using? how many connections etc are actively being used? so i can see if the setting is too high.
Re: Nginx + php-fpm Slow Response When Busy
July 03, 2009 02:01AM
If you configure --with-http_stub_status_module.

You can install rrdtool and get graphs as in http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/ .

There are also Munin plugins for nginx.

--
Jim Ohlstein
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 234
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