Design video conferencing (Zoom / Google Meet)
The interviewer asks
“Design a video conferencing service like Zoom or Google Meet. Users join meetings of 2 to 300 people with audio, video and screen sharing; it must feel real-time (low delay) even when some participants are on weak mobile networks.”
What a strong answer looks like
A strong answer separates the control plane from the media plane. The control plane (signalling over WebSocket, meeting service, auth) sets up who is in which room and negotiates sessions with SDP. The media plane uses WebRTC over UDP through Selective Forwarding Units (SFUs): each client uploads its streams once and the SFU forwards packets to others without decoding them. Simulcast or SVC lets the SFU send each viewer the quality that fits their bandwidth and layout. STUN/TURN handles NATs and firewalls. The deep dives are why SFU beats mesh and MCU, how bandwidth adaptation works, how to place and cascade SFUs across regions for global meetings, and what latency budget real-time media needs (under ~150 ms one way for natural conversation).
Concepts to mention
1 Requirements
Functional
- Create and join meetings by link, with waiting room and host controls (mute, remove)
- Audio and video for up to 300 participants, with gallery and active-speaker layouts
- Screen sharing
- In-meeting chat and reactions
- Cloud recording of meetings
- Join from browser, desktop and mobile apps, and dial-in by phone (PSTN)
Non-functional
- Mouth-to-ear latency under ~150-200 ms within a region; under ~300 ms across continents
- Join time under 3 s
- Audio must survive 10-20% packet loss and low bandwidth (as low as ~50 kbps for audio-only)
- 1M concurrent meetings, ~10M concurrent participants at peak
- 99.99% availability; a single media server failure should only cause a brief reconnect
Out of scope (say it out loud)
- Webinars with 10,000 view-only attendees (would use live streaming, mention only)
- Calendar integration and scheduling
- AI transcription details (mention as extension)
2 Estimates
3 API
| Endpoint | What it does |
|---|---|
POST/v1/meetings | Create a meeting; returns meeting_id, join link, settings |
POST/v1/meetings/{id}/join | Authenticate, check waiting room, assign an SFU and return a signalling URL, TURN credentials and a short-lived media token |
WS/signal/{meeting_id} | Signalling: SDP offer/answer, ICE candidates, participant join/leave, mute state, layout and subscription changes |
UDP (SRTP)SFU media ports | Encrypted RTP/RTCP media over DTLS-SRTP; RTCP carries loss and bandwidth feedback |
POST/v1/meetings/{id}/recordings | Start or stop cloud recording |
POST/v1/meetings/{id}/participants/{pid}/mute | Host control |
4 Data model
meetingsPostgresmeeting_id (PK)host_idtitlesettings (waiting room, passcode)created_atstatusRelational and low volume relative to media.
room stateRedis (per-region)meeting_id → assigned SFU(s)participant listrolesmute statesactive speakerrecording flagHot, small, changing every second; owned by the signalling server that hosts the room, mirrored to Redis for failover.
SFU registryRedis / etcdsfu_idregionaddressload (cpu, bandwidth, participants)healthUsed by the allocator to place meetings; updated by heartbeats every few seconds.
recordingsS3 + Postgres metadatarecording_idmeeting_idstorage_keydurationstatustranscript_keyRaw per-track recordings in object storage, composited later by workers.
call quality metricsClickHouse / time-series DBmeeting_idparticipant_idtsrttjitterlossbitrateframe rateUsed for dashboards, alerts and debugging 'my call was bad' complaints.
5 Architecture
Hover a box to highlight its connections.
6 Request flows
Join a meeting
- 1Client calls /join; meeting service checks auth and passcode and puts the user in the waiting room if enabled
- 2Allocator returns the SFU already hosting this meeting in the user's region, or picks the least-loaded healthy SFU close to the user
- 3Client opens a WebSocket to the signalling server and gets TURN credentials and a media token
- 4Client creates a WebRTC peer connection, gathers ICE candidates (host, STUN-reflexive, TURN relay), and exchanges SDP offer/answer with the SFU via signalling
- 5ICE picks the best working path (direct UDP preferred; TURN over TCP/TLS 443 if UDP is blocked); DTLS sets up SRTP keys
- 6Client publishes its audio and simulcast video tracks; signalling tells it which tracks of others to subscribe to based on layout
- 7Media flows within ~1-3 s of clicking join
Media forwarding during the call
- 1Each sender uploads audio plus 3 simulcast video layers (e.g. 720p, 360p, 180p) once to its SFU
- 2SFU reads RTCP feedback (loss, estimated bandwidth) from each receiver
- 3For each receiver it picks the layer to forward per sender: high for the active speaker tile, low for thumbnails, none for off-screen participants
- 4SFU forwards RTP packets without decoding; it rewrites sequence numbers when switching layers and requests a keyframe from the sender when needed
- 5Audio: SFU forwards the top 3 loudest speakers using audio-level header extensions, saving bandwidth in large meetings
Recording
- 1Host starts recording; the SFU adds a recording bot as a hidden subscriber
- 2Recorder receives the tracks, writes them to object storage, and after the meeting a worker composes a layout video and generates a transcript
- 3Recording link is shared with participants when processing finishes
7 Deep dives
Mesh vs MCU vs SFU
There are three ways to connect participants. In a mesh, every client sends its stream directly to every other client. With n people, each uploads n-1 copies; at 1.5 Mbps that is 13.5 Mbps upload for 10 people, which phones and home connections cannot do. Mesh is fine only for 2-3 people (and 1:1 calls often use peer-to-peer to save server cost). An MCU (Multipoint Control Unit) decodes all incoming streams, mixes them into one composite video, re-encodes and sends one stream to each participant. Clients are simple, but the server does heavy transcoding, which costs a lot of CPU, adds latency (decode plus encode, often 100+ ms) and fixes the layout. An SFU (Selective Forwarding Unit) receives each participant's stream once and forwards packets to subscribers without decoding. It is cheap per stream, adds only a few ms, and lets each client choose its own layout. Its weakness is download bandwidth on the client grows with visible tiles, which is solved with simulcast and limiting visible tiles. Modern systems (Zoom, Meet, Teams) are SFU-based, sometimes with MCU-style mixing for PSTN dial-in or very constrained devices.
Bandwidth adaptation: simulcast, SVC and congestion control
Participants have very different networks: office fibre, home Wi-Fi, a 4G phone on a train. Real-time video cannot buffer like YouTube, so it must adapt within a second. With simulcast, each sender encodes the same video at 2-3 resolutions and bitrates and uploads all of them; the SFU picks per receiver which layer to forward. With SVC (scalable video coding, available in VP9 and AV1), one stream contains layered data, and the SFU drops upper layers for weaker receivers. Bandwidth estimation runs on both ends using RTCP feedback and transport-wide congestion control: the receiver reports packet arrival times, the sender's estimator (like Google Congestion Control) detects rising delay before loss and lowers its bitrate. Under heavy loss, priorities apply: audio is protected first (Opus with FEC, small packets, retransmission only if RTT allows), then screen share (needs sharp text at low frame rate), then speaker video, then thumbnails. NACK-based retransmission fixes single lost packets; keyframe requests (PLI) recover from bigger losses. The user sees a lower resolution rather than a frozen call, which is the right trade-off.
Placing SFUs and cascading across regions
Latency is mostly physics, so media servers must be near users. Deploy SFUs in many regions (Mumbai, Chennai, Singapore, Frankfurt, Virginia) and edge PoPs. When a meeting starts, the allocator picks an SFU near the first participant. If everyone is in India, all connect to Mumbai. If a participant joins from the US, connecting them to Mumbai adds ~200+ ms round trip over the public internet. Cascading solves this: the US participant connects to a US SFU, and the two SFUs connect to each other over the provider's private backbone, forwarding only the streams that are actually subscribed on the other side. This cuts both latency and cross-region bandwidth. Large meetings also need cascading because one SFU has limits (around 500-1,000 participants or ~10 Gbps); a 300-person meeting can be split across several SFUs in the same region. The allocator uses live load from the SFU registry and avoids moving a running meeting; if an SFU is overloaded, new joiners go to a cascaded sibling.
NAT traversal and security
Most devices sit behind NAT, and many corporate networks block UDP. ICE tries candidates in order: direct host addresses, server-reflexive addresses learned from STUN, and finally relayed addresses through TURN. Because clients connect to public SFUs, direct UDP to the SFU usually works; TURN (often over TLS on port 443 so it looks like HTTPS) handles the 10-20% of users behind strict firewalls, at the cost of extra latency and relay bandwidth, so TURN servers must be co-located with SFUs. Media is encrypted hop by hop with DTLS-SRTP, so the SFU can see media in clear. For true end-to-end encryption, clients encrypt frames with a shared key using insertable streams (SFrame) before packetising; the SFU still forwards because it only needs RTP headers, but server-side features like recording, transcription and PSTN mixing then stop working, which is why E2EE is usually an opt-in mode. Join tokens are short-lived and bound to the meeting, waiting rooms and passcodes stop 'zoombombing', and host controls are enforced by the signalling server, not trusted from clients.
8 Trade-offs
UDP vs TCP for media
TCP retransmits everything in order, so one lost packet stalls all later packets (head-of-line blocking). For live media, late data is useless, so RTP over UDP with selective recovery is used. TCP/TLS via TURN is only a fallback.
Simulcast vs SVC
Simulcast works with H.264 and VP8 everywhere but costs extra upload bandwidth and encode CPU. SVC is more efficient but needs VP9/AV1 support on all clients and in hardware. Many systems use simulcast with VP8/H.264 and add SVC where supported.
Peer-to-peer for 1:1 calls vs always SFU
P2P saves server bandwidth for two-party calls and can lower latency. But switching to SFU when a third person joins causes a renegotiation glitch, and recording needs a server. Many products use P2P for 1:1 and switch on the third join.
Webinar mode via HLS vs SFU
For 10,000 passive viewers, an SFU fan-out is expensive. Converting the meeting into a low-latency live stream (LL-HLS, 2-5 s delay) through a CDN is far cheaper, at the cost of interaction latency.
9 Bottlenecks
Monday 10 am meeting spike
Meetings start on the hour. Pre-warm SFU capacity by time of day and region, spread allocation, and keep join fast by not waiting on non-critical calls (recording setup, chat history).
Client CPU and download bandwidth
Decoding 25 video tiles burns phones. Cap visible tiles on mobile, subscribe to low layers for thumbnails, and pause video for off-screen participants.
Cross-region bandwidth cost
Cascaded links carry only subscribed streams and lower layers where possible; most meetings are kept in one region.
10 Failure handling
SFU crash
Clients detect ICE failure within a few seconds and signalling re-allocates the room to a healthy SFU; clients do an ICE restart and republish. The call freezes for 2-5 s but continues. Room state lives in signalling and Redis, not in the SFU.
Signalling server down
Existing media keeps flowing because it does not depend on signalling. Clients reconnect their WebSocket to another signalling node, which loads room state from Redis.
Severe packet loss for one user
Their outgoing video drops to the lowest layer or turns off, audio uses FEC, and the UI shows a 'poor connection' indicator. Other participants are unaffected because the SFU isolates each receiver.
11 What impresses
- Explaining why SFU wins with numbers on upload bandwidth
- Prioritising audio over video under loss
- Cascading SFUs over a private backbone for global meetings
- Knowing E2EE breaks recording and transcription, so it is opt-in
- Using a latency budget (~150 ms) to justify region placement
- Collecting per-participant quality metrics to debug bad calls
12 Mistakes
- Sending media over the signalling WebSocket or HTTP
- Using mesh for large meetings
- Ignoring NAT traversal and corporate firewalls
- Designing the media path like video streaming with seconds of buffering
- Putting all participants worldwide on one central server
- No plan for bandwidth adaptation
13 Follow-ups
Saved on this device. Create a free account to keep it on every device.
Practise this with Sam
A real mock interview, out loud, with an honest scorecard. Free to start.