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:36:43 时间段详细记录,太恐怖了,1s写入日志多大240条,难怪nginx的负载飙到54%

2017/05/09 21:36:42 [notice] 143984#0: *2210297 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2106253 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2186550 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2186550 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2204373 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2178827 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2178827 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2174075 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2192938 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2184738 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2178702 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2178827 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2164479 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2164479 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2207950 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2207950 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2206807 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2206807 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2147325 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2147325 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2146090 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2146090 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2202243 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2202243 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2159677 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2181228 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2181228 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2199544 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2129089 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2147325 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2164479 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2144525 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2144525 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2202243 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2128282 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2146090 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2209153 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2209153 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2151087 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2151087 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2087849 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2087849 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2180084 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2194164 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2149424 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2149424 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2132295 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2086470 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2195833 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2195833 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2165986 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2210503 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2210503 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2209153 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2196487 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2196487 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2165986 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2174122 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2184751 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2136083 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2136083 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2175850 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2188260 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2169324 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2160157 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2160157 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2203464 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2203464 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2181228 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2148600 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2204612 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204612 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2149424 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2186550 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2180900 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2180900 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2149681 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2149681 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2152412 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2197834 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2197834 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2211485 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2211485 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2199276 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2199276 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2136083 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2144525 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2138501 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2138501 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2203464 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2147376 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2147376 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2204612 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2171804 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2171804 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2187796 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2187796 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2160157 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2159339 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2210355 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2175294 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2204800 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204800 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2191351 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2191351 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2134758 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2205738 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2205738 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2200117 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2200117 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2204001 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204001 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2142361 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2142361 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2171804 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2202345 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2197156 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2197156 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2196879 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2196879 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2151087 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2193240 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2204977 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2193240 [lua] hls
2017/05/09 21:36:43 [error] 143984#0: *2204977 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2189719 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2189719 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2141027 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2141027 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2165986 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2165986 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2122514 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2190219 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2190219 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2147376 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2098802 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2098802 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2156137 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2156137 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2142361 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2211167 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2205291 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2205291 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2192529 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2192529 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2097916 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2201800 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2201800 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2193020 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2193020 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2141139 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2136709 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2136709 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2159600 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2159600 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2156137 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2210052 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2210053 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2211168 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2211162 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2149892 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2159845 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2194944 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2194944 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2196511 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2206411 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2206411 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2211541 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2159261 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2211541 [lua] hls
2017/05/09 21:36:43 [error] 143984#0: *2159261 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2152418 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2152418 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2194275 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2209256 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2209256 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2208837 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2208837 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2185994 "\.m3u8"
2017/05/09 21:36:43 [info] 143984#0: *2210187 client pre
2017/05/09 21:36:43 [notice] 143984#0: *2136709 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2199994 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2199994 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2197135 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2197135 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2189288 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2189288 [lua] hls
2017/05/09 21:36:43 [info] 143984#0: *2208514 client 183
2017/05/09 21:36:43 [info] 143984#0: *2209467 client 183
2017/05/09 21:36:43 [notice] 143984#0: *2204658 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204658 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2159261 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2201943 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2201943 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2181340 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2197116 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2159600 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2162239 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2162239 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2188389 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2188389 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2203649 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2203649 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2209256 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2133678 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2189211 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2133678 [lua] hls
2017/05/09 21:36:43 [error] 143984#0: *2189211 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2208950 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2208950 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2204405 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204405 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2165986 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2200375 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2200375 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2168351 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2184419 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2184419 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2183669 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2183669 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2134644 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2162239 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2142432 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2142432 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2162247 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2162247 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2211574 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2197450 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2197450 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2180184 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2203913 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2203913 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2152418 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2202370 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2202370 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2142432 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2206880 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2206880 [lua] hls
2017/05/09 21:36:44 [notice] 143984#0: *2200453 "\.m3u8"

 

(2)Lua脚本日志写入:

if ( tonumber(res) == 0 or tonumber(res) == 1 ) then          -- 不是签名验证,则直接返回
   ngx.log(ngx.ERR, "error : 不是签名验证,则直接返回::res=== ",res)
    return
end

解决办法:立即关闭该日志的写入,重启nginx服务器 reload

【1】日志切割工具下载:http://soft.laozuo.org/tools/Knife4File.zip

