AlgoViz

Design Zoom

hard 60 min

Design video meetings like Zoom.

See it run

Join a meeting, watch one upload become many chosen copies, and see what happens when networks and servers fail.

Operations

Join a meeting

Control first, then signalling, then media straight to the SFU.

Step 1 of 13

Click the link

Our systemNoorMeeting APISignallingWebSocketCoordinatorSFU

Noor's client sends the meeting id, the passcode and what the device can do.

Step 1: Click the link

def join(client, meeting, passcode):    limiter.check(client)                    # 429    check(meeting, passcode, client)         # 403 or 202 waiting    return token(client, meeting), urls()ws = connect(urls.signalling, token)people = ws.receive("state")ws.send("offer", sdp, candidates)            # by signallinganswer = ws.receive("answer")ice_checks(); dtls_handshake()               # to the SFU itselfsend_rtp(layers=3); receive_rtp()
Latency
first sound in 2 s
Load
47,000/s on the hour
Average joins
3,500/s
People at once, peak
28M

The SFU has a public address, so a client normally needs no STUN server to reach it.

In the real world

The same video meetings doing real jobs. Pick one and step through it.

Signalling is a different service, so it can repair the media.

Step 1 of 5

All well

Our systemPeopleSignallingCoordinatorSFU 17SFU 21

owner

SFU 17, fence 4

Media goes to SFU 17 with fence 4.

Step 1: All well

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • Media over TCP

    critical

    One lost packet holds back all later sound.

    Wrong
    websocket.send(audio_frame)
    Right
    rtp.send(audio_frame)       # over UDP
  • Forwarding what nobody sees

    major

    A thousand people with a thousand videos is 999,000 streams.

    Wrong
    for s in all_streams: forward(s)
    Right
    for s in visible(receiver): forward(s)
  • Slowing the sender for one bad receiver

    major

    Everyone else loses quality.

    Wrong
    sender.bitrate = min(all_receivers)
    Right
    layer[receiver] = fit(estimate[receiver])
  • Treating the meeting number as a secret

    critical

    With 2.8M live meetings in 10^11 numbers, one guess in about 36,000 is right.

    Wrong
    if exists(number): admit()
    Right
    limiter.check(client)check_passcode(); waiting_room()
  • No fence on reassignment

    major

    A frozen SFU can wake and split the meeting in two.

    Wrong
    owner[meeting] = "sfu-21"
    Right
    owner[meeting] = ("sfu-21", fence + 1)

Interview tips

  • Start with the deadline

    • 150 ms one way.
    • Spend a budget step by step.
    • Late means lost.
  • Count streams and bits

    • 9 uploads or 1.
    • 2.2 up, 5.65 down.
    • 28M people, 56 Tb/s.
  • Degrade in order

    • Thumbnails, speaker, then audio only.
    • Down fast, up slow.
    • Each receiver alone.
  • Be honest about limits

    • Distance costs time.
    • End to end excludes server recording.
    • A normal SFU could read media.