← Lessons

quiz vs the machine

Gold1380

System Design

Client Side Prediction

Hiding network latency by letting the client act immediately on its own inputs.

5 min read · core · beat Gold to climb

The latency problem

With a pure authoritative server, every keypress must travel to the server and back before the player sees movement. At one hundred milliseconds of round trip, controls feel like wading through mud.

Client side prediction fixes this by letting the client run the same simulation locally and apply its own input immediately, without waiting.

How it works

  • The player presses move, and the client predicts the new position at once.
  • The same input is also sent to the server tagged with a sequence number.
  • The client keeps a buffer of unacknowledged inputs so it can correct later.

The local result is a guess that should match what the authoritative server will compute, because both run the same deterministic rules.

Why it usually works

  • Most inputs are predictable, like walking forward on flat ground.
  • The server runs the same code, so the prediction is right the vast majority of the time.
  • When the guess is wrong, reconciliation corrects it, covered in the next lesson.

Key idea

Client side prediction applies inputs locally and instantly while still sending them to the authoritative server, hiding round trip latency.

Check yourself

Answer to earn rating on the learn ladder.

1. What does client side prediction do?

2. Why does the client tag each input with a sequence number?