【2】log日志查看工具:http://www.uvviewsoft.com/logviewer/files/LogViewerPro.zip

 

3、他们摄像头推流,直播结束后ffmpeg 进程一直在

4、是否针对播流权限认真是否取消掉?

答:暂时先取消掉

6、流状态列表查看(必须的联系他们的人员怎么处理),没有推流但是nginx服务状态一直存在

 解决方案:

修改nginx rtmp配置参数,添加这个参数:drop_idle_publisher 10s;

drop_idle_publisher
语法:drop_idle_publisher timeout
上下文:rtmp, server, application
描述:终止指定时间内闲置(没有音频/视频数据)的发布连接。默认为 off。注意这个仅仅对于发布模式的连接起作用(发送 publish 命令之后)。

 

二、性能优化技巧

1、设置worker_connections:10240

官方解释如下,个人认为是每一个worker进程能并发处理(发起)的最大连接数(包含所有连接数)。不能超过最大文件打开数:在linux终端中输入ulimit -a进行查看

www@ubuntu5:$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 126277
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 126277
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

 参考:linux ulimit命令调优系统参数

 2、编译安装过程优化

 

找到源码的这个文件 /nginx-1.10.3/auto/cc/gcc

# debug
CFLAGS="$CFLAGS -g"

不修改代码大小7.3M:

tinywan@tinywan:~/nginx-1.10.3/auto/cc$ ls -lh /usr/local/nginx/sbin/nginx
-rwxr-xr-x 1 root root 7.3M 3月  31 09:29 /usr/local/nginx/sbin/nginx

修改后的文件大小759K

tinywan@tinywan:~/nginx-1.10.3$ ls -lh /usr/local/nginx/sbin/nginx
-rwxr-xr-x 1 root root 759K 5月  10 14:35 /usr/local/nginx/sbin/nginx

 

查看CPU类型

tinywan@tinywan:~/nginx-1.10.3$ cat /proc/cpuinfo | grep "model name"
model name    : Intel(R) Core(TM) i3-4160 CPU @ 3.60GHz

 

 

 

 Nginx日志分割及自动删除超过30天日志

#!/bin/bash
# 分割nginx access日志脚本

time=`date +%Y%m%d`
logs_path="/usr/local/nginx/logs/"
pid_path="/usr/local/nginx/logs/nginx.pid"

#日志分割,按天创建文件夹
cd $logs_path
website=`ls $logs_path/access_* | xargs -n 1 | cut -f 2 -d "_"`
for i in $website
do
  mkdir -p $logs_path/backup/$time/
  mv $logs_path/access_$i $logs_path/backup/$time/$i
done
#向nginx主进程发信号重新打开日志
kill -USR1 `cat ${pid_path}`

#每月1日删除所有超过30天日志。
if [ "`date +%d`" = "01" ]; then
  all_list=`ls $logs_path/backup | xargs -n 1`
  for del in $all_list
  do
    let results=$time-$del
    if [ $results -gt 30 ]; then
      rm -rf $logs_path/backup/$del
    fi
  done
fi

注: /usr/local/nginx/logs/下的日志格式为access_domain1.log。

加入计划任务,每天大概0时分割日志:

58 23 * * * /data/script/nginx_logs.sh

 

 

 

 

 

 

 

 

时间: 2024-10-27 06:47:22

Nginx 服务器性能Bug和性能优化方案(真实经历)的相关文章

Linux VPS服务器内存不够用的优化方案

自从把我的一个网站搬家到linode 1G 的vps上后,总感觉有些不太正常.首先dnspod监控上显示网站有时能访问,有时不行.然后wp supercache插件在执行预缓存任务时经常失败后重启,邮件内容如"[http://www.111cn.net] 预缓存可能已失去响应.预缓存已经重新启动.".还有一个情况是linode有时会发来磁盘io使用高的报警邮件. 今天抽空检查了下服务器,发现一个现象是mysql进程频繁无故重启. 150424 17:41:14 [Note] Event

Nginx服务器配置性能优化方案_nginx

