Nginx and PHP-FPM Configuration and Optimizing Tips and Tricks - Comment Page: 6
I wrote before a guide Howto install Nginx/PHP-FPM on Fedora 29/28, CentOS/RHEL 7.5/6.10, but this guide is just installation guide and many cases Nginx and PHP-FPM basic configuration is good enough, but if you want to squeeze all the juice out of your VPS or web server / servers and do your maintenance work little bit easier, then this guide might be useful. These tips are based entirely on my own experience, so they may not be an absolute truth, and in some situations, a completely different configuration may work better. It's also good to remember leave resources for another services also if you run example, MySQL, PostgreSQL, MongoDB, Mail server, Name server and/or SSH server on same...
If i have a 10 K concurrent user , and 8 core server process .. request size is about 4 KB , and response size is about 20 KB ,
what is the best configuration should i use .. and please how I could calculate values based on requests per server ( with nginx load balancer ) , cores and ram size
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
If php-fpm and nginx are the same box, it might be better to use the socket approach (better performance, no tcp overhead)
pm.start_servers = 3
pm.min_spare_servers = 2
does not make sense
Hi Martin,
Why it doesn’t make sense? It’s PHPs default value! Check:
http://php.net/manual/en/install.fpm.configuration.php
PHP-FPM pm.start_servers default value is:
min_spare_servers + (max_spare_servers – min_spare_servers) / 2
2+(4-2)/2=3
Thanks for Gre8 and useful information.
hey,
im experiencing Very hige cpu load,
i have 16Gb of ram and 6cpus ,
but everytime i have high traffic on my site some of the pages get nginx error 500
Hi Zion,
Could you tell more how much traffic you have, what configs you are using and do you run some custom site? And what cause high cpu load, nginx or php-fpm?
Hi We have 10 GB data to be synchronized between moodle and wordpress. When I try to synchronize, it shows error: 504 Bad Gateway TimeOut. Please guide. What should be memory parameters in nginx and php-fpm.
Hi GAURAV,
What method you are using to synchronize this data? It sounds like a really long and heavy operation over the HTTP protocol. Is it possible run on server (using php-cli)?
hi, thanks for this tips, i follow them and i have a better performance, but i have some troubles on concurrency, in the load testing almost, all request are failing, can i send you the config files?
Hi Andres,
Nice to hear that you find this helpful and of course you post config files and please tell also your server(s) specs.
Thanks a lot for these good described tips!
> cat /proc/cpuinfo |grep processor
is the hard way to do that, all you need is
grep -c ^processor /proc/cpuinfo
hi
im getting the 499 status in windows environment
127.0.0.1 – – [03/May/2019:15:52:32 +0000] “POST /store.php HTTP/1.1” 499 0 “-” “-”
how ill fix this
I find this helpful. Thanks for sharing.
Thanks for the tips, NGINX optimization is crucial in such cases.
I have high CPU usage.
1CPU
2GB Ram
Site at the most 100 concurrent users.
pm.max_children = 20
pm.start_servers = 8
pm.min_spare_servers = 4
pm.max_spare_servers = 12
pm.max_requests = 500