GitHub Icon

Platform

Solutions

Resources

Company

What Are Relays Servers for Multiplayer Games? A Peer-to-Peer Networking Guide

While often invisible to players, multiplayer game infrastructure that supports secure player connectivity and game stability is as crucial as the gameplay itself.

One key component in this infrastructure that is often overlooked is the relay server.

In this post, we'll delve into the role of Relay servers in peer-to-peer networking, and touch upon the specifics of baseline relay services, such as Unity, Steam, Epic Online Services and their use case, alongside where and when improved relay services are preferrable, alongside touching the broader topic of game server hosting and why servers sometimes go offline.

What is a Relay Server in Multiplayer Games?

In short, in the context of online games, a Relay server elevates and solves the common issues of peer-to-peer by acting as an “intermediary” server that forward communication between players.

In other words, relays act as bridges (or routers/proxies), relaying messages between peers that cannot establish direct connections. By relaying data between players, they play a crucial role in establishing connections between players who may encounter obstacles such as firewalls or network address translation (NAT) issues. These NAT issues are so extremely common, that companies such as XBOX or PlayStation will have entire support pages dedicated to them.  

Relays usually improve the gaming experience by reducing latency and packet loss, provided that the relay server itself is robust, and the orchestration service used by the  relay server iperformed geographically relative to the players. Otherwise, the Relay will introduce latency, potentially reducing fairness between players who are near the relay, and those who aren’t (if one of the game client is acting as the authoritative server).

Understanding Peer-to-Peer Architecture in Modern Gaming

Peer-to-peer networking architecture is an entrenched part of multiplayer games backend structure. In a P2P setup, one of the players' machines acts as the server, handling the game logic and synchronization for all participants.

This approach often minimizes developers' costs, as a player handles the hosting of the match, and is more straightforward to implement. For smaller titles, or studios who find the hosting fees too steep, it is a great choice. However, it often results in less than ideal play experience – with inconsistent game performance, particularly if the host player lacks a high speed internet connection or adequate hardware. Worse yet, P2P can easily be abused by cheaters to manipulate the game and hackers that can attack your players, making this a terrible solution for any studio looking to make competitive play a long-tail retention strategy for their game, and will lower long term retention as highly engaged players likely won’t perceive the interest on continued investment over time in the game.

However, titles big and small, namely indies to AAA, are shifting towards either a full or hybrid game server model to ensure stability and fairness, that incorporates authoritative game servers alongside relays game server.

Cheating Techniques in Peer-to-Peer Networking

A major challenge of P2P is bad actors exploiting the vulnerabilities of P2P hosting, namely cheaters have devised various methods to gain an unfair advantage or disrupt the gaming experience for others:

  • Lag Switching: Cheaters can intentionally introduce lag to disrupt the flow of the game. By delaying their data transmission, they can 'freeze' the game momentarily and make moves without other players being able to respond in real time.

  • Data Manipulation: Since game data resides on individual clients, a cheater can modify their data to give themselves infinite health, unlimited ammunition, or even change their location instantly.

  • Ghosting: In games where players are supposed to have limited visibility of the map or other players, a cheater could gain complete visibility, giving them an unfair advantage.

Why Do Game Servers Go Down or Shut Down?

Server downtime is always a frustrating period of time for gamers. It often occurs due to maintenance, updates, unforeseen issues, or even cyber-attacks. In some cases, game servers are permanently shut down, a decision typically driven by the game's declining player base, financial considerations, or the release of sequels, newer titles, and limited resources of the studio.

Relay Service: Free or Not?

Relays are game servers used to help players connectwithout generating compute cost, meaning players themselves remain the gatekeepers to authorize the game’s actions. As such, the servers needed are minimal. Companies such as Epic, with Epic Online Services and Steam with Steamworks provide game developers with relays free of charge when using their backend solutions.

