Media and real time · Design 20

Design Zoom

Design Zoom in a 45-minute interview: signalling vs media, mesh vs SFU vs MCU, simulcast and SVC, UDP and WebRTC, TURN relays and regional media servers.

AdvancedInterview priority: High60 min
On this page
  1. How to use this page
  2. 1. Clarify the requirements
  3. 2. Back-of-the-envelope estimates
  4. 3. API
  5. 4. Data model
  6. 5. High-level design
  7. 6. Deep dives
  8. 7. Bottlenecks, failures and monitoring
  9. 8. Follow-up questions
  10. Quiz

How to use this page

This page follows the order of a real system design interview. At each step there is a Your turn box: write your own answer first (it stays in your browser), then open ours and compare. Reading a finished design feels easy; producing one under time pressure is the skill you are practising.

PhaseTime in a 45-min interviewWhat you produce
1. Clarify requirements5 minFunctional list, non-functional targets, what's out of scope
2. Estimate5 minConcurrent participants, bandwidth in and out, number of media servers
3. API5 minThe control calls, the signalling events, and the media path
4. Data model5 minThe few things that are stored, and the much larger live state
5. High-level design10 minControl plane and media plane, with join, group call and firewall flows
6. Deep dives10–15 minTopology, transport, quality adaptation, NAT traversal, placement
7. Wrap up2–3 minBottlenecks, failures, what you would monitor

Video calling is unusual among case studies. Most designs are about storing things correctly; this one stores almost nothing. It is about moving packets fast enough that a conversation feels natural, and about accepting that some of them will be lost.

Users join a meeting by link, then send and receive live audio and video. Support screen sharing, mute, and meetings from 2 to 1,000 people. Skip recording, chat, breakout rooms and webinars.

1. Clarify the requirements

Your turn: scope it

The interviewer says: "Design Zoom." Write down the questions you would ask, then 4–6 functional requirements, 4–6 non-functional requirements with targets, and 2–3 things you would put out of scope.

Compare with our answer

The questions that change the design: How big can a meeting get (5 people or 1,000)? Do we need recording? Browser, desktop and phone? Do we need end-to-end encryption? Is webinar-style "few speakers, many viewers" in scope? Then write the agreed list on the board, as below.

Functional: what it must do

  • Create and join meetings: By link or meeting id
  • Live audio and video: Everyone sees and hears everyone (up to a limit)
  • Screen sharing
  • Mute / camera off: Host can mute others
  • Active speaker view: Show whoever is talking

Out of scope

RecordingIn-meeting chatBreakout roomsWebinars and live streaming

Non-functional: how well it must work

QualityTargetWhy
Latency< 150 ms mouth-to-earAbove ~300 ms conversation breaks down
SmoothnessGraceful under packet loss and jitterBetter a blurry frame than a frozen one
Availability99.99%Meetings are scheduled business events
ScaleMillions of concurrent meetings
SecurityEncrypted media, meeting passcodes / waiting rooms“Zoombombing” is real
GlobalMedia servers near every userDistance adds latency

Two things make this different from a chat app. First, the data is perishable: an audio packet that arrives 300 ms late is worthless, so "never lose anything" is the wrong goal. The right one is "degrade gracefully": a blurry frame beats a frozen one, and audio matters more than video. Second, a meeting is live state, not stored state. When the last person leaves, almost nothing needs to survive except a usage record for billing.

2. Back-of-the-envelope estimates

Your turn: the numbers

Assume 20 million people on calls at the daily peak. Each camera sends about 1.2 Mbit/s, and each person receives about 5 video streams averaging 600 kbit/s (mostly thumbnails). One media server can forward about 10 Gbit/s. Work out the upload into the servers, the download out of them, and the number of media servers. Then work out what a 10-person call would need without any server.

Compare with our answer
  • Upload: 20 M × 1.2 Mbit/s = 24 Tbit/s ≈ 3 TB/s into the media servers.
  • Download: 20 M × 5 × 0.6 Mbit/s = 60 Tbit/s ≈ 7.5 TB/s out of them. Downlink is bigger than uplink because each stream is copied to several viewers.
  • Media servers: 60 Tbit/s ÷ 10 Gbit/s = 6,000 servers, before headroom; plan for about 9,000 spread over many regions.
  • Mesh for 10 people: everyone uploads 9 copies: 9 × 1.2 = 10.8 Mbit/s of upload per person, and 90 streams in total. Typical home uplinks are 10–20 Mbit/s and phones far less, so mesh is out beyond 3–4 people.
  • Audio is tiny (Opus at roughly 20–50 kbit/s) but it is the stream that must never suffer.

