🎮

How Multiplayer Works

What really happens when two players share the same game world?

1

Polling vs Real-Time

Two ways to get updates from a server. Watch both run side by side and see why multiplayer games need WebSockets.

HTTP Polling (every 1s)
0
waiting...
WebSocket (instant)
0
connected

HTTP Polling

The client repeatedly asks "anything new?" even when nothing changed. Wasteful and always delayed by the polling interval.

WebSockets

A persistent connection stays open. The server pushes updates the instant they happen. No delay, no wasted requests.

Why It Matters
If a game server sends 60 position updates per second, polling would need 60 HTTP requests per second per player. WebSockets send the same data over one connection with near-zero overhead.
2

The Latency Problem

Click or tap anywhere in the box to move your character. Then drag the latency slider up and try again.

Simulated Latency: 0ms
Try 0ms first, then slide up to feel the delay

What Is Latency?

The time for data to travel from your computer to the server and back. Also called "ping." Even at light speed, distance adds delay.

Real-World Numbers

Same city: ~10ms. Cross-country: ~50ms. Across the ocean: ~150ms. That is why game servers are placed in multiple regions.

Pro Gamer Fact
Competitive gamers can feel the difference between 10ms and 30ms of latency. In fast-paced games, 100ms can mean the difference between hitting a shot and missing completely.
3

Who's In Charge?

Should the player's computer or the server decide where characters are? Click anywhere to move, then try the "cheat" button.

Try to cheat: teleport to the goal

Client Authority

The player's computer decides where they are. Fast and responsive, but cheaters can teleport, speed hack, or walk through walls.

Server Authority

The server validates every move. Cheating is impossible because the server rejects invalid positions. Slightly more latency but secure.

Real World Example
In the early days of online FPS games, players could edit memory to teleport or fly. Modern games like Fortnite and Valorant use server-authoritative movement, so the server decides where you actually are.
4

Prediction & Interpolation

The server only sends updates 10 times per second. Watch what happens without prediction vs with it. The blue dot is a remote player moving in a circle.

Server tick rate: 10 updates/sec Render: 60 FPS

Without Prediction

Characters jump between positions every server tick. It looks choppy and robotic, even at 10 updates per second.

With Interpolation

The client smoothly animates between known server positions. The movement looks fluid even though updates are infrequent.

Behind the Scenes
Most multiplayer games only send 20-60 updates per second, but render at 60+ FPS. The gap is filled by interpolation (smoothing between known positions) and extrapolation (guessing where something is heading).

Multiplayer Expert!

You've seen the core mechanics behind every online multiplayer game: real-time connections, latency compensation, server authority, and prediction. These same techniques power everything from simple chat apps to massive battle royales.

0
Interactions
0
Latency Levels Tested
0
Cheat Attempts

Real-Time Connections

WebSockets keep a persistent connection open so data flows instantly, unlike HTTP polling which asks "anything new?" over and over.

Latency Changes Everything

Even 100ms of delay completely changes how a game feels. Every multiplayer game fights latency constantly.

Server Authority

The server is the single source of truth. If the client could decide where players are, cheating would be trivial.

Prediction Smooths the Gaps

Client-side prediction and interpolation hide latency by guessing where things should be, then correcting when the server responds.

Ready to Create?

Put your new knowledge into practice!

Suggest a Correction