WebRTC Video Conferencing (Zoom)
Understand the architectural components of video conferencing systems like Zoom. Follow call signaling, STUN/TURN network traversal, Mesh vs. SFU vs. MCU topologies
Continue with the guided workspace
Use the paired workspace to connect this guide's mental model with live component state, visible signals, and the outcome each step or scenario is meant to prove.
A real-time video conferencing system like Zoom must move audio and video between participants with sub-second latency over unpredictable home networks. It does this with a signaling layer to set up the call, NAT traversal (STUN/TURN) to punch through home routers, Selective Forwarding Units (SFUs) to route media streams, and simulcast plus bandwidth adaptation so each receiver gets the best resolution its connection can sustain.
Mental Model
Think of WebRTC video conferencing like setting up a multi-person phone call. First, you need an operator (Signaling Server) to exchange phone numbers (SDP/ICE) so everyone knows how to reach each other. If peers are behind home firewalls (NAT), they ask a public directory (STUN) for their public address. If they are behind a strict corporate security wall, they canβt connect directly; they must route calls through a paid relay operator (TURN). For the meeting layout, you can either call everyone directly (Mesh), send your feed to a central forwarder who passes copies around (SFU), or send your feed to a TV studio that mixes everyone into one split-screen video before sending it back (MCU).
Concept Flow
graph TD
A[WebSocket Signaling Server] -->|Exchange SDP & ICE| B[Client A]
A -->|Exchange SDP & ICE| C[Client B]
B -->|Binding Query| D[STUN Server]
C -->|Binding Query| D
B -->|Fallback Media Relay| E[TURN Server]
C -->|Fallback Media Relay| E
B -->|Media Uplink| F[SFU Media Server]
F -->|Forwarded Downlinks| C
Components and Why They Exist
WebSocket Signaling Server
The WebSocket signaling server coordinates initial peer discovery and session negotiation out-of-band before media streaming begins. During call setup, connection metadata packets route through this signaling server to exchange Session Description Protocol (SDP) offers and answers along with ICE network candidates between participant devices.
STUN Server
The STUN server helps client devices discover their public-facing IP addresses and ports behind home NAT routers. Each client queries the STUN server with a UDP binding request to learn its reflexive public NAT mapping before attempting direct peer-to-peer connectivity.
TURN Server
The TURN server acts as a fallback media relay when strict Symmetric NAT firewalls block direct UDP connectivity. Whenever direct peer paths are blocked, encrypted UDP/SRTP media packets route through the TURN relay server so isolated participants can still join the call.
SFU (Selective Forwarding Unit)
The Selective Forwarding Unit (SFU) routes multi-party conference streams efficiently with low server CPU overhead and a single upload per publisher. It ingests single simulcast uplinks from each participant and selectively forwards the appropriate quality layer down to each subscriber according to their available bandwidth.
MCU (Multipoint Control Unit)
The Multipoint Control Unit (MCU) minimizes subscriber download bandwidth and client decoding load by mixing all video feeds on the server. It decodes every incoming participant stream, merges them into a single composite grid layout, and sends one re-encoded stream out to each viewer.
Edge Cases and Misconceptions
- P2P is Not Always Free: A common misconception is that WebRTC is entirely peer-to-peer and incurs no server hosting costs. In real-world environments, up to 20% of calls fail direct connection checks and must route through TURN servers, creating substantial network bandwidth fees.
- SFU vs. MCU Client Constraints: While an SFU is cheap to host, it forces the viewer clientβs device to decode separate incoming video streams simultaneously. For large calls, this heats up mobile devices and drains batteries rapidly. MCUs keep client CPU cool by doing the compositing work on the server side.
- Encryption Limits Server Features: When End-to-End Encryption (E2EE) is enabled, media packets are encrypted using SRTP. Since SFUs only route encrypted ciphertext without decrypting it, the server cannot perform advanced features like active speaker detection (via audio volume analysis), server-side virtual backgrounds, or composite recording.
Common Questions
What is the difference between Mesh, SFU, and MCU?
Mesh connects peers directly (high client load, low server cost). SFU forwards streams unaltered (low client upload, O(N) client download). MCU mixes all streams into one composite layout (low client download, high server CPU cost).
Why do we need both STUN and TURN?
STUN resolves public IP mappings for peers behind normal NATs to enable P2P. TURN is a relay server fallback used when strict Symmetric NATs block direct peer connections.
How does Simulcast solve bandwidth constraints?
The publisher encodes three different quality tiers simultaneously. The SFU dynamically drops high-quality layers for congested subscribers to prevent video freezes.
What role does the signaling server play in WebRTC?
It negotiates connection configurations (SDP offers/answers) and network locations (ICE candidates) between peers via WebSockets before the media stream starts.
Is the video data encrypted in Zoom-like systems?
Yes, media streams are encrypted end-to-end at the application boundary using SRTP. In E2EE mode, even media servers like SFUs only route encrypted ciphertext without decrypting it.
How does signaling choose a media server?
WebRTC media does not move through HTTP 301/302 redirects. The signaling layer negotiates an SFU or TURN endpoint based on region, capacity, and connectivity, then the peers establish their UDP/SRTP path through ICE.
What is a WebRTC ICE Candidate?
An ICE (Interactive Connectivity Establishment) candidate represents a potential network path (IP address, port, and protocol) that the client browser can use to receive media. The client generates multiple candidates (local interface IPs, STUN-resolved public IPs, and TURN-relay IPs) and shares them with the peer via signaling.
How does Simulcast prevent video freezes on low-bandwidth connections?
In a Simulcast setup, the publisher uploads three distinct resolution tracks (e.g., 180p, 360p, 720p) simultaneously. If a subscriber's downstream network congests, the SFU stops sending the heavy 720p stream and dynamically switches to the 180p stream, maintaining audio-video continuity at the cost of resolution.