A strong answer mentions: bandwidth, not requests per second, as the unit · downlink larger than uplink · thousands of media servers across regions · why mesh fails · audio prioritised over video.

Assumptions: concurrent participants (peak) 20 M; video sent per person (kbit/s) 1.2 K; streams each person receives 5; forwarding capacity per media server (gbit/s) 10.

NumberEstimateWhy it matters
Upload into media servers3 TB/sEvery camera uploads one stream (or a few simulcast layers).
Download from media servers7.5 TB/sPeople receive several streams, mostly smaller simulcast layers, so downlink > uplink.
Media servers needed6 KThousands, spread across many regions.
Streams in a 10-person mesh call90Peer-to-peer mesh: each person uploads 9 copies, which phones can’t do.
  • Media servers forward packets; they don’t decode video (that’s what makes them cheap).
  • Audio is small (~50 kbit/s) but the most important stream: protect it first.

The key insight from the numbers: bandwidth sizes everything, and the media servers carry all of it. The control plane (joining, muting, layout changes) is a few thousand requests a second, which is small. That split, a tiny control plane and an enormous media plane, is the shape of the whole design.

A sanity check on the scale: Zoom has reported over three trillion meeting minutes a year, which is around 9 billion a day, or about 6 million people in meetings at any moment on average. A peak of 2–3× that is the 20 million we assumed.

3. API

Your turn: the API

List the calls a client makes to create and join a meeting, the messages it exchanges once it is in, and how the actual audio and video travel. Which of these go over HTTP, which over a WebSocket, and which over neither?

Compare with our answer

A strong answer mentions: REST for create and join · the join response carrying a token, a media server address and STUN/TURN servers · a WebSocket for signalling (SDP offer and answer, ICE candidates, mute, active speaker) · media over UDP (SRTP) straight to the media server, never through the signalling server · host controls as signalling events.

CallRequestResponseNotes
POST /v1/meetings{ topic, startTime, settings }201 { meetingId, joinUrl, passcode }
POST /v1/meetings/{id}/join{ passcode, displayName }{ token, signallingUrl, mediaServer, iceServers[] }Assigns the nearest media server
WS signallingSDP offer / answer, ICE candidates, mute, layouteventsControl messages only, never media
UDP media (SRTP over RTP)encrypted audio/video packets–Directly to the media server

Real-time events

DirectionEventPayload
client → serverjoin / leave{ participantId }
server → clientsparticipant-joined / left{ participantId, name }
client ↔ serveroffer / answer / ice-candidateSDP and network candidates
server → clientsactive-speaker{ participantId }
host → servermute-participant{ participantId }

There are three channels, and keeping them separate is the point:

  1. HTTP for control that happens once: create a meeting, check the passcode, get assigned a media server.
  2. A WebSocket for signalling: small, reliable, ordered messages. The client describes its codecs and resolutions in an SDP (Session Description Protocol) offer, the server answers, and both sides exchange ICE candidates (possible network addresses to try). Later: mute, "Ana is speaking", "switch to gallery view".
  3. UDP for media: encrypted RTP packets (SRTP, Secure Real-time Transport Protocol) flowing directly between the client and its media server.

4. Data model

Your turn: what is stored?

A meeting lasts 40 minutes and then disappears. What has to be stored durably, what lives only while the meeting runs, and where does each go?

Compare with our answer

A strong answer mentions: meetings and settings in a relational database · live meeting state (who is in, on which media server, muted) in memory, rebuilt if lost · a registry of media servers with live load · usage records streamed to a warehouse for billing · no media stored at all (recording is out of scope).

meetings Relational (PostgreSQL)

  • meeting_id, host_id
  • passcode_hash, settings
  • scheduled_at

Small, transactional, read on join.

live sessions In-memory (Redis)

  • meeting_id → media_server_id
  • participants[] with state (muted, sharing)

Which media server hosts which meeting, and who is in it right now.

media server registry Service discovery (etcd / Consul)

  • server_id, region, load, health

