Overview
In this installment of our networking basics series, we dive into the crucial distinction between bandwidth and latency. For a home lab setup, understanding these concepts is vital, but nowhere more so than when setting up a game server where even milliseconds can make or break the player experience.
Background
Bandwidth refers to how much data can be transferred per second, while latency measures the time it takes for a single packet of data to travel from one point to another. These two metrics are often conflated, but they serve different purposes and have distinct impacts on network performance. In my home lab setup, I've been focusing on optimizing both aspects, particularly for game servers.
How It Works
Bandwidth vs Latency: The Basics
Bandwidth is about throughput—how much data can be sent or received in a given time. For example, a high-speed internet connection might offer 1 Gbps (gigabit per second) of bandwidth, allowing you to download large files quickly.
Latency, on the other hand, measures the delay between sending and receiving packets. This is crucial for real-time applications like gaming or video conferencing. A low latency means that data travels quickly from one point to another, ensuring a smoother experience.
Game Hosting Example
Consider hosting a game server such as Minecraft or Valheim. These servers send frequent but small state updates (packets) to players. The total bandwidth required per player might be minimal—often under 1 Mbps—but every packet must arrive on time. A round-trip delay of just 30 milliseconds can make the difference between a smooth game experience and lag.
Physical Distance and Latency
The speed of light limits how fast data can travel over long distances. For instance, adding about 10 milliseconds to your latency for every 1000 kilometers (621 miles) of fiber optic cable. This means that hosting a game server in the same region as most players can significantly reduce lag compared to hosting it halfway across the country.
Common Latency Issues in Home Labs
- WiFi Hops: Each hop on a WiFi network introduces latency, typically between 5 and 30 milliseconds. For critical applications like gaming, it's best to wire servers directly.
- Bufferbloat: An overloaded router can queue packets, causing ping spikes that can reach hundreds of milliseconds during upload-heavy tasks.
- ISP Routing: The ISP itself can introduce additional latency due to its routing decisions.
Results
Practical Tools and Metrics
To measure these issues, I've been using the following tools:
- Ping: Measures round-trip time (RTT) between two points.
- MTR (My Traceroute): Provides per-hop information to help identify where latency is introduced.
- iperf3: Tests bandwidth between lab machines on the local network. In my setup, this should be near line rate—around 940 Mbps for gigabit Ethernet.
- Speedtest: Measures internet speed over the WAN (Wide Area Network).
- Waveform Bufferbloat Test: Identifies bufferbloat issues in your network.
Design Decisions
Based on these findings, I've made several design decisions to optimize my home lab:
- Game Traffic Bypasses Cloudflare Tunnel: The tunnel adds an extra hop, which is fine for websites but problematic for UDP game packets. Game traffic should be kept as direct as possible.
- Wired Servers: To minimize latency and jitter, servers are wired directly to the network switch.
- Upload Headroom Matters More Than Download: For hosting game servers, ensuring sufficient upload bandwidth is more critical than download speed.
Impact on /api/status
Publishing host load averages helps in diagnosing issues. A pegged CPU can introduce server-side tick lag that players might attribute to network problems. To rule out network issues, it's essential to verify that the host isn't causing additional latency.
Lessons Learned
Understanding the difference between bandwidth and latency is crucial for optimizing a home lab setup, especially when hosting real-time applications like game servers. By focusing on minimizing latency and ensuring sufficient upload headroom, you can provide a better experience for your players or users.
By keeping these principles in mind, I've been able to significantly reduce lag and improve the overall performance of my game server in the BreadLab environment.