rtmp拉流性能测试
夏楚 edited this page 2022-05-18 21:29:27 +08:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

一、测试环境

  • 测试日期2022/5/18
  • 代码版本git hash: c7d7999f
  • cpu Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
  • 操作系统CentOS release 6.3 (Final)
  • 内存16GB
  • 网卡127.0.0.1
  • 测试码流: 200kbps.768x320.flv
  • 编译器gcc (GCC) 8.2.0
  • zlmediakit编译类型Release
  • malloc库ptmalloc(未开启jemalloc)
  • config.ini配置文件修改(主要开启合并写、按需转协议)
diff --git a/conf/config.ini b/conf/config.ini
index c2d4613f..99ce5c84 100644
--- a/conf/config.ini
+++ b/conf/config.ini
@@ -51,12 +51,12 @@ addMuteAudio=1
 #如果不删除将会接着上一次的数据继续写(录制hls/mp4时会继续在前一个文件后面写)
 resetWhenRePlay=1
 #是否默认推流时转换成hlshook接口(on_publish)中可以覆盖该设置
-publishToHls=1
+publishToHls=0
 #是否默认推流时mp4录像hook接口(on_publish)中可以覆盖该设置
 publishToMP4=0
 #合并写缓存大小(单位毫秒)合并写指服务器缓存一定的数据后才会一次性写入socket这样能提高性能但是会提高延时
 #开启后会同时关闭TCP_NODELAY并开启MSG_MORE
-mergeWriteMS=0
+mergeWriteMS=300
 #全局的时间戳覆盖开关在转协议时对frame进行时间戳覆盖
 #该开关对rtsp/rtmp/rtp推流、rtsp/rtmp/hls拉流代理转协议时生效
 #会直接影响rtsp/rtmp/hls/mp4/flv等协议的时间戳
@@ -72,15 +72,15 @@ enable_audio=1
 ###### 如果某种协议你想获取最好的用户体验请置0(第一个播放者可以秒开,且不花屏)

 #hls协议是否按需生成如果hls.segNum配置为0(意味着hls录制)那么hls将一直生成(不管此开关)
-hls_demand=0
+hls_demand=1
 #rtsp[s]协议是否按需生成
-rtsp_demand=0
+rtsp_demand=1
 #rtmp[s]、http[s]-flv、ws[s]-flv协议是否按需生成
-rtmp_demand=0
+rtmp_demand=1
 #http[s]-ts协议是否按需生成
-ts_demand=0
+ts_demand=1
 #http[s]-fmp4、ws[s]-fmp4协议是否按需生成
-fmp4_demand=0
+fmp4_demand=1
  • 推流命令:
ffmpeg -stream_loop -1 -re -i ~/Downloads/source.200kbps.768x320.flv -acodec copy -vcodec copy -f flv  rtmp://ip:port/live/test

二、rtmp拉流性能测试(1万路)

  • 拉流命令:
#加大文件描述符个数
ulimit -n 102400
#启动1万个rtmp拉流
./test_bench_pull -c 10000 -i rtmp://127.0.0.1/live/test
  • top信息

图片

  • perf top信息

图片

  • nload信息(平均2.34Gb/s)

图片

三、rtmp拉流性能测试(3万路)

  • 拉流命令:
#加大文件描述符个数
ulimit -n 102400
#启动1万个rtmp拉流
./test_bench_pull -c 30000 -i rtmp://127.0.0.1/live/test
  • top信息

图片

  • perf top信息

图片

  • nload信息(平均7.09Gb/s)

图片