Live capacity and health of every media server per region.

usage records Data warehouse

  • meeting_id, participant_id, joined_at, left_at, quality stats

Billing and analytics; not on the live path.

Notice how little is durable. The meetings table is small and boring: a few rows per scheduled meeting. The interesting state is live: which media server hosts meeting 8812, which 37 participants are in it, who is muted and who is sharing. It changes every second, matters only while the meeting runs, and can be rebuilt from the clients if lost (every client knows which meeting it is in). So it lives in Redis, keyed by meeting id, with a TTL refreshed while the meeting is active.

The media server registry is the other live piece. Each media server reports its CPU, bandwidth and participant count every few seconds to a service-discovery system (etcd or Consul). The join path reads it to pick a server near the user with spare capacity. Stale data here causes the classic failure of sending a burst of new meetings to a server that has just filled up, which is why assignment should use headroom thresholds, not "least loaded".

5. High-level design

Your turn: draw it

Sketch the boxes. How does a client join, where does its video go, how does a participant in another continent get it, and what happens to a user whose network blocks UDP? Then step through ours.

Compare with our answer

Compare your sketch with the figure below. The pieces people most often forget: a separate signalling path (control never shares a pipe with media), TURN for blocked networks, and media servers that cascade between regions instead of everyone connecting to one place.

The architecture, then joining, a group call and a blocked network

  1. The architecture separates control from media. The meeting API and signalling servers handle joining and control messages. The heavy media flows over UDP to selective forwarding media servers in many regions, which cascade between each other, with STUN and TURN servers to get through firewalls.
  2. Joining: the app calls the meeting API, which checks the passcode and picks a media server near the user with spare capacity. Then the app opens a signalling connection to exchange network details, and media starts flowing over UDP.
  3. In a group call, each person uploads their video once to the media server, a selective forwarding unit. It forwards the streams to everyone else without decoding them, choosing a small or large version for each viewer.
  4. Some networks block direct UDP. ICE tries direct paths first; if they fail, Ben’s media is relayed through a TURN server, which is slower but always works.
ComponentWhat it does
Meeting APICreate/join, auth, passcodes, server assignment
Signalling serviceWebSocket for SDP/ICE, mute, layout, active speaker
Media servers (SFU)Receive each stream once, forward to many; no decoding
STUN / TURNDiscover public addresses; relay when direct paths fail
Server registryLive load and health of media servers per region
Live sessionsWho is in which meeting on which server

Trace the join flow out loud in the interview:

  1. Ana's app calls POST /meetings/{id}/join with the passcode. The meeting API checks it against the meetings database.
  2. The API asks the registry for a healthy media server near Ana with headroom, records her in the live session, and returns a token, that server's address and a list of STUN/TURN servers.
  3. Ana opens a WebSocket to signalling and sends an SDP offer: "I can send VP8 or H.264, these three resolutions, and here are my candidate addresses."
  4. Signalling relays it to the media server, which answers. ICE checks find a working network path.
  5. Encrypted audio and video start flowing over UDP between Ana and her media server. Signalling stays open for control messages for the rest of the call.

6. Deep dives

Your turn: the hard parts

Before reading on, write two or three sentences on each: how does video flow in a 10-person call? Why UDP? How does one call serve a viewer on fibre and a viewer on weak 4G at once? How does a laptop behind a corporate firewall get media at all?

Compare with our answer

A strong answer mentions:

  • An SFU: each person uploads once, the server forwards without decoding; mesh only for 1:1.
  • UDP with a jitter buffer, loss concealment and forward error correction; retransmit only when there is time.
  • Simulcast or SVC layers chosen per viewer, driven by bandwidth estimates and layout.
  • ICE: try direct UDP, then a TURN relay over UDP, then TCP or TLS on port 443.

Topology: mesh, SFU or MCU?

Three ways to wire a group call

OptionHowClient upload / downloadServer costCatch
Mesh (peer-to-peer)Everyone sends to everyoneN−1 uploads, N−1 downloadsNoneUplink and CPU run out at 4–5 people; no server to enforce host controls
SFU (selective forwarding unit)Everyone uploads once; server forwards packets1 upload (a few layers), several downloadsLow: forwards, never decodesClients still download several streams and decode each one
MCU (multipoint control unit)Server decodes, mixes into one picture, re-encodes1 upload, 1 downloadVery high: decode and encode every streamAdds 50–200 ms of processing, one fixed layout for everyone, expensive at scale