高层的配置nginx.conf文件中,Nginx中有少数的几个高级配置在模块部分之上. user www-data; pid /var/run/nginx.pid; worker_processes auto; worker_rlimit_nofile 100000; user和pid应该按默认设置 - 我们不会更改这些内容,因为更改与否没有什么不同. worker_processes 定义了nginx对外提供web服务时的worker进程数.最优值取决于许多因素,包括(但不限于)CPU核的数量

iSCSI性能瓶颈及性能优化方案

iSCSI性能瓶颈 &http://www.aliyun.com/zixun/aggregation/37954.html">nbsp;   iSCSI协议建立在传统的TCP/IP协议之上,在进行实际数据传输时,其传输系统性能受限于TCP/IP协议栈负载及以太网最大带宽,另外iSCSI协议层也会额外增加一些负载开销,在实际应用中,iSCSI数据传输性能仍然存在瓶颈.以发送端的写操作为例,一次完整的iSCSI协议数据传输包括数据封装.数据拷贝.数据传输三个步骤. 1.数据封装 iSC

Mysql性能优化方案分享_Mysql

网上有不少mysql 性能优化方案,不过,mysql的优化同sql server相比,更为麻烦,同样的设置,在不同的环境下 ,由于内存,访问量,读写频率,数据差异等等情况,可能会出现不同的结果,因此简单地根据某个给出方案来配置mysql是行不通的,最好能使用status信息对mysql进行具体的优化. mysql> show global status; 可以列出MySQL服务器运行各种状态值,另外,查询MySQL服务器配置信息语句:mysql> show variables; 一.慢查询 m

mysql 性能优化方案

网上有不少mysql 性能优化方案,不过,mysql的优化同sql server相比,更为麻烦与负责,同样的设置,在不同的环境下 ,由于内存,访问量,读写频率,数据差异等等情况,可能会出现不同的结果,因此简单地根据某个给出方案来配置mysql是行不通的,最好能使用status信息对mysql进行具体的优化,网上找了一篇文章,分页分得乱七八糟的,只能转到博客. mysql> show global status; 可以列出mysql服务器运行各种状态值,另外,查询mysql服务器配置信息语句: m

修改Linux内核参数提高Nginx服务器在高并发时的性能

并发 Linux下高并发的Nginx服务器,当TCP TIME_WAIT套接字数量经常达到两.三万,服务器很容易被拖死.通过修改Linux内核参数,可以减少Nginx服务器的TIME_WAIT套接字数量. vi /etc/sysctl.conf 增加以下几行: 引用 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse =

一些优化Nginx服务器的技巧简介

  这篇文章主要介绍了一些优化Nginx服务器的技巧简介,包括对HTTP模块和Events模块的配置建议,需要的朋友可以参考下 大多数的Nginx安装指南告诉你如下基础知识--通过apt-get安装,修改这里或那里的几行配置,好了,你已经有了一个Web服务器了!而且,在大多数情况下,一个常规安装的nginx对你的网站来说已经能很好地工作了.然而,如果你真的想挤压出nginx的性能,你必须更深入一些.在本指南中,我将解释Nginx的那些设置可以微调,以优化处理大量客户端时的性能.需要注意一点,这不

详解Nginx服务器中配置Sysguard模块预防高负载的方案_nginx

nginx做为HTTP服务器,有以下几项基本特性: 处理静态文件,索引文件以及自动索引:打开文件描述符缓冲. 无缓存的反向代理加速,简单的负载均衡和容错. FastCGI,简单的负载均衡和容错. 模块化的结构.包括gzipping, byte ranges, chunked responses,以及 SSI-filter等filter.如果由FastCGI或其它代理服务器处理单页中存在的多个SSI,则这项处理可以并行运行,而不需要相互等待. Nginx专为性能优化而开发,性能是其最重要的考量,实

Nginx服务器高性能优化的配置方法小结_nginx

通常来说,一个优化良好的 Nginx Linux 服务器可以达到 500,000 – 600,000 次/秒 的请求处理性能,然而我的 Nginx 服务器可以稳定地达到 904,000 次/秒 的处理性能,并且我以此高负载测试超过 12 小时,服务器工作稳定. 这里需要特别说明的是,本文中所有列出来的配置都是在我的测试环境验证的,而你需要根据你服务器的情况进行配置: 从 EPEL 源安装 Nginx: yum -y install nginx 备份配置文件,然后根据你的需要进行配置: cp /e