Bandwidth Budgets
Before writing netcode, do the arithmetic. How many bytes does each snapshot need, how often is it sent, to how many players? The answer tells you whether your design works on a home connection, what server egress costs, and which compression tricks you actually need.
The numbers to plan with
| Limit | Value to plan with | Why |
|---|---|---|
| Safe UDP payload | about 1200 bytes per packet | Packets larger than the path's MTU (usually 1500 bytes on Ethernet, less over VPNs and mobile tunnels) get fragmented or dropped. Lose one fragment and the whole datagram is lost. QUIC uses 1200 bytes as its minimum for the same reason |
| IPv4 + UDP headers | 28 bytes per packet (IPv6 + UDP: 48) | paid on every packet, so many tiny packets are wasteful |
| Client upload | keep game traffic in the tens of kbit/s | home and mobile uploads are small and shared with video calls and other people's uploads |
| Client download | aim for under ~1 Mbit/s for action games | many players are on mobile data, congested Wi-Fi or another continent |
| Server egress | sum over all players | you pay for it per GB at most cloud providers |
A budget calculation
A 16-player shooter, server snapshots at 30 Hz, every player sees every other player:
using System;
int players = 16, snapshotHz = 30, inputHz = 60;
int headerBytes = 28; // IPv4 + UDP
int packetHeader = 8; // our protocol: sequence, ack, ack bits
int bytesPerPlayer = 14; // quantized position, yaw, pitch, animation, health
int inputBytes = 6; // buttons + aim, sent 3 times for redundancy
int snapshotBytes = packetHeader + (players - 1) * bytesPerPlayer;
double downKbps = (snapshotBytes + headerBytes) * snapshotHz * 8 / 1000.0;
double upKbps = (packetHeader + 3 * inputBytes + headerBytes) * inputHz * 8 / 1000.0;
double serverMbps = downKbps * players / 1000.0;
double gbPerHour = serverMbps * 3600 / 8 / 1000;
Console.WriteLine(quot;snapshot payload: {snapshotBytes} bytes (limit ~1200)");
Console.WriteLine(quot;per client down: {downKbps:F1} kbit/s, up: {upKbps:F1} kbit/s");
Console.WriteLine(quot;server egress per match: {serverMbps:F2} Mbit/s = {gbPerHour:F2} GB/hour");
Console.WriteLine(quot;header share of a snapshot packet: {100.0 * headerBytes / (snapshotBytes + headerBytes):F0}%");snapshot payload: 218 bytes (limit ~1200)
per client down: 59.0 kbit/s, up: 25.9 kbit/s
server egress per match: 0.94 Mbit/s = 0.43 GB/hour
header share of a snapshot packet: 11%
That fits easily. Now change one number at a time and watch the budget move: 100 players instead of 16 (a battle royale) makes each snapshot more than 6 times bigger (1394 bytes, already over the packet limit) and sends it to 6 times more people, so server egress grows about 40-fold. Interest management and delta compression stop being optional at that point.
Notice also the upload: sending inputs at 60 Hz costs more in headers than in input data. Sending 2 ticks of input per packet at 30 Hz halves the header cost; redundancy keeps it robust to loss.
When the snapshot doesn't fit: priority
When there are more entities than fit in one packet, the server has to choose. A common scheme is a priority accumulator: every entity gains priority each tick (faster for important or nearby ones). The server fills the packet in priority order until the byte budget is used up, and resets the priority of whatever it sent. Entities that were skipped have higher priority next time, so nothing is starved forever.
type E = { name: string; weight: number; bytes: number; acc: number };
const ents: E[] = [
{ name: 'enemy near', weight: 10, bytes: 14, acc: 0 },
{ name: 'ally near', weight: 6, bytes: 14, acc: 0 },
{ name: 'rocket', weight: 8, bytes: 10, acc: 0 },
{ name: 'enemy far', weight: 2, bytes: 14, acc: 0 },
{ name: 'door', weight: 1, bytes: 4, acc: 0 },
{ name: 'crate', weight: 0.5, bytes: 8, acc: 0 },
];
const BUDGET = 40; // tiny on purpose, so not everything fits
for (let tick = 1; tick <= 8; tick++) {
for (const e of ents) e.acc += e.weight;
const order = [...ents].sort((a, b) => b.acc - a.acc);
let used = 0;
const sent: string[] = [];
for (const e of order) {
if (used + e.bytes > BUDGET) continue; // doesn't fit: try smaller ones
used += e.bytes;
sent.push(e.name);
e.acc = 0;
}
console.log(`tick ${tick}: ${used} B [${sent.join(', ')}]`);
}tick 1: 38 B [enemy near, rocket, ally near]
tick 2: 38 B [enemy near, rocket, ally near]
tick 3: 38 B [enemy near, rocket, ally near]
tick 4: 38 B [enemy near, rocket, enemy far]
tick 5: 38 B [ally near, enemy near, rocket]
tick 6: 38 B [enemy near, rocket, ally near]
tick 7: 36 B [enemy near, rocket, door, crate]
tick 8: 38 B [ally near, enemy near, rocket]
The near enemy and the rocket go out every tick and the ally most ticks. The far enemy gets a slot at tick 4, and the door and the crate, whose priority grew slowly, finally go out together at tick 7. Nobody waits forever. The weights are where game knowledge goes: distance, whether the entity is in view, whether it just changed (a door that just opened matters more than one standing open).
Measure, don't guess
- Log bytes per message type per second on the server, and show them in a debug overlay. The surprise is almost always one chatty message (a per-frame "aim changed" RPC, a debug string).
- Engines have profilers for this: Unity's Multiplayer Tools and Network Profiler, Unreal's Networking Insights, Godot's network profiler in the debugger (Network Conditioners, Wireshark & Profilers).
- Test the worst case, not the average: everyone in one room, firing, at the end of a round.
Test yourself
Why do game protocols keep UDP payloads around 1200 bytes or less?
- UDP can't carry more
- Larger datagrams may be fragmented, and losing any fragment loses the whole datagram
- Routers prioritize small packets
- Encryption requires it
What does a priority accumulator guarantee that sorting by importance alone does not?
- Smaller packets
- Every entity is eventually sent, because skipped entities keep gaining priority
- Reliable delivery
- Lower latency for every entity