Choice: SFU for groups, direct peer-to-peer for 1:1. This is what Zoom, Google Meet, Microsoft Teams and open-source servers such as Janus, mediasoup and LiveKit do. An SFU is cheap because forwarding a packet costs about the same CPU whatever is inside it, so one server can carry thousands of streams.

MCUs are not dead: they survive where a client can only take one stream, such as dialling in from a phone line or connecting a meeting-room hardware system. In an interview, mention that as the place where mixing still pays.

Why a two-person call can skip the server

With two people, a direct path saves a hop: the media goes from Ana to Ben without a detour through a data centre, which can cut 20–50 ms. The catch is the switch: when a third person joins, both clients must move to the SFU mid-call, which takes a renegotiation and a brief glitch. Many products only go direct when they are confident the call will stay at two (a 1:1 call button rather than a meeting link).

Transport: why UDP, and what replaces TCP's reliability

TCP guarantees every byte arrives, in order. For live media that guarantee is a trap: if one packet is lost, TCP holds back every packet behind it until the retransmission arrives (head-of-line blocking), which on a 100 ms round trip means a freeze of at least that long. Live audio would rather skip 20 ms than stop for 100.

So media goes over UDP with RTP, and the application decides what to do about loss:

ToolWhat it doesCost
Jitter bufferHolds packets for 20–60 ms so uneven arrival times become smooth playbackAdds that much delay; it grows and shrinks with network conditions
Packet loss concealmentThe audio decoder guesses a missing 20 ms frame from its neighboursFree; works for isolated losses
FEC (forward error correction)Sends extra redundant data so a lost packet can be rebuilt without asking10–50% more bandwidth while loss is high
NACK (retransmission request)Receiver asks for a missing video packet againOnly useful if the round trip is short enough to arrive in time
Keyframe requestWhen video is badly broken, ask the sender for a fresh full frameA keyframe is several times larger than a normal frame

Choice: UDP with SRTP encryption, jitter buffers, Opus with built-in FEC for audio, NACKs and keyframe requests for video, and a TCP or TLS fallback on port 443 only when UDP is blocked. Browsers do all of this through WebRTC, the browser standard that bundles ICE, SRTP, codecs and congestion control. Zoom's native apps use their own protocol over UDP with a similar toolbox, and its browser client uses WebRTC.

One call, very different networks: simulcast and SVC

Ana is on fibre, Ben is on a train, and Cleo has Ana pinned as the speaker. If the SFU sends everyone the same stream, it must be the lowest quality anyone can handle, which punishes everyone for the worst connection.

OptionHowGood atCatch
Lowest common qualityOne stream at the weakest viewer's rateSimpleEveryone sees a blurry call
Re-encode per viewerServer transcodes (an MCU per viewer)Perfect fitCPU cost multiplied by viewers
SimulcastSender encodes 2–3 independent streams (e.g. 180p, 360p, 720p); SFU forwards one per viewerWorks with standard codecs; no server decodingSender spends extra upload and CPU (about 1.5× a single stream)
SVC (scalable video coding)One stream built in layers; SFU drops upper layers per viewerLess upload than simulcast; smooth switchingNeeds codec support (VP9, AV1, H.264 SVC); more complex

