首页 > 代码库 > Nginx 服务器性能Bug和优化方案(真实经历)
Nginx 服务器性能Bug和优化方案(真实经历)
一、遇到的问题
1、问题:本应该是3个ffmpeg ,但是怎么会有5个ffmpeg出现?
2、Lua脚本问题,一直写入日志,导致有大量的日志,这里的错误日志是直接写进nginx的error.log 日志文件的
(1)日志文件
total 1.8G -rw-r--r-- 1 root root 11M May 9 21:47 access.log -rw-r--r-- 1 root root 3.1K May 9 21:46 error.log -rw-r--r-- 1 root root 705M May 9 21:44 live_access.log -rw-r--r-- 1 root root 1.1G May 9 21:44 nginx_error.log
2017/05/09 21:43:05 时间段详细记录:
2017/05/09 21:43:05 [notice] 154005#0: *2276339 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276301 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255428 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2255382 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2276989 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276946 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255373 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2277509 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255426 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2276852 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276850 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276811 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276416 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276558 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276495 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255454 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2280641 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2255417 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255401 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2257856 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255428 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255372 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255426 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255396 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2276402 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2254567 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255436 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255387 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2276423 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255460 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2255443 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2277380 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276203 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276375 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255467 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2255404 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255485 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2276709 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255473 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2255419 "\.m3u8" matches "/live/C 2017/05/09 21:43:05 [notice] 154005#0: *2255443 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255456 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255480 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255460 "\.m3u8" does not match " 2017/05/09 21:43:05 [notice] 154005#0: *2255467 "\.m3u8" does not match "
2017/05/09 21:43:06 时间段详细记录:
2017/05/09 21:43:06 [notice] 154005#0: *2276219 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2255463 "\.m3u8" does not match 2017/05/09 21:43:06 [info] 154005#0: *2280641 client 59.47.230.140 close 2017/05/09 21:43:06 [notice] 154005#0: *2255438 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2276179 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 129532#0: signal 1 (SIGHUP) received, recon 2017/05/09 21:43:06 [notice] 129532#0: reconfiguring 2017/05/09 21:43:06 [notice] 154005#0: *2255469 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2255482 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2254624 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2255498 "\.m3u8" matches "/live/ 2017/05/09 21:43:06 [notice] 154005#0: *2255503 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2255473 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2276387 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2255496 "\.m3u8" matches "/live/ 2017/05/09 21:43:06 [notice] 154005#0: *2255407 "\.m3u8" matches "/live/ 2017/05/09 21:43:06 [notice] 154005#0: *2255337 "\.m3u8" matches "/live/ 2017/05/09 21:43:06 [notice] 154005#0: *2255472 "\.m3u8" matches "/live/ 2017/05/09 21:43:06 [notice] 154005#0: *2276430 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2255519 "\.m3u8" matches "/live/ 2017/05/09 21:43:06 [notice] 154005#0: *2255439 "\.m3u8" matches "/live/ 2017/05/09 21:43:06 [notice] 154005#0: *2255396 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2276635 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2255494 "\.m3u8" matches "/live/ 2017/05/09 21:43:06 [notice] 154005#0: *2255498 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2280695 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2255515 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: *2255459 "\.m3u8" does not match 2017/05/09 21:43:06 [notice] 154005#0: gracefully shutting down 2017/05/09 21:43:06 [notice] 154005#0: *2277200 "\.m3u8" does not match
(2)Lua脚本日志写入:
if ( tonumber(res) == 0 or tonumber(res) == 1 ) then -- 不是签名验证,则直接返回 ngx.log(ngx.ERR, "error : 不是签名验证,则直接返回::res=== ",res) return end
解决办法:立即关闭该日志的写入,重启nginx服务器 reload
3、他们摄像头推流,直播结束后ffmpeg 进程一直在
4、是否针对播流权限认真是否取消掉?
6、流状态列表查看(必须的联系他们的人员怎么处理),没有推流但是nginx服务状态一直存在
解决方案:
修改nginx rtmp配置参数,添加这个参数:drop_idle_publisher 10s;
drop_idle_publisher
语法:drop_idle_publisher timeout
上下文:rtmp, server, application
描述:终止指定时间内闲置(没有音频/视频数据)的发布连接。默认为 off。注意这个仅仅对于发布模式的连接起作用(发送 publish 命令之后)。
语法:drop_idle_publisher timeout
上下文:rtmp, server, application
描述:终止指定时间内闲置(没有音频/视频数据)的发布连接。默认为 off。注意这个仅仅对于发布模式的连接起作用(发送 publish 命令之后)。
Nginx 服务器性能Bug和优化方案(真实经历)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。