PHP+NGINX参数优化

Failed requests: 0

Write errors: 0

Requests per second: 3712.72 [#/sec] (mean)

Time per request: 134.672 [ms] (mean)

Time per request: 0.269 [ms] (mean, across all concurrent requests)

Transfer rate: 732.37 [Kbytes/sec] received

 

1000并发:

Concurrency Level: 1000

Time taken for tests: 28.385349 seconds

Complete requests: 100000

Failed requests: 0

Write errors: 0

Requests per second: 3522.94 [#/sec] (mean)

Time per request: 283.853 [ms] (mean)

Time per request: 0.284 [ms] (mean, across all concurrent requests)

Transfer rate: 694.94 [Kbytes/sec] received

 

与1)比较,有大约10%的性能下降

调整fpm的max_request参数为1000,并发1000报错返回降到200个以下,

Transfer rate在800左右

3. nginx下关于PHP-FPM在高负载下的优化配置

When you running a highload website with PHP-FPM via FastCGI, the following tips may be useful to you : )

1、Compile PHP’s modules as less as possible, the simple the best (fast);

2、Increas PHP FastCGI child number to 100 and even more. Sometime, 200 is OK! ( On 4GB memory server);

3、Using SOCKET PHP FastCGI, and put into /dev/shm on Linux;
注:在php-fpm.cnf里设置<value name="listen_address">/tmp/nginx.socket</value>就可以通过socket连接 FastCGI了,/dev/shm是内存文件系统,放在内存中肯定会快了

4、Increase Linux “max open files”, using the following command (must be root):
# echo ‘ulimit -HSn 65536′ >> /etc/profile
# echo ‘ulimit -HSn 65536 >> /etc/rc.local
# source /etc/profile

注:我是修改/etc/rc.local,加入ulimit -SHn 51200的

5、Increase PHP-FPM open file description rlimit:
# vi /path/to/php-fpm.conf
Find “<value name=”rlimit_files”>1024</value>”
Change 1024 to 4096 or higher number.
Restart PHP-FPM.

6、Using PHP code accelerator, e.g eAccelerator, XCache. And set “cache_dir” to /dev/shm on Linux.

上一页123下一页


留言