Choice: simulcast (or SVC where codecs allow). The SFU picks a layer for each viewer from two inputs: the viewer's layout (a 160-pixel thumbnail never needs 720p) and the viewer's bandwidth estimate, which the client and server compute continuously from packet arrival times and loss (Google's congestion control algorithm for WebRTC is the best-known example). When Ben enters a tunnel, his estimate drops and the SFU switches him to the low layer within a second; when he comes out it moves him back up.

The sender adapts too: if nobody is watching Ana's 720p layer, the SFU tells her client to stop encoding it, saving her upload and battery.

Getting through NAT and firewalls

Most devices sit behind a home router doing NAT (network address translation: many devices share one public IP address), and many companies block unknown traffic. A media server cannot simply send packets to "192.168.1.20".

The standard answer is ICE (Interactive Connectivity Establishment), which collects candidate paths and tries them in order:

  1. Host candidate: the device's own address. Works only on the same network.
  2. Server-reflexive candidate: the client asks a STUN server "what public address do my packets come from?" and offers that. Works through most home routers.
  3. Relay candidate: a TURN server relays all media. Works through almost anything, including TCP or TLS on port 443.

Because our media servers have public addresses, the common case is easy: the client sends UDP to the server, which opens a mapping in the client's NAT, and the reply comes back the same way. TURN is for networks that block outbound UDP or restrict it to certain ports. Published WebRTC figures suggest something like 10–20% of sessions need a relay, much higher on locked-down corporate networks.

Where media servers live, and cascading

Physics sets a floor: light in fibre covers about 200 km per millisecond, so London to Sydney is at least 85 ms one way before any routing. If a meeting with people in London, New York and Mumbai uses one server in Virginia, the Mumbai participant pays a long, lossy public-internet path in both directions.

OptionHowCatch
One central regionEveryone connects to one placeDistant users get high latency and loss
Server nearest the hostPick by the person who started the meetingEveryone else pays the distance
Nearest server per participant, cascadedEach person connects to a nearby SFU; SFUs forward streams to each other over a private backboneMore moving parts: inter-server routing, deciding which streams cross regions

Choice: cascading SFUs. The first hop (the unreliable public internet, often Wi-Fi) is short, and the long haul runs over provisioned links between data centres. Each region's SFU only forwards across the backbone the streams that viewers on the other side actually need, usually the active speakers, so cascading also saves backbone bandwidth.

Picking "nearest" is not just geography. The join path uses the client's IP location to shortlist two or three regions, the client can measure round-trip times to each, and the registry filters out servers above their headroom threshold.

Very large meetings

A 1,000-person all-hands cannot send everyone's video to everyone: 1,000 × 999 streams is a million. Two techniques keep it bounded:

  • Last-N / active speaker forwarding: the SFU forwards video only for the N most recent speakers (say 4–9) plus the screen share. It knows who is speaking because each audio packet carries a small audio level header, so the SFU can rank speakers without decoding audio.
  • Pagination: a gallery view asks for the 25 thumbnails on the current page only, at the low layer.

With these, a 1,000-person meeting costs each viewer about the same as a 10-person one. Audio still flows from everyone who is unmuted, but most are muted, and the SFU forwards only the loudest few audio streams.

End-to-end encryption with an SFU

By default, SRTP encrypts media between the client and the SFU, so the SFU can, in principle, see the media (it must, if it transcodes or records). For end-to-end encryption, clients encrypt each frame again with a key that only participants hold (the SFrame approach, implemented in browsers through "insertable streams"). The SFU still reads the RTP headers it needs for routing (sequence numbers, layer ids, audio level) but cannot see the picture. The cost: server-side features that need the media stop working. When Zoom's end-to-end mode is on, features such as cloud recording and phone dial-in are unavailable, which is exactly the trade-off to state in an interview.

7. Bottlenecks, failures and monitoring

Scaling bottlenecks

BottleneckFix
Huge meetings (1,000 people)Only forward video of active speakers + a few thumbnails; everyone else audio-only or paused
Media server loadAssign by live capacity; spread meetings; cascade large ones across servers
TURN relay costPrefer direct UDP; place TURN near users; measure relay rates
Signalling spikes at the top of the hourAutoscale; join retries with jitter

When things fail

FailureWhat happens
A media server dies mid-callClients detect lost media, reconnect via signalling to another server within seconds
Packet loss spikesFEC, retransmission for key frames only, lower layers; audio prioritised
Signalling outageCalls in progress continue (media is separate); new joins fail until it recovers
Region outageAssign meetings to the next nearest region

What to monitor

Round-trip timePacket loss and jitter per callFreeze / audio-drop rateJoin success rate and timeMedia server CPU and bandwidthTURN relay usage

What happens when a media server dies mid-call: every client on it sees its media stop within a second or two. Clients ask signalling for a new server, run an ICE restart to it, and re-publish their streams. The meeting's live state in Redis says who should be in the meeting, so the new server can rebuild it. Users see a few seconds of frozen video; audio comes back first because it is the first stream re-published.

8. Follow-up questions

Your turn: the interviewer pushes

Answer these three in order before opening ours. 1) A 500-person meeting is all on one SFU in Frankfurt when that machine fails. What happens and how do you limit the blast radius? 2) The product team wants cloud recording. Where does it go? 3) Your monitoring shows call quality collapsing for one large customer every morning. How do you investigate?

