System Design Atlas

Real-time multiplayer world

05 / 10Worked example

Authoritative data and states

How does the authority generation prevent a second valid writer?

The interfaces require authoritative state. G-21 has at most one reward record for 1 crystal. Only the current authority generation confirms effects. Client-side movement prediction grants no ownership. The table separates current states from the evidence that established them.

Starting point Validate input sequence numbers within the player and session identity.

Assumptions for the example case

A fictional example design: one session with at most 32 players, server-authoritative movement, one-time pickup of world items, reconnection within the same session and durably confirmed rewards. Figures and quality goals are illustrative test assumptions. A shared global game world, player trading, paid items and comprehensive fraud detection are outside the scope.

Data relationships and permitted transitions

Session, characters, crystal and record

Session W-21Generation + tick
W-21 → P-21/P-221:32 characters
P-21 and P-22Position + input sequence
P-21/P-22 → G-210..1 winners
Crystal G-21frei → vergeben
G-21 → BelohnungsbelegNot more than 1
Reward record1 Crystal · Winner · Generation
wartend → aktiv ↔ getrenntaktiv/getrennt → beendetfrei → vergeben · terminal

State snapshots are replaceable; the crystal record and authority generation remain authoritative.

An old game process continues after a network partition. Bind every durable record to the current authority generation. The datastore rejects old generations even while their clients remain connected.

Entities and relationships

EntityAuthoritative dataResponsibility
Game session W-21Authority generation, current tick and participantsExactly one active writer per generation.
Game characters P-21 and P-22Position, last input sequence, sessionClient position is a prediction.
Crystal G-21frei or vergeben; winnerOne unique allocation per world item.
Reward recordSession, item, winner and tickDurable record before visible final reward confirmation.
State snapshotGeneration, tick and visible charactersReplaceable representation; old snapshots are discarded.

Game session W-21

Authoritative data
Authority generation, current tick and participants
Responsibility
Exactly one active writer per generation.

Game characters P-21 and P-22

Authoritative data
Position, last input sequence, session
Responsibility
Client position is a prediction.

Crystal G-21

Authoritative data
frei or vergeben; winner
Responsibility
One unique allocation per world item.

Reward record

Authoritative data
Session, item, winner and tick
Responsibility
Durable record before visible final reward confirmation.

State snapshot

Authoritative data
Generation, tick and visible characters
Responsibility
Replaceable representation; old snapshots are discarded.

Permitted state transitions

Starting pointTargetCondition
wartendaktivAuthentication checked and capacity available.
aktivgetrenntConnection lost; the server stops the character according to a defined rule.
getrenntaktivReconnect to the current authority generation.
aktiv or getrenntbeendetSession ends with saved reward receipts.
freivergebenG-21 is atomically allocated to a valid contender according to the server’s input order.
vergeben or beendetterminalReallocation is blocked; the record remains available.

wartend

Target
aktiv
Condition
Authentication checked and capacity available.

aktiv

Target
getrennt
Condition
Connection lost; the server stops the character according to a defined rule.

getrennt

Target
aktiv
Condition
Reconnect to the current authority generation.

aktiv or getrennt

Target
beendet
Condition
Session ends with saved reward receipts.

frei

Target
vergeben
Condition
G-21 is atomically allocated to a valid contender according to the server’s input order.

vergeben or beendet

Target
terminal
Condition
Reallocation is blocked; the record remains available.

Fence authority generations

Fence authority generations

Bind every durable record to the current authority generation.

An old game process continues after a network partition.

The datastore rejects old generations even while their clients remain connected.

Alternative considered
Changing only the router leaves the old writer able to act.
Trade-off
A generation change requires an atomic leadership decision.
Reassess
The game rules require multiple writers for one world.

Terms in this step

Fence authority generations
The datastore rejects old generations even while their clients remain connected.

Try it yourself

Let an old and a new game process write concurrently. Mark the boundary that rejects the old process.

A hint for your attempt

Use the specific entities and conditions from this step. The two solution parts distinguish the decision from its evidenced outcome.

Compare with a possible solution
First part of the solution
The reward datastore atomically checks the current authority generation on every write. A router change alone is insufficient.
Second part of the solution
The old process receives a generation conflict and cannot reallocate G-21. The new process retains the existing winning record.

Apply to your project

Which corresponding assumption would you test first in your project? Consider this trigger: The game rules require multiple writers for one world.

Step 6 examines a separate simulation process.