While a great steppingstone, these services are extremely limited in terms of locations, and aren’t known to be the most reliable. Here’s the breakdown of why free relay services aren’t ideal for commercially produced games:

  • Increased Latency: Introducing an intermediary can potentially increase the game’s latency if the relay server is geographically distant from the players. It is therefore critical to pair it with an automated orchestration system that deploys relays nearest to users. With a low coverage density, these services are known to introduce latency.

  • Reliability: If a relay server goes down, it will disrupt the gaming experience for connected players. If all relays are hosted on the same provider and an outage occurs, all players will be taken offline. Therefore, only a multi-cloud relay orchestration network can ensure high reliability.

  • Authoring: Still, relay network are not an authoritative server. Thus, they can’t replace a central server authority for highly competitive, fast paced games.

Is Unity Game Hosting Free?

The straightforward answer is no; Unity game hosting is not free.

Unity offers various tiers, including some free services to get started, but serious hosting solutions for multiplayer games usually have associated costs. These costs are tied to bandwidth, the number of concurrent users, number of requests, and other variables.

Unity Technologies have introduced several services to aid developers in creating multiplayer games, including the Unity Relay service, however, it's crucial to note that Unity Relay is not free. While Unity provides a robust ecosystem for game development, including tools for multiplayer game creation, services like Relay are typically offered under a pricing model that scales with usage.

Unity's Relay service aims to simplify establishing and maintaining network connections for multiplayer games, offering a more reliable and scalable solution than traditional P2P. Developers should carefully consider the costs of using Unity Relay, particularly for games with large player bases or high volume of network traffic.

Introducing the Network of Relays: A Potential Solution

A convenient and easy to integrate way to counter some of the vulnerabilities of P2P hosting is by using a network of relays.

Instead of players connecting directly to each other, they connect to Relay servers, which then handle the data transmission between players. These are much easier to integrate than authoritative server, and cheaper to run, and provide massive benefits over pure P2P hosting.

Benefits include:

  • Shielding of IP Addresses: Players' IP addresses are hidden from each other since they only connect to the relay server. Relays prevent IP-based attacks and safeguard player privacy.

  • Fairness in Connection Quality: Since everyone connects to the relay, any network advantages (like being the host in a P2P scenario) are neutralized. Everyone experiences a more consistent connection quality.

  • NAT: By design, relays solve P2P’s NAT well-documented connectivity issues by acting as a go-between between users for seamless connections and player experience. Specifically, it overcomes NAT traversal and firewall restrictions.

  • Potential for Cheating Detection: Relay servers can be equipped with anti-cheat algorithms that monitor game data in real time. Suspicious patterns or anomalies can be flagged, making it easier to detect and deter cheaters.

Relays for WebGL games

WebGL games are especially susceptible to issues with traditional relays. WebGL games tend to have easily 2-5 times more latency because on WebGL websocket cannot NAT punch through directly, it needs relay server (STUN server) for NAT (network address translation).

This further reinforces the need for an orchestration service that can help overcome this latency challenge, such as Edgegap, that deploys nearest to users on a highly dense worldwide network to mitigate this inherent problem of multiplayer WebGL games.

Upgrading from Relay: Authoritative Game Servers?

Game server hosting refers to providing online infrastructure for multiplayer games. This includes dedicated servers that run 24/7, ensuring players can connect and play together regardless of location. Hosting can be managed by game developers themselves, or third-party companies.

Effective game server hosting is crucial for game's online components, impacting everything from latency to matchmaking. As multiplayer experiences become more central to gaming, the quality, reliability, and scalability of server hosting become paramount for developers and players alike.

For more details on why, and when, authoritative servers may be better suited than relays, see our Networking Types guide here.

Conclusion

Understanding the nuances of game server infrastructure, from relay servers to hosting solutions, is vital for game developers and the gaming community.

While basic relay services may offer streamlined solutions, they come with their costs and considerations to your game and your player’s experience.

A smart network of relays powered by automated orchestration and deployed on a global, region-less distributed network provides the benefits that can far outweigh their infrastructure costs and the cost of opportunity directly correlating with player’s experience

Learn more about Edgegap’s Distributed Relay, or directly from our Documentation.