Nginx php-fpm 502 报错:设置参数调大后依然没解决

GhostCoder
  • 271

相关报错:

  • Nginx Error Log
recv() failed (104: Connection reset by peer) while reading response header from upstream
  • PHP FPM Error Log
449 [04-Jan-2019 10:52:30] WARNING: [pool www] child 25054 exited on signal 11 (SIGSEGV - core dumped) after 47484.155316 seconds from start
450 [04-Jan-2019 10:52:30] NOTICE: [pool www] child 1310 started
451 [04-Jan-2019 11:23:24] WARNING: [pool www] child 25033 exited on signal 11 (SIGSEGV - core dumped) after 49338.447068 seconds from start
452 [04-Jan-2019 11:23:24] NOTICE: [pool www] child 1857 started
453 [04-Jan-2019 11:46:21] WARNING: [pool www] child 25052 exited on signal 11 (SIGSEGV - core dumped) after 50715.557187 seconds from start
454 [04-Jan-2019 11:46:21] NOTICE: [pool www] child 2263 started
455 [04-Jan-2019 11:54:20] WARNING: [pool www] child 25038 exited with code 1 after 51193.974856 seconds from start
456 [04-Jan-2019 11:54:20] NOTICE: [pool www] child 2378 started
457 [04-Jan-2019 12:23:16] WARNING: [pool www] child 1005 exited on signal 11 (SIGSEGV - core dumped) after 6101.226650 seconds from start

当前 PHP-FPM 参数配置:

115 ; The number of child processes created on startup.
116 ; Note: Used only when pm is set to 'dynamic'
117 ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
118 pm.start_servers = 40
119
120 ; The desired minimum number of idle server processes.
121 ; Note: Used only when pm is set to 'dynamic'
122 ; Note: Mandatory when pm is set to 'dynamic'
123 pm.min_spare_servers = 20
124
125 ; The desired maximum number of idle server processes.
126 ; Note: Used only when pm is set to 'dynamic'
127 ; Note: Mandatory when pm is set to 'dynamic'
128 pm.max_spare_servers = 60
129
130 ; The number of seconds after which an idle process will be killed.
131 ; Note: Used only when pm is set to 'ondemand'
132 ; Default Value: 10s
133 ; pm.process_idle_timeout = 10s;
134
135 ; The number of requests each child process should execute before respawning.
136 ; This can be useful to work around memory leaks in 3rd party libraries. For
137 ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
138 ; Default Value: 0
139 ; pm.max_requests = 0
现在问题是参数调高了也没解决问题:之前看说可能是因为 PHP 执行太慢,但我单独测试过,每个接口单独执行都不会超过 100毫秒 所以想问下问题可能出在哪?

服务器是腾讯云免费的:1 核 1 GB 5 Mbps

回复
阅读 3.6k
5 个回答

目前怀疑是 PHP 7.3 的问题,因为切换回 7.0 之后就好了,感觉 7.3 不太稳

看一下系统日志, 也许能查出问题

/var/log/message

fpm日志爆出频繁的内存错误,应该是内存不足的问题,你看一下每个fpm峰值占用多大的内存 然后乘上fpm进程数量

要么加内存
要么限制一下进程数量

1G的内存你调的也太高了吧?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