1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

SmartPtr: Support load test for source by srs-bench. v6.0.130 (#4097)

1. Add live benchmark support in srs-bench, which only connects and
disconnects without any media transport, to test source creation and
disposal and verify source memory leaks.
2. SmartPtr: Support cleanup of HTTP-FLV stream. Unregister the HTTP-FLV
handler for the pattern and clean up the objects and resources.
3. Support benchmarking RTMP/SRT with srs-bench by integrating the gosrt
and oryx RTMP libraries.
4. Refine SRT and RTC sources by using a timer to clean up the sources,
following the same strategy as the Live source.

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
Co-authored-by: Jacob Su <suzp1984@gmail.com>
This commit is contained in:
Winlin 2024-06-21 07:13:12 +08:00 committed by GitHub
parent e3d74fb045
commit 1f9309ae25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
508 changed files with 6805 additions and 3299 deletions

View file

@ -14,6 +14,8 @@ git clone -b feature/rtc https://github.com/ossrs/srs-bench.git &&
cd srs-bench && make
```
> Note: 依赖Go编译工具建议使用 Go 1.17 及以上的版本。
编译会生成下面的工具:
* `./objs/srs_bench` 压测模拟大量客户端的负载测试支持SRS、GB28181和Janus三种场景。
@ -33,7 +35,7 @@ cd srs/trunk && ./configure --h265=on --gb28181=on && make &&
具体场景,请按下面的操作启动测试。
## Player for Live
## Player for WHEP
直播播放压测,一个流,很多个播放。
@ -49,7 +51,7 @@ ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/
./objs/srs_bench -sr webrtc://localhost/live/livestream -nn 100
```
## Publisher for Live or RTC
## Publisher for WHIP
直播或会议场景推流压测,一般会推多个流。
@ -63,7 +65,7 @@ ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/
> 注意帧率是原始视频的帧率由于264中没有这个信息所以需要传递。
## Multipel Player or Publisher for RTC
## Multiple WHIP or WHEP for RTC
会议场景的播放压测会多个客户端播放多个流比如3人会议那么就有3个推流每个流有2个播放。
@ -84,7 +86,7 @@ ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/
> 备注URL的变量格式参考Go的`fmt.Sprintf`,比如可以用`webrtc://localhost/live/livestream_%03d`
<a name="dvr"></a>
## DVR for Benchmark
## DVR for RTC Benchmark
录制场景,主要是把内容录制下来后,可分析,也可以用于推流。
@ -120,6 +122,37 @@ ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/
> Note: 可以传递更多参数详细参考SRS支持的参数。
## Reconnecting Load Test
建立连接和断开重连的压测可以测试SRS在多个Source时是否有内存泄露问题参考 [#3667](https://github.com/ossrs/srs/discussions/3667#discussioncomment-8969107)
RTMP重连测试
```bash
for ((i=0;;i++)); do
./objs/srs_bench -sfu=live -pr=rtmp://localhost/live${i}/stream -sn=1000 -cap=true;
sleep 10;
done
```
SRT重连测试
```bash
for ((i=0;;i++)); do
./objs/srs_bench -sfu=live -pr='srt://127.0.0.1:10080?streamid=#!::'m=publish,r=live${i}/stream -sn=1000 -cap=true;
sleep 10;
done
```
WebRTC重连测试
```bash
for ((i=0;;i++)); do
./objs/srs_bench -sfu=rtc -pr=webrtc://localhost/live${i}/livestream -sn=1000 -cap=true;
sleep 10;
done
```
## Regression Test
回归测试需要先启动[SRS](https://github.com/ossrs/srs/issues/307)支持WebRTC推拉流
@ -329,4 +362,50 @@ make -j10 && ./objs/srs_bench -sfu janus \
-nn 5
```
## Install LIBSRT
我们使用 [srtgo](https://github.com/Haivision/srtgo) 库测试SRT协议需要安装libsrt库
参考[macOS](https://github.com/Haivision/srt/blob/master/docs/build/build-macOS.md)
```bash
brew install srt
```
如果是Ubuntu可以参考[Ubuntu](https://github.com/Haivision/srt/blob/master/docs/build/package-managers.md):
```bash
apt-get install -y libsrt
```
安装完libsrt后直接编译srs-bench即可
```bash
make
```
## Ubuntu Docker
如果使用Ubuntu编译推荐使用 `ossrs/srs:ubuntu20` 作为镜像编译已经编译了openssl和libsrt启动容器
```bash
docker run --rm -it -v $(pwd):/g -w /g ossrs/srs:ubuntu20 make
```
## GoLand
使用GoLand编译和调试时需要设置libsrt的环境变量首先可以使用brew获取路径
```bash
brew --prefix srt
#/opt/homebrew/opt/srt
```
然后在GoLand中编辑配置 `Edit Configurations`,添加环境变量:
```bash
CGO_CFLAGS=-I/opt/homebrew/opt/srt/include;CGO_LDFLAGS=-L/opt/homebrew/opt/srt/lib -lsrt
```
> Note: 特别注意的是CGO_LDFLAGS是可以有空格的不能使用字符串否则找不到库。
2021.01, Winlin