P2P vs DGS: Experts discuss
Our aim is to democratize game development by providing the education and tools needed to create and operate multiplayer experiences. In this guide, we’ll cover the basics of different network and server model options for your multiplayer game.
What are multiplayer network models?
Network models for multiplayer games describe the architecture and design used to establish communication between the source of information and destination – such as between a client and server, or between peers.
- Server: The entity that holds the final say in what is the current state of the world.
- Client: An entity that shares their version of the game/world state to the server.
All connected devices hold a version of the world, and the main problem being solved with multiplayer network models is that a netcode solution is trying to deliver the same experience to all connected players – as smoothly as possible.
- Client-server model: A model in which there’s a “server” that sends information to the “clients” that consume that information.
- Peer-to-peer model: A model in which all players are connected together directly without a server.
What is a client-server model?
Client-server architecture is a model in which there’s a “server” that hosts the game logic and sends information to the “clients” that consume that information and act accordingly. The clients can also send data to the server, such as inputs and actions.
In this model:
- Any provider of information or services is referred to as a server
- The service requesters and receivers of that information are referred to as clients
The server in this scenario is likely a dedicated game server, purely focused on simulating the game state and relaying information.
Alternatively, a player could also be assigned a server (or host) role in a typical peer-to-peer topology.
What is a peer-to-peer model?
A peer-to-peer model connects all players together directly without a server or dedicated host. Unlike client-server models – which require an assigned server that holds the final say in the state of the world – in a P2P model, each player’s device is responsible for running the game logic and negotiating with others.
A P2P network can be:
- An ad hoc connection – two devices connected to share files.
- A permanent infrastructure that links a half-dozen computers in a small office over copper wires.
- A network on a much grander scale in which special protocols and applications set up direct relationships among users over the Internet.
What are multiplayer server models?
Server models define which “expression” of client-server model is used and dictates who is the “server” in the client-server relationship.
The main two server models are:
- Client-hosted: A model where one player in the game acts as the host, and their device is the authority on the game state
- Dedicated game server: A model where the game simulation is run on a separate device. This device is the authority on game state but is not playing or rendering the game
There are a variety of server models your multiplayer game can choose from, and each are suitable for different genres of games.
What is a client-hosted server?
A client-hosted server (also known as a listen server) is a model where the game logic is hosted on one of the player's own machines rather than a separate dedicated server. The host machine acts both as a server and as a client.
This means one of the players will both play and own the game world and other players will connect to it. This model has performance, security, and reliability considerations to be taken into account.
What is a dedicated game server?
A dedicated server model is where the game logic is hosted on a separate machine from players. Dedicated servers simulate game worlds without supporting direct input or output, except what is required for administration. These servers act as the state machine where all of the telemetry of networked objects within the simulation are reconciled.
Dedicated game servers can also compensate for network latency (lag) by using netcode features such as interpolation and prediction. Players must connect to the server with separate client programs in order to see and interact with the game, however; the game server is the authority of where everything sits inside of the simulation, and where it is at any time.
As the logic is hosted on a device separate from the players/clients, a dedicated game server model is more secure, since the IPs of players connecting to that server would not be exposed to an opponent like they would in the client hosted model.
Choosing your server model
These nine key factors come into play when choosing your server model:
- Latency: The amount of latency tolerable within the game.
- Players per session: The amount of network connected players in each game session.
- Synchronized simulation scale: The amount of the simulation you choose to keep in sync across your connected players.
- Precision: The exactness requirements of the shared experience.
- Cost: The cost to create, maintain, and operate the game.
- Complexity: How complex the networking solution is and how experienced your team would need to be to implement it successfully.
- Cheat mitigation: How important is it to attempt to prevent players from cheating.
- Lock-in: Whether or not the solution is difficult to change in the future.
- Netcode: Some netcodes are limited in their ability to compensate for lag, and yet others might not support a specific multiplayer model P2P vs DGS