Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebRTC: Server Concurrent Performance Configuration Adjustment #3206

Closed
jayy1943 opened this issue Oct 10, 2022 · 1 comment
Closed

WebRTC: Server Concurrent Performance Configuration Adjustment #3206

jayy1943 opened this issue Oct 10, 2022 · 1 comment
Assignees
Labels
Discussion Discussion or questions. TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC. Won't fix We won't fix it.

Comments

@jayy1943
Copy link

jayy1943 commented Oct 10, 2022

Note: Please read FAQ before file an issue, see 2716

Note: Before asking a question, please refer to the FAQ, specifically 2716.

Description (描述)

Please describe your issue here (描述你遇到了什么问题)
Make sure to maintain the markdown structure.

  1. SRS Version (版本): 4.0.257
    Make sure to maintain the markdown structure.

  2. SRS Log (日志):
    Make sure to maintain the markdown structure.

None.  
Make sure to maintain the markdown structure.
  1. SRS Config (Configuration):
    Make sure to maintain the markdown structure.
# the config for srs to delivery hls
# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleHLS
# @see full.conf for detail config.

listen              1935;
max_connections     60000;
daemon              off;
srs_log_tank        file;
srs_log_level       warn;
srs_log_file        ./objs/data/srs.log;

http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
rtc_server {
    enabled on;
    listen 8000;
    candidate $CANDIDATE;
}

vhost __defaultVhost__ {
    min_latency     on;
    play  {
        gop_cache on;
        queue_length    10;
        atc             on;
        mix_correct     on;
    }
    hls {
        enabled         on;
        hls_fragment    1.2;
        hls_window      4.8;
        hls_wait_keyframe on;
        hls_cleanup     on;
        hls_dispose 120;
        hls_path        ./objs/nginx/html;
        hls_m3u8_file   [app]/[stream].m3u8;
        hls_ts_file     [app]/[stream]-[seq].ts;
    }
    http_remux {
        enabled on;
        mount       [vhost]/[app]/[stream].flv;
    }

    rtc {
        enabled on;
        rtmp_to_rtc on;
        rtc_to_rtmp off;
        nack on;
        twcc on;
    }
}

Replay (重现)
Make sure to maintain the markdown structure.

Please describe how to replay the bug? (重现Bug的步骤)
Make sure to maintain the markdown structure.

I would like to understand the factors affecting the concurrent performance of WebRTC multi-stream playback:

  1. Push a 1080p FLV stream with H264+AAC codecs to an RTMP port using FFmpeg, with a bitrate of approximately 4Mbps. Check the server resource usage, which occupies around 6.3% of the CPU. Then, simultaneously pull 9 WebRTC streams and observe that the CPU usage increases to nearly 30%. Calculating it, each stream consumes approximately 2.5% of the CPU.

  2. Push a 480p FLV stream with H264+AAC codecs to an RTMP port using FFmpeg, with a bitrate of approximately 1Mbps. Check the server resource usage, which occupies around 4% of the CPU. Then, simultaneously pull 9 WebRTC streams and observe that the CPU usage increases to approximately 12%. Calculating it, each stream consumes approximately 1% of the CPU.

  3. Use the built-in WebRTC streaming feature of SRS (https://localhost/demos/room.html?autostart=true) to directly push a stream from the camera. The resolution should be 320x240. Check the server resource usage, which occupies around 1.7% of the CPU. Then, simultaneously pull 9 WebRTC streams and observe that the CPU usage increases to approximately 6.7%, peaking at 8%. Each stream consumes approximately 0.5% of the CPU.

The server used for the experiment has the following CPU: Intel(R) Xeon(R) Silver 4210R CPU @ 2.40GHz.

I would like to ask the following questions. Thank you very much!

  1. Is it a mechanism of WebRTC itself that requires a fixed amount of CPU consumption for each stream, regardless of whether it is pushing or pulling? From the experiments, it seems to be related to the resolution and bitrate of the pushed stream. Is the main consumption in the protocol transcoding from RTMP to WebRTC (including AAC to Opus transcoding)?

  2. If using WebRTC directly, does it also involve transcoding? Is it possible to achieve no transcoding at all, or do you have any optimization suggestions? I have tried setting TWCC to "off," but there was no significant difference.

Expect (Expected Behavior)

Please describe your expectation (Describe what you expect to happen)

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Oct 10, 2022

The performance loss of WebRTC will be greater than live streaming. For details, you can refer to the previous article on SRS performance optimization.

If WebRTC is enabled for RTMP conversion, there will be transcoding for AAC and Opus. You can disable rtmp_to_rtc and rtc_to_rtmp.

SRS does not use particularly complex WebRTC algorithms, so other configurations have little impact. Even so, the RTC performance of SRS is much lower compared to live streaming.

The performance of RTC is basically unsolvable, and the best solution is to use horizontal scaling. Please refer to #3138 for more information.

TRANS_BY_GPT3

@winlinvip winlinvip self-assigned this Oct 10, 2022
@winlinvip winlinvip changed the title [咨询]webrtc:服务端并发性能 WebRTC: 服务端并发性能配置调整 Oct 10, 2022
@winlinvip winlinvip added WebRTC WebRTC, RTC2RTMP or RTMP2RTC. Discussion Discussion or questions. Won't fix We won't fix it. labels Oct 10, 2022
@winlinvip winlinvip changed the title WebRTC: 服务端并发性能配置调整 WebRTC: Server Concurrent Performance Configuration Adjustment Jul 29, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Discussion or questions. TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC. Won't fix We won't fix it.
Projects
None yet
Development

No branches or pull requests

2 participants