Peer-to-peer
Two browsers, one negotiated path.
A single peer connection carries media and data directly between two participants. TURN may still relay the media when the network demands it, but there is no media server decoding or forwarding the session.
- Room size
- 2 people
- Latency
- Lowest
- Client upload
- Moderate
- Client CPU
- Moderate
- Server cost
- None
- Complexity
- Low
How it works
- 01
Each peer captures its local tracks and adds them to one RTCPeerConnection. Signaling exchanges a single offer and answer, then ICE discovers a pair and DTLS secures the transport.
- 02
Media is encoded once per sender and sent to the other browser. If the path is direct, no application server sees the media payload. If ICE selects a TURN relay, traffic is forwarded but not decoded.
- 03
The room service is still server-assisted: signaling, authorization, TURN credentials, and presence are control-plane responsibilities. The media path being peer-to-peer does not remove those services.
- 04
For a third participant, P2P stops being the topology and becomes mesh: every participant needs a connection to every other participant.
Bandwidth & cost math
Per-participant upload
One encoded stream, assuming one video and one audio track.
upload ≈ video bitrate + audio + overhead
Per-participant download
One stream from the other peer.
download ≈ remote video bitrate + audio + overhead
Server media egress
Zero for a direct path; TURN egress applies when the relay is selected.
TURN egress ≈ upload + download
Strengths
- Lowest architectural latency: no media server hop in the direct path.
- Simplest media-plane design and the cheapest to operate when paths are direct.
- Natural fit for private conversations and the first milestone of any WebRTC product.
- TURN remains a narrow, well-understood fallback for restrictive networks.
Limits
- Does not scale beyond two participants without becoming mesh.
- Connectivity depends on NAT/firewall conditions unless TURN is available.
- No server-side recording, transcription, or moderation without adding a participant.
- A peer can see the other peer's public network address unless relay-only privacy mode is used.
Use it when
Do
- Ship TURN with P2P
- Direct connect is an outcome, not a guarantee. Without TURN, a meaningful share of real networks will fail.
- Separate signaling from media health
- A signaling reconnect should not tear down an established peer connection.
- Offer relay-only privacy mode
- If address privacy matters, use iceTransportPolicy: relay and verify the selected pair.
Don't
- Don't call the whole product peer-to-peer
- Signaling, TURN, rooms, and observability are server-side even when media is direct.
- Don't add a third participant to P2P
- That is mesh. Model the connection count and upload cost before the room grows.
- Don't skip cleanup
- Closing the connection is not enough; stop every local track and clear permissions UI state.
Reference implementations