AlgoViz

Design Zoom

hard 60 min

Design video meetings like Zoom.

Video lesson · Chapter 1 of 5

Join the meeting before hearing the first word

0:00 / 4:08

Theory

Read or listen first. About 2 min.

What it is

A video meeting service carries live sound and pictures between people. It has two halves: a control half, which is an ordinary web system for meetings, accounts and permissions, and a media half, which moves packets that are worthless if they are late.

The central part is the SFU, the selective forwarding unit. Each person sends their media to it once. It passes copies on, and chooses for each receiver which people and which quality to send.

Why it exists

Conversation has a deadline. ITU-T recommendation G.114 advises keeping one-way delay under about 150 ms, and not above 400 ms. A perfect picture that comes a second later is a failure.

Sending everything to everyone also grows too fast. Ten people on direct links need 90 streams, and each person must upload nine. Most homes cannot. A server in the middle turns nine uploads into one.

A short history

  1. July 2003

    RFC 3550 defines RTP, the packet format for live media with sequence numbers and timestamps.

  2. September 2012

    RFC 6716 defines Opus, an audio codec for 6 to 510 kbit/s.

  3. November 2015

    RFC 7667 describes ways to connect many people, including the selective forwarding middlebox.

  4. 26 January 2021

    W3C and IETF announce WebRTC as an official standard.

  5. August 2024

    RFC 9605 defines SFrame, which encrypts media so that a forwarding server cannot read it.

Words to know

WebRTC
The browser standard for live media: capture, connect, encrypt, adapt.
SFU
A server that forwards chosen streams without decoding them.
MCU or mixer
A server that decodes everybody, makes one combined picture, and encodes it again.
Signalling
Messages that set up the call: who is here, which formats, which addresses.
ICE, STUN, TURN
Try all possible paths. Learn your public address. Relay when nothing else works.
Simulcast
Sending the same video at several sizes at once.
Jitter buffer
A short wait at the receiver that hides uneven arrival times.
Last N
Forward only the few people who spoke most recently.

Solve it like an interview

New to it? Start with Approach. Revising? Go straight to the mock.

  1. 1ApproachWhat this question tests, where it gets hard, and how to spend the time.
  2. 2ScopeAsk what changes the design, then commit to a short list.
  3. 3NumbersWork out a number when the answer changes what you build.
  4. 4API and dataThe contract first, then the data that serves it.
  5. 5DesignStart with the smallest system that works. Change it only when something breaks.
  6. 6Deep divesCompare the options before you open them, then say which you would pick.
  7. 7Explain your choicesAnswer first. Then compare your reasoning.
  8. 8By levelThe same question is judged differently for mid, senior and staff.
  9. 9MockAnswer against the clock, then score yourself.

Understand it

The tin-can choir
Two singersAshaNoor

In WebRTC language Lee is a forwarder: Lee passes songs on and does not blend them. A server that blends is an MCU.

Scope

What are we building?

Meetings from 2 to 1,000 people with sound, video, screen sharing and recording, in browsers and apps. Comparable products include Google Meet, Microsoft Teams, Webex, Discord, Slack huddles and FaceTime. Voice rooms for communities are the Discord exercise.

  • Late is lost

    About 150 ms from mouth to ear. No waiting for lost packets.

  • Upload once

    The server copies. Homes have little upload.

  • Bend, not break

    Drop picture quality first and sound last.

The finished system

Where the design ends up

This is the last version. The Design tab starts with one service and one database, and people connected directly.

The whole system

A participant joins through the meeting API, backed by PostgreSQL, and keeps a WebSocket to the signalling service. Signalling asks the coordinator, backed by Redis, for a media server. Media goes straight to an SFU, or through a TURN relay when UDP is blocked. The SFU sends to an SFU in region 2, which serves a participant far away, and to a recorder that writes object storage and feeds a CDN for the audience.
Blue is control, pink is live media, orange is recording and the delayed stream.

Summary

The whole topic in one minute.

Live media goes over UDP, encrypted, to a nearby SFU. Each person uploads once, in several sizes, and the SFU forwards to each receiver only what fits their screen and their network. Audio is protected before video.

The control half decides who may join and which SFU a meeting uses. Large meetings spread over several SFUs, and huge audiences watch a delayed stream. Recording is one more receiver.

  • Two planes: control over HTTPS and WebSocket, media over UDP.
  • An SFU forwards without decoding. A mixer decodes, so it costs far more and adds delay.
  • Simulcast lets one upload serve strong and weak receivers.
  • Bandwidth is the bill: forward only what is on the screen.
  • TURN is the fallback for networks that block UDP.
  • One home SFU per meeting and region, a coordinator to move people when it dies.
  • End-to-end encryption and server recording exclude each other.

Sources