Search code examples
webrtcsfu

WebRTC SFU for data channels


Does SFU apply to data channels as well?

As I understand it, it doesn't offer any advantage besides moving the broadcasting of messages to the central SFU (and having just one peer connection).

As I understand it now:

  • without SFU -> send N messages to all N peers through N RTCDataChannels
  • with SFU -> send 1 message to the SFU, then the SFU broadcasts that message to all other N - 1 peers.

Thus, moving the broadcasting of messages from the local peer, to the "remote" SFU. Is this right? And if so, what benefits does this offer?


Solution

  • A SFU has the same advantages for DataChannels as it does for RTP.

    • Reduce network load on the sender. Instead of uploading your message n times you send it once, and SFU handles replication.

    • Reduce CPU load on the sender. The sender only has to one run SCTP Association. It doesn't have to spin up all the threads for each individual congestion controller etc..

    • Reduced distance to peers. Most SFUs are actually made up of a fleet of servers. Each peer connects to the closest SFU geographically to give better round trip times. Senders and Receivers can more quickly respond to loss and other issues.

    • Privacy. Users may not want to establish a direction connection/expose their IP address.

    • Insight. When running a SFU you get more insight into your users sessions. I can isolate if the issue was the sender or receiver. A P2P mesh is harder to debug/reproduce issues.