Compare with our answer

A strong answer mentions:

  1. Clients detect lost media, get a new server through signalling, ICE-restart and re-publish; cap how many participants of one meeting sit on one server by spreading large meetings across several cascaded SFUs, so one failure drops a fraction, not everyone; pre-warm spare capacity in the region.
  2. A hidden recorder participant joins the SFU like any viewer, subscribes to the active speaker and screen share, and a separate fleet composes and encodes them to a file in object storage (this is where mixing, MCU-style, belongs: offline, not in the live path). It cannot work with end-to-end encryption unless a participant's client does the recording.
  3. Break quality metrics down by network and transport: a jump in TCP or TURN usage points to a firewall change; rising round-trip time to one region points to a routing problem; high loss on Wi-Fi only points to the office network. Client-side quality reports (RTT, loss, jitter, resolution, freezes) are what make this possible.

The senior-level questions, roughly in the order interviewers escalate:

How would you add recording?

A hidden “recorder” participant joins the SFU, receives the streams, and composes them into a file in the background.

Why is 1:1 different?

Two people can go peer-to-peer directly (no server hop), switching to the SFU if a third person joins.

How do you do end-to-end encryption with an SFU?

Clients encrypt frames with keys the server never sees (insertable streams); the SFU still forwards packets it can’t read.

More senior follow-ups
  • Webinars with 50,000 viewers. Viewers don't need 150 ms; 2–5 s is fine. Switch them to a broadcast pipeline: the meeting is composed once and streamed with low-latency HLS or DASH through a CDN, while panellists stay on the SFU.
  • Noise suppression and virtual backgrounds. Do them on the client: they need the raw media, and doing them on the server would turn the SFU into an MCU.
  • Screen sharing. It is a separate video track tuned for sharpness over frame rate (text must be readable; 5 frames a second is fine), with its own simulcast layers.
  • Fair use of the backbone. Inter-region cascade links are expensive; forward only streams that remote viewers actually subscribe to.
Zoom on one page
  • Numbers: 20 M concurrent at peak; ~3 TB/s up, ~7.5 TB/s down; ~6,000 media servers at 10 Gbit/s before headroom. Bandwidth, not requests, sizes the system.
  • Latency budget: under ~150 ms mouth-to-ear; above ~300 ms conversation breaks down.
  • Split control from media: HTTP for join, WebSocket signalling for SDP, ICE and control, UDP (SRTP) for media.
  • Topology: SFU for groups (upload once, forward without decoding); peer-to-peer for 1:1; MCU only for dial-in and recording.
  • Transport: UDP + jitter buffer + concealment + FEC + NACK; TCP/TLS 443 only as a fallback, with lower quality.
  • Quality per viewer: simulcast or SVC layers chosen by layout and bandwidth estimate.
  • NAT: ICE tries direct, then STUN, then TURN; TURN costs a second media fleet, so co-locate it.
  • Placement: nearest SFU per participant, cascaded over a private backbone.
  • Big meetings: last-N speaker forwarding using audio-level headers, paginated galleries.
  • Failure: server dies → signalling assigns another → ICE restart → audio first.
Mock interviewPractise it as a mock interview: scope, size and the big decisionsOpens in the ByteAtlas lab. Your progress is saved in this browser.
Check what stuck

1. A team builds group calls by having every participant send video directly to every other participant. Calls work well with three people but break down at eight. What is the root cause?

2. Why does a video call carry media over UDP even though UDP does not guarantee delivery?

3. Ana's camera feeds a 30-person meeting. One viewer has her pinned full screen, most see her as a thumbnail, and two are on weak mobile links. What lets one upload serve all of them?

4. About 15% of participants in your service connect through TURN relays. Why is that a capacity concern?

5. A meeting has participants in London, New York and Mumbai. Which placement gives the best experience?

6. In a 1,000-person all-hands, how does the media server avoid forwarding a million video streams?

7. The signalling service goes down for five minutes. What should users notice?

8. A customer complains that calls from one office became choppy last week, while the same people have smooth calls from home. What is the most likely cause to check first?

Score 60% or more and the lesson is marked complete.

Passing the quiz also marks it complete. Progress is saved in this browser only.