Full answer
Requirements
Functional:
- Players queue for a match; matchmaking finds 100 players of similar skill and low latency.
- During the match, every player sees others move and shoot in near real time; the server decides hits.
- After the match, results update ranks and rewards.
Non-functional:
- Round-trip latency under about 80 ms for most players; tolerate packet loss.
- Cheating is hard: clients cannot decide outcomes.
- A crashed game server affects only its own match.
Capacity estimates
Assumptions: 1M concurrent players, 100 per match, 30 ticks per second, 20 bytes per entity update after delta compression, each player receiving updates for about 20 nearby entities.
- Matches: 1M / 100 = 10,000 concurrent.
- Naive snapshots (every player gets all 100 players at 100 bytes, 30 times a second): 100 x 100 x 30 x 100 bytes = 30 MB per second per match, too much.
- With interest management and deltas: 100 players x 20 entities x 30 ticks x 20 bytes = 1.2 MB per second per match, about 10 Mbps.
- If one host runs about 20 matches, that is about 500 hosts across regions.
API
POST /v1/matchmaking/tickets {"mode": "battle-royale", "region_pings": {"ap-south": 32, "ap-southeast": 71}}
-> {"ticket_id"}
GET /v1/matchmaking/tickets/{id} -> {"status": "MATCHED", "server": "203.0.113.7:7777", "token": "..."}
UDP client -> server: {seq, input bits, aim, client_time} server -> client: {tick, ack_seq, delta snapshot}
POST /v1/matches/{id}/results (game server -> backend, signed)
Data model
players: player_id, skill rating, region, inventory (in a normal database).- Matchmaking queues in memory (Redis or the matchmaker's own state), keyed by mode and region.
matches: match_id, server address, players, started_at, result.- Game state lives only in the game server's memory during the match.
High-level design
flowchart LR
C[Game client] --> API[Backend API]
API --> MM[Matchmaker]
MM --> FL[Fleet manager]
FL --> GS[Dedicated game server]
C -- "UDP inputs and snapshots" --> GS
GS -- "signed results" --> API
API --> DB[(Players, ranks, inventory)]Game loop
Every tick (33 ms at 30 Hz) the server:
- Applies the inputs received from each player.
- Simulates movement and physics; resolves hits with lag compensation (rewinding other players' positions to what the shooter saw).
- Sends each player a snapshot of what changed among entities relevant to them, as a delta against the last snapshot that player acknowledged.
Clients predict their own movement immediately and interpolate others between snapshots, then correct when the server's state differs. UDP is used because a late position update is useless; resending it (as TCP would) only adds delay.
Bottlenecks and trade-offs
- Matchmaking trades wait time against match quality: widen the skill range and region over time while a ticket waits.
- Tick rate. Higher rates feel better but cost CPU and bandwidth linearly; 20 to 60 Hz is typical depending on the genre.
- Authority. The server decides outcomes; client prediction keeps it responsive. Lag compensation helps shooters but can let a target be hit "behind a wall" from their own view.
- Fleet scaling. Pre-warm servers ahead of peak hours; matches cannot move between hosts, so draining a host means waiting for its matches to end.
- Cheating. Server authority stops speed and teleport hacks; aim bots need separate detection from behaviour data.
By level
Fresher: Explain matchmaking, a server per match and why the server, not the player's device, decides who wins. A fresher should know the server updates the game many times per second.
Mid: Do the bandwidth math, explain UDP, tick loops, delta snapshots and interest management, and describe client prediction. Mention fleet sizing.
Senior: Discuss lag compensation trade-offs, tick rate economics, fleet draining, matchmaking expansion policies and cheat detection. Expect precise reasoning about what happens each tick.
Key points
- Matchmaking by skill and region, then a dedicated authoritative server per match
- UDP inputs and fixed tick simulation
- Delta snapshots and interest management cut bandwidth from 30 MB to 1.2 MB per second per match
- Client prediction and server reconciliation
- 10,000 concurrent matches for 1 million players
Common mistakes
- Letting clients report hits or positions as truth
- Using TCP and suffering head-of-line delays
- Sending full world state to every player each tick
- Ignoring region latency in matchmaking
Follow-ups
- How does lag compensation work?
- How would you handle a game server crash mid-match?
- How do you scale matchmaking for many modes and regions?
Tips
- Do the naive versus optimised bandwidth math
- Explain the tick loop step by step
- Separate matchmaking, game servers and the persistent backend
Evaluation rubric
- Clear architecture with authoritative servers
- Correct bandwidth reasoning
- Latency techniques: prediction, interpolation, lag compensation
- Matchmaking and fleet trade-offs