TExcelTAD
Home › Multiplayer Game Networking › Field Notes: Running Game Servers

Field Notes: Running Game Servers

Shipping the netcode is half the job. The other half is keeping hundreds of server processes healthy while players hammer them at peak hours. These notes come from live operations: what to measure, how to deploy, and what tends to break.

1. Watch the tick time, not the CPU average

A server at 30 Hz has a 33 ms budget per tick. If one tick in a hundred takes 60 ms, the average CPU looks fine while every player feels a hitch every three seconds. Track tick duration as a distribution and alert on the high percentiles (p99, max per minute), per match:

csharp · try it yourself
using System;
using System.Linq;

var rng = new Random(12);
double budget = 1000.0 / 30;
// 3000 ticks: mostly 8-14 ms, plus a GC pause or a big explosion now and then.
double[] ticks = Enumerable.Range(0, 3000)
    .Select(i => rng.NextDouble() < 0.02 ? 35 + rng.NextDouble() * 40 : 8 + rng.NextDouble() * 6)
    .OrderBy(x => x).ToArray();

double P(double p) => ticks[(int)Math.Ceiling(p * ticks.Length) - 1];
Console.WriteLine(
quot;average {ticks.Average():F1} ms (budget {budget:F1} ms)"); Console.WriteLine(
quot;p50 {P(0.50):F1} p95 {P(0.95):F1} p99 {P(0.99):F1} max {ticks.Max():F1} ms"); Console.WriteLine(
quot;ticks over budget: {ticks.Count(t => t > budget)} of {ticks.Length}");
average 11.7 ms  (budget 33.3 ms)
p50 11.1  p95 13.8  p99 49.7  max 74.2 ms
ticks over budget: 44 of 3000

The average says "a third of the budget, all good". The p99 and the count of over-budget ticks say players are getting hitches. When you find one, the usual causes are garbage collection, a synchronous database or HTTP call on the game thread, logging to disk on the game thread, or an O(n²) loop that only shows up with many players in one place.

2. Never block the game thread

Anything that waits for I/O (saving results, calling the matchmaking API, validating a token you didn't cache, writing logs) goes to a background worker or queue. The game loop only reads finished results. A 300 ms hiccup in your database must never become a 300 ms freeze for 64 players.

3. Metrics worth a dashboard

Metric Why
Tick duration p50/p99/max per match performance hitches
Players and matches per server and region capacity, autoscaling
RTT and packet loss per region (from the clients' acks) network problems, bad routes, region placement
Bytes per second per message type bandwidth regressions after a patch
Corrections per minute per player (prediction errors) desync bugs, or speed hacks
Rejected inputs and rate-limit kicks cheating, bugs in the client
Connects, disconnects, reconnects, timeouts infrastructure issues, DDoS
Crashes per build version a bad deploy

4. Logs need tick, match and player

Structured logs (JSON lines) with matchId, tick, playerId (the account's stable id, never an email) and build in every line. Keep input recordings and periodic state checksums for a while, so a reported bug can be replayed. Never log access tokens or connect tickets (Accounts & Sign-In).

5. Deploy without killing matches

  • Drain, don't kill: a new build stops new matches on old servers, and old servers exit after their current match ends. Your orchestrator must support it (Dedicated Servers & Hosting).
  • Version the protocol: clients and servers check the protocol version on connect; matchmaking only pairs a client with servers of a compatible version. During a rollout both versions exist side by side.
  • Handle SIGTERM: finish or save the match, tell clients why, then exit.
  • Roll out by region or percentage and watch crash rate and tick-time metrics before going wider.

6. Plan capacity from measurements

Measure one match on the target hardware (CPU per tick, memory, bandwidth) under a realistic load, ideally with headless bots that join, move, shoot and leave. Then the arithmetic is simple, and you can keep a buffer of ready servers for spikes:

ts · try it yourself
const peakPlayers = 24_000, playersPerMatch = 12;
const cpuMsPerTick = 6.5, tickHz = 30;            // measured with bots on the target VM
const coresPerVm = 8, safety = 0.7;                // never plan above 70% CPU

const matches = Math.ceil(peakPlayers / playersPerMatch);
const coreShare = (cpuMsPerTick * tickHz) / 1000; // fraction of a core one match needs
const matchesPerVm = Math.floor((coresPerVm * safety) / coreShare);
const vms = Math.ceil(matches / matchesPerVm);
console.log(`${matches} concurrent matches, each needs ${(coreShare * 100).toFixed(1)}% of a core`);
console.log(`${matchesPerVm} matches per ${coresPerVm}-core VM at ${safety * 100}% target -> ${vms} VMs at peak`);
console.log(`if a patch makes ticks 30% slower: ${Math.ceil(matches / Math.floor((coresPerVm * safety) / (coreShare * 1.3)))} VMs`);
2000 concurrent matches, each needs 19.5% of a core
28 matches per 8-core VM at 70% target -> 72 VMs at peak
if a patch makes ticks 30% slower: 91 VMs

A 30% performance regression costs about a quarter more servers at peak (91 instead of 72 VMs). Put tick time into your CI performance tests.

7. Protect the servers

  • Game servers have public UDP ports, so they will see DDoS attacks, especially in competitive games. Use your host's or a relay's DDoS protection, keep server IPs out of public view (relays help), and rate-limit unauthenticated packets before doing any work (Rate Limiting & Abuse).
  • Check the connect ticket before allocating a slot (Connections, Timeouts & Reconnects).
  • Run servers with least privilege: no admin rights, no secrets they don't need, separate credentials per environment.

8. Put servers near players

Latency is mostly distance. Cover your player base with regions, let the client measure ping to each region (most hosting providers offer ping beacons for this), and match players within a region. A server in the "right" country but behind a poor route can still be worse than one further away, so measure from real clients.

9. Keep server clocks in sync

Servers' system clocks should be synced with NTP (or the cloud provider's time service). Game time inside a match comes from a monotonic clock; wall-clock time is only for logs, timestamps in the database and token expiry checks, where a few seconds of skew already break JWT exp validation.

10. Have a kill switch

Feature flags for risky features (a new game mode, a new anti-cheat rule) let you turn them off without a deploy. Combined with server-side configuration of tick rate, max players and rate limits, they turn a launch-night incident into a config change.

Test yourself

Average tick time is 12 ms on a 30 Hz server (33 ms budget). Why might players still complain?

  1. 30 Hz is too low for any game
  2. Rare long ticks (p99 or max above the budget) cause regular hitches that the average hides
  3. The average must be exactly 33 ms
  4. CPU usage is too low

How should a server deploy a new build without disrupting play?

  1. Restart every server at once
  2. Stop sending new matches to old servers and let them exit after their current matches (draining)
  3. Push the new binary into running processes
  4. Ask players to reconnect

Where should a game server save match results to a database?

  1. Synchronously inside the tick
  2. On a background worker or queue, so database latency never stalls the game loop
  3. In the client
  4. Only on shutdown