Lesson 7 of 9 · 27m
Mesh vs SFU Architecture
Choose between full-mesh peer connections and selective forwarding by modeling CPU, bandwidth, layout flexibility, recording, and moderation requirements.
The architecture question is not "what does WebRTC support?" WebRTC supports peer connections. The question is who receives whose media, how many times it is encoded, where bandwidth is spent, and who has enough authority to moderate or record. Mesh is seductive because it starts simple. SFU is unavoidable because physics does not care about your demo.
Mesh means every sender talks to every receiver
In a four-person mesh call, each participant creates three peer connections and encodes uploads for all of them:
A <-> B
A <-> C
A <-> D
B <-> C
B <-> D
C <-> DPeer connections grow as n(n-1)/2. Each browser encodes video once per peer connection or at least manages separate transport paths. Even if simulcast helps a bit, uplink quality and CPU become the first walls. On mobile, thermal throttling arrives before your sixth participant.
An SFU forwards media without mixing it
A Selective Forwarding Unit terminates each participant's WebRTC transport, then forwards selected RTP streams onward:
participant A ──publish──┐
participant B ──publish──┼──> SFU ──subscribe──> participants
participant C ──publish──┘The SFU does not decode and re-encode every stream the way an MCU does. It forwards packets, rewrites headers as needed, manages congestion feedback, chooses layers, and enforces subscription policy. This scales fan-out because each participant usually uploads once and downloads the streams they need.
Choose from requirements, not ideology
2-4 users, ephemeral, low infra mesh can be rational
5+ users, mobile clients SFU usually required
recording/transcription server-side media access required
large webinar SFU plus simulcast or forwarding tree
strict E2EE mesh or SFU with Insertable Streams design
server moderation SFU or trusted media control planeAn MCU is a different beast: it decodes, mixes, and re-encodes into composite streams. That simplifies clients but centralizes CPU cost and destroys per-participant layout flexibility. Most modern conferencing uses SFU forwarding, not MCU composition.
The SFU is still inside the security boundary
A plain SFU can see RTP headers and potentially decrypt media depending on keying design. It must authenticate publishers, authorize subscriptions, enforce room membership, implement rate limits, and resist RTP injection. A conference server is not just a packet hose; it is a privileged media router.
A typical authorization matrix looks like:
participant token + room capability -> may publish audio/video
screen-share capability -> may publish screen track
viewer token -> subscribe only
moderator token -> mute, eject, lock, end
recorder identity -> subscribe to recording setOperational topology matters
One SFU process is easy. Twenty rooms across continents are not. Media quality depends on physical distance, packet loss, and jitter. Production systems route users to regional SFUs, cascade between SFUs when needed, and drain nodes during deploys. Cascading multiplies complexity because a room is no longer one process; it is a distributed forwarding graph.
Mesh and SFU failure modes differ
Mesh failures are often client-side: CPU, uplink, browser memory, and peer fan-out. SFU failures are often concentrated: capacity exhaustion, bad deploy, congestion control bug, or regional network incident. Concentrated failure is operationally scary but measurable and fixable. Distributed client collapse is diffuse and harder to support.
Field notes
- A mesh call with
nparticipants does not mean exactly one encode per peer in every implementation, but uplink and connection complexity still scale badly. - Recording an SFU-forwarded call requires explicit server access or a recording participant; it does not happen magically because media passes nearby.
- TURN is still necessary with an SFU. The SFU is just another endpoint as far as restrictive networks are concerned.
- End-to-end encryption through an SFU requires careful key distribution and Insertable Streams or equivalent transforms; simply adding TLS to signaling does not make media end-to-end encrypted.
Was this lesson helpful?