Prompt
How do I scale video calls to a large user base
Latest observation
Scaling video calls to a large user base is mostly about reducing how much media your infrastructure has to handle, and using the right architecture for the call size.
1) Pick the right media architecture
Small calls: Mesh
- Every participant sends media directly to every other participant.
- Simple, but bandwidth and CPU explode as users increase.
- Good only for very small calls, usually 2–4 people.
Medium to large calls: SFU
- Selective Forwarding Unit (SFU) is the standard approach for scalable video calls.
- Each client sends one uplink stream to the SFU.
- The SFU forwards streams to other participants without decoding/re-encoding.
- Benefits:
- Much lower server CPU than mixing/transcoding
- Better latency than MCU
- Supports adaptive quality per participant
Very large calls or broadcast-style: MCU or hybrid
- MCU mixes/transcodes streams into one or a few outputs.
- More server-heavy, but useful when clients are limited devices or when you need a single composite stream.
- Often used in hybrid setups:
- SFU for interactive participants
- separate broadcast pipeline for spectators
2) Use simulcast or scalable video coding
To handle varying network conditions and different subscriber needs:
- Send multiple quality layers from each client:
- low / medium / high
- SFU forwards the appropriate layer to each receiver.
- This avoids sending everyone high-res video all the time.
- Helps especially when many users are in the same call but not all need high quality.
3) Reduce unnecessary media
For large calls, do not treat all participants equally.
Common strategies:
- Active speaker only video at high quality
- Others stay thumbnail size or audio-only
- Subscribe on demand: only receive the streams currently visible on screen
- Pause video for off-screen participants
- Mute/stop video when idle
This can drastically reduce downstream bandwidth.
4) Separate signaling from media
Use a scalable signaling layer:
- WebSockets or WebRTC signaling server
- Stateless app servers where possible
- Store room state in Redis or another fast shared cache
- Use pub/sub for room events
Signaling is not the main bottleneck, but it must handle:
- room joins/leaves
- ICE candidate exchange
- reconnects
- permissions
- moderation events
5) Scale TURN/STUN infrastructure
For NAT traversal:
- STUN helps clients discover their public address
- TURN relays media when direct peer-to-peer connection fails
At scale:
- Deploy multiple TURN servers geographically
- Use load balancing and health checks
- Monitor relay usage carefully, since TURN can become expensive
- Prefer direct/SFU media paths whenever possible to limit relay load
6) Partition by geography and room placement
Latency matters a lot in real-time media.
Best practices:
- Deploy SFUs in multiple regions
- Place users in the nearest region
- Keep a room anchored to one region when possible
- Use geo-routing or region-based room assignment
- Avoid cross-region media forwarding unless necessary
If you need global rooms, consider:
- regional SFUs with a backbone for cross-region distribution
- separate “primary” region for media mixing or coordination
7) Use adaptive bitrate and congestion control
Your system should automatically adjust to network conditions:
- Lower resolution/frame rate on poor networks
- Reduce bitrate when congestion is detected
- Prefer audio continuity over perfect video quality
- Implement client-side adaptation with WebRTC congestion control
This improves reliability and reduces infrastructure load.
8) Keep server CPU and memory under control
On SFU nodes:
- Avoid decoding/re-encoding whenever possible
- Use efficient packet forwarding
- Limit per-node participant counts
- Monitor:
- CPU
- NIC bandwidth
- packet loss
- jitter
- RTT
- memory
- file descriptors
Capacity planning matters:
- Bandwidth is often the first bottleneck
- Then NIC/interrupt handling
- Then CPU for packet forwarding and encryption overhead
9) Design for horizontal scaling
You want to add more nodes, not bigger boxes forever.
Typical pattern:
- Stateless API servers behind a load balancer
- Shared session/room registry
- SFU nodes assigned per room
- Autoscaling based on bandwidth and CPU
- Health-aware room placement and migration strategy
Important: migrating an active room is hard, so try to place rooms carefully from the start.
10) Optimize client behavior
The client can reduce load significantly:
- Show fewer remote videos at once
- Dynamically request only visible tiles
- Use lower resolution thumbnails
- Stop rendering hidden streams
- Enable hardware encoding/decoding when available
- Use efficient codecs like VP8, H.264, or AV1 depending on support and cost
11) Watch codec and device tradeoffs
Codec choice affects cost and compatibility:
- H.264: widely supported, good compatibility
- VP8/VP9: common in WebRTC, moderate efficiency
- AV1: better compression, but higher encode cost and limited support on some devices
For scale, codec decisions affect:
- client CPU
- server transcode needs
- bandwidth usage
- compatibility across browsers/devices
12) Instrument everything
You cannot scale what you can’t see.
Track:
- call setup time
- join success rate
- media start time
- packet loss
- jitter
- bitrate
- ICE success/failure rate
- TURN usage
- CPU/bandwidth per SFU
- room occupancy
- reconnect rates
- QoE metrics
Use this data to:
- detect hotspots
- tune autoscaling
- choose room placement
- identify bad ISP/region performance
13) Plan for failure
At scale, failures are normal.
Have:
- server health checks
- automatic room reassignment for new joins
- reconnect logic
- fallback audio-only mode
- degraded mode when overloaded
- graceful shutdown for draining SFU nodes
- retry and backoff for signaling
Practical recommendation
If you’re building a production video platform, the usual path is:
- Use WebRTC
- Use SFU architecture
- Enable simulcast
- Only forward visible/active streams
- Deploy SFUs in multiple regions
- Use TURN sparingly and monitor it
- Autoscale based on real-time metrics
- Instrument QoE deeply
If you want, I can also help with:
- a reference architecture diagram
- a capacity planning example
- choosing between SFU vs MCU
- a tech stack recommendation for your scale target
Brands