WebRTC & Real-Time Media: Signaling, STUN/TURN and SFUs

Networking
35 / 47

Video calls send audio and video peer-to-peer over UDP. A signaling server only introduces the peers; STUN/TURN get around NATs; for groups, a media server (SFU) relays streams.

The Analogy (Read This First)

Signaling is the phone operator who connects two callers and then hangs up; the callers talk directly. TURN is the operator staying on the line to relay when the callers cannot reach each other.

Deep Dive Analysis

Why not just HTTP. Calls need low latency more than perfect delivery: a lost video frame is skipped, not resent. That is why media uses UDP (via SRTP) and why a late packet is worth less than a missing one. TCP's retransmission would add exactly the delay you are trying to avoid.

Signaling. Before two browsers can talk they must exchange: who is calling whom, which codecs each supports (an SDP offer/answer), and network addresses (ICE candidates). WebRTC does not define how; you build a signaling service, typically WebSocket-based. It carries tiny messages, is not on the media path, and is the part you must scale and secure yourself.

NAT is the real obstacle. Most devices sit behind routers with private addresses. ICE tries paths in order of cost: a direct local connection, then a STUN-discovered public address (the STUN server just says 'here is the address I see you at'), and finally TURN, a relay that forwards all media when no direct path exists (symmetric NATs, strict firewalls). TURN costs bandwidth, so plan for the share of calls that need it (often 10-20%).

Group calls: mesh vs MCU vs SFU. In a mesh, everyone connects to everyone: N-1 uploads per person, fine for 3-4, hopeless beyond that. An MCU decodes everyone and mixes one stream: easy for clients, but very CPU-heavy on the server. An SFU (selective forwarding unit) receives each participant's single upload and forwards it to the others without decoding: the standard for Zoom-like products.

Adapting to bad networks. Participants send simulcast (the same video at 3 qualities); the SFU forwards the layer each receiver can handle and switches as bandwidth changes. Congestion control lowers the bitrate before packets are dropped. This is why calls get blurry instead of freezing.

Scaling an SFU. One SFU handles a few hundred participants. Large meetings cascade SFUs (clients connect to the nearest one, which relays to others) and place servers close to users, because every extra 100 ms of distance is audible. A room is pinned to one or a few SFUs, so the control plane assigns rooms to servers.

Webinars vs meetings. Thousands of viewers and a few speakers are not a call: the speakers' streams go to an SFU, then to a CDN-style fan-out, accepting a few seconds of delay. Choose by interactivity: sub-second means WebRTC, a few seconds means HLS/DASH at CDN scale.

Recording and chat. Recording is a separate subscriber that joins the room and writes to object storage; chat and presence ride the signaling channel. Authenticate every join with a short-lived token.

Key Bullets
  • Media goes over UDP; losing a frame beats delaying it.
  • Signaling (SDP + ICE) is your service; it is not on the media path.
  • STUN discovers your public address; TURN relays when direct fails - budget for it.
  • SFU forwards without decoding; mesh does not scale, MCU is expensive.
  • Simulcast lets each receiver get the quality its network can take.
Trade-offs
Mesh: no server cost | Upload bandwidth grows with each participantSFU: scales to large rooms cheaply | Clients must decode several streamsMCU: one simple stream per client | Server CPU grows with room size
Real-World Examples
A 1-to-1 video call with a TURN fallbackA 50-person video meetingA 10,000-viewer webinar that tolerates a few seconds of delay

Curated Curation & Deep Insights

ScaleDojo Certified
Video Tutorial Pending

Our system architects are vetting high-quality, authorized video guides for WebRTC & Real-Time Media: Signaling, STUN/TURN and SFUs with zero third-party platform links.

Verification in Progress
Reading Material Pending

We are preparing premium, zero-competitor deep-dives for WebRTC & Real-Time Media: Signaling, STUN/TURN and SFUs. Authorized reading references will appear automatically.

Verification in Progress