Nginx+PHP-fpm environment performance parameter optimization method

1. The bigger the worker_processes, the better (the performance will not increase significantly after a certain number) 2.worker_cpu_affinity divides all cpu equally into worker_processes Than each worker_processes The performance of cross-cpu allocation is better; regardless of the execution of PHP, the test result is that the number of worker_processes is 2 times the number of cpu cores, and the optimal performance is 3.Unix domain socket (shared memory method) has better performance than tcp network port configuration Regardless of the backlog, the request speed has jumped by an order of magnitude, but but the error rate exceeds 50% With the addition of backlog, performance is improved by about 10% 4. Adjust the backlog of nginx, php-fpm and the kernel, connect() to unix:/tmp/php-fpm.socket failed (11: Resource temporarily unavailable) while connecting to upstream error returns will be reduced nginx: The server block of the configuration file listen 80 default backlog=1024; php-fpm: configuration file listen.backlog = 2048 kernel parameters: /etc/sysctl.conf, cannot be lower than the above configuration net.ipv4.tcp_max_syn_backlog = 4096 net.core.netdev_max_backlog = 4096 5. Adding a master instance of php-fpm on a single server will increase fpm’s processing capabilities and reduce the chance of error returns. Multi-instance startup method, using multiple configuration files: /usr/local/php/sbin/php-fpm…

Nginx+PHP-fpm environment performance parameter optimization method

1. The bigger the worker_processes, the better (the performance increase is not obvious after a certain number) 2.worker_cpu_affinity All cpus share worker_processes equally than each worker_processes The performance of cross-cpu allocation is better; regardless of the execution of php, the test result has the best performance when the number of worker_processes is twice the number of cpu cores 3. Unix domain socket (the way of shared memory) is better than tcp network port configuration performance Regardless of the backlog, the request speed has an order of magnitude leap, but the error rate exceeds 50% With backlog, the performance is improved by about 10% 4. Adjust the backlog (backlog) of nginx, php-fpm and kernel, connect() to unix: /tmp/php-fpm.socket failed (11: Resource temporarily unavailable) while connecting to upstream error returns will be reduced nginx: The server block of the configuration file listen 80 default backlog=1024; php-fpm: configuration file listen.backlog = 2048 Kernel parameters: /etc/sysctl.conf, cannot be lower than the above configuration net.ipv4.tcp_max_syn_backlog = 4096 net.core.netdev_max_backlog = 4096 5. Increasing the master instance of php-fpm on a single server will increase the processing capacity of fpm and reduce the probability of error reporting and return Multi-instance startup method, using multiple configuration files: /usr/local/php/sbin/php-fpm…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索