在使用带有PHP-FPM v5.3.3 nginx的设置中,我注意到nginx错误日志中经常发生以下错误:
Feb 16 15:00:22 mymachine www.example.com 2015/02/16 15:00:20 [error] 20254#0: *1448249 readv() failed (104: Connection reset by peer) while reading upstream [...]
看着php-fpm.log文件,我注意到了以下几点:
[16-Feb-2015 15:00:20] NOTICE: [pool www] child 22279 exited with code 0 after 47983.681002 seconds from start [16-Feb-2015 15:00:20] NOTICE: [pool www] child 10625 started
这就是pm.max_requestsconfiguration指令设置的工作者回收。
我(合理地)认为PHP-FPM会在回收工作人员之前提前处理任何接受的连接/请求,因为这个任务并不意味着任何紧急情况。
pm.max_requests是一种常见的做法。 也许你只需要几个工人运行。 你应该调查忙碌和正在运行的worker的数量,php-fpm有一个内部资源pm.status_path – 你可以看到wget或者其他的http客户端:
[root@sol etc]# wget -O - -q http://localhost/status pool: www process manager: dynamic start time: 29/Jan/2015:11:36:20 +0300 start since: 1633615 accepted conn: 996160 listen queue: 0 max listen queue: 0 listen queue len: 0 idle processes: 34 active processes: 1 total processes: 35 max active processes: 18 max children reached: 0 slow requests: 0
它说,我有一个活跃的进程和一个空闲的 – 因此我没事。 繁忙进程的数量是最多的18个,因此我从开始就一直都可以。