← Lessons

quiz vs the machine

Platinum1780

System Design

The Spectator And Replay System

Letting viewers watch live or rewatch matches by recording and replaying inputs.

5 min read · advanced · beat Platinum to climb

Watching without playing

Spectator and replay systems let people view a match they are not playing, either live or afterward. The elegant trick is that a deterministic simulation needs only inputs, not full frames, to reproduce the match.

Replays as input logs

  • The server records the stream of inputs and the initial seed for the match.
  • To replay, a client re runs the same deterministic simulation, feeding the logged inputs.
  • This produces a tiny file compared to recording video, since one match is just a list of inputs.

Determinism, the same property that powers prediction, is what makes this faithful. Any nondeterminism would desync the replay.

Live spectating

  • Live viewers can receive a delayed snapshot stream, often minutes behind, to prevent stream sniping.
  • A dedicated relay fans out the spectator stream so player facing servers are not loaded.
  • Spectators get a free camera, so interest management must send a wider or full view.

Key idea

Replays store only inputs and a seed, replaying through the deterministic simulation, while live spectating fans out a delayed stream via a relay.

Check yourself

Answer to earn rating on the learn ladder.

1. Why can a replay store only inputs instead of full video?

2. Why are live spectator streams often delayed by minutes?