Nginx community, i’ve recently switched to this awesome software which
has performed admirably under load testing.
I host a php/mysql driven site that with each page view serves results
from multiple external xml feeds in realtime. Once we have the XML data
we cache results to reduce load.
I run nginx / php5-fpm / memcache and APC. Site gets > 100,000 searches
per day. Each query takes between 1 and 4 seconds depending on the
search. So as you can imagine the processes don’t open and close as
quickly as some more basic php sites. Server load is around 3 average
for a quad core box. So OK…
But i wanted your expert opinion on how to check, test and verify my
config params for nginx and php5-fpm. I want to be 100% sure i haven’t
allocated too many processes. So without pasting my entire config, i
will show just the bits i’m concerned i wish to check with you guys.
php5-fpm tweaks
Concerns - is max_children / start servers too high? Would they take up
CPU processes wasting resources?
pm = dynamic
pm.max_children = 30
pm.start_servers = 15
pm.min_spare_servers = 5
pm.max_spare_servers = 30
pm.max_requests = 511
listen.backlog = 1024
Worker_processes 4
worker_connections 8192
fastcgi_params
Concerns - is my fastcgi_buffers too much? The reason why i set them
high is that each XML result can contain a lot of data.
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
Even under load, memory usage only reaches about 45% so perhaps i’m
wasting an opportunity to cache more things in memory.
quickly as some more basic php sites. Server load is around 3 average
CPU processes wasting resources?
worker_connections 8192
fastcgi_busy_buffers_size 256k;
The question is buried inside the details. It’s, I guess, this:
“But i wanted your expert opinion on how to check, test and verify my
config params for nginx and php5-fpm. I want to be 100% sure i haven’t
allocated too many processes.”
Yes, i just wanted an expert opinion on verifying my parameters
I felt it necessary to explain the application, environment and
parameters.
Just as a follow up; i found that the pm = dynamic config i was using
whilst serving OK for visitor, it seemed to be using twice the
processing that a pm = static used up.
So i have switched to an entirely static allocation.
I projected that each child process consumes about 50Mb with overheads
and therefore allocated 40 child processes for php5-fpm
So far so good.
I’m still getting connection reset by peer but i’m 99% sure this is
people who click back or stop the load before the page finishes. As we
get over 100k searches per day, 10-15 connection reset by peer errors
are fine.
The only thing is, only 50% of my memory is being used so maybe i can
allocate more somewhere.
I thought my post title was very clear; couldn’t have been any clearer.
I guess i may as well have posted a dancing cat purely for entertainment
value.
Perhaps my post wasn’t that clear then. Fair enough. I had searched and
clawed over tonnes of information. In fact i spent quite a few hours
looking. However, it seems not 1 set of parameters is suitable for every
nginx + php5-fpm set up, which is sensible really. I’m not a natural
sysadmin and as it was the weekend my sysadmin was unavailable, probably
off geocaching or something.
What i couldn’t find is enough info on how to test and verify my chosen
config. Due to the volume of traffic and revenue involved i didnt want
it to be trial and error. I also wanted an expert eye cast over the
chosen params in case anything jumped out as obviously incorrect.
Posted at Nginx Forum:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.