Skip to content
PN Scripts

Games

What a multiplayer game backend needs

  • PN Scripts Team
  • 6 min read

A multiplayer game backend needs six parts: player accounts, sessions and matchmaking, a server with authority over the game state that matters, durable storage for progress and saves, an economy validated on the server, and tools for live operations and patches. How far you take each part depends on the game. A co-op game for friends can trust players more than a competitive shooter with paid items, and the cost of the backend follows that choice.

#Start with the genre and the cheating risk

Before choosing technology, answer two questions: what happens if a player cheats, and who pays for the servers? The answers set the network model.

Game typeTypical modelTrade-off
Co-op with friendsOne player hosts, or a relay connects peersCheap to run, but the host can cheat
Competitive or rankedDedicated authoritative serversFair matches, with a server bill for every match
Turn-based or asyncWeb API and database, no real-time serverSimple and cheap, but latency hides nothing
Persistent worldAuthoritative servers plus shared world storageThe most backend work of all

Many games mix these. A shooter can run authoritative match servers while its profile, inventory and store are a normal web API with a database behind it.

#Accounts, sessions and matchmaking

Players should not need a new password to play. Most games sign players in through the platform they already use, such as Steam, PlayStation Network, Xbox, Game Center or Google Play Games, and then link that identity to an internal player ID that belongs to you. That internal ID is what lets one player keep their progress across platforms if you add cross-play later.

  • Guest accounts lower the barrier on mobile, but plan how a guest upgrades to a full account without losing progress.
  • Session tokens should be short-lived and checked by every service, including the game server when a player joins a match.
  • Account deletion is part of the design. Apple requires apps that let users create an account to also let them delete it from inside the app.

Matchmaking puts players into a queue and forms matches by rules: skill rating, region, latency, party size and game mode. Good matchmakers widen the rules the longer a player waits, so a player at an unusual skill level or at an off-peak hour still gets a game. When a match forms, the backend allocates a server, sends connection details to the players, and fills empty slots if someone leaves, a process called backfill.

#Server authority and cheating

In an authoritative setup, the client sends only inputs, such as "move forward" or "fire", and the server runs the simulation and decides the result. The client never reports "I hit that player for 100 damage" or "I now have 5,000 coins". It asks, and the server decides.

Pure authority would feel slow on a real connection, so games add three techniques on top:

  • Client-side prediction: the player's own character moves at once, and the client corrects itself when the server's answer arrives.
  • Interpolation: other players are drawn slightly in the past, between known positions, so their movement looks smooth.
  • Lag compensation: when checking a shot, the server rewinds other players to where the shooter saw them.

The server also checks what inputs are plausible: movement speed, fire rate, line of sight, cooldowns. Client-side anti-cheat tools make cheating harder, but they complement server checks and do not replace them. Anything the client controls, a determined player can change.

#Persistence and saves

Separate two kinds of data. Match state, such as positions, health and the score, lives in the game server's memory for a few minutes and is thrown away. Player data, such as level, unlocks, inventory and purchases, lives in a database and must survive crashes, patches and server moves.

  • Write at clear moments: at the end of a match, on a checkpoint, or after a purchase, and inside a database transaction, so a crash never leaves half a reward.
  • Version the save format. Every patch that changes what a save contains needs a migration that upgrades old saves, tested on real examples.
  • Decide how cloud save conflicts resolve. A player who plays offline on two devices creates two different saves. "Last write wins" is simple but can erase progress, so for valuable data, merge or ask the player.
  • Back up and test restores. Progress is what players care about most, and a lost inventory is the fastest way to lose a community.

#An economy validated on the server

If players can earn, spend, buy or trade something, the economy lives on the server. The client shows balances and sends requests. The server checks the request, applies it and records it.

  • Keep a ledger. Record every grant and every spend as an entry with a reason, instead of only overwriting a balance. It lets you answer support tickets and find exploits.
  • Validate store purchases on the server. Apple and Google both provide server APIs to verify in-app purchases. Grant items only after verification, and make the grant idempotent so a retried request cannot deliver the item twice. The same technique is described in what a reliable API integration needs.
  • Make trades atomic. Moving an item from one player to another must happen in a single transaction, or you create a duplication exploit.
  • Give designers admin tools. Prices, drop rates and rewards should be data your team can change from a dashboard, with an audit log, without shipping a new client.

#Live operations and patches

A released multiplayer game changes every week, and the backend decides how painful that is.

  • Remote configuration and feature flags let you tune balance values, start events and switch off a broken feature without a client update. On mobile this matters most, because a new build has to pass store review before players get it.
  • Version checks at login tell the client whether it is compatible with the servers, and send outdated players to update instead of letting them fail inside a match.
  • Rolling server updates start new servers on the new version and let old ones drain as their matches end, so nobody is kicked mid-game.
  • Monitoring covers concurrent players, time to find a match, server crashes, error rates per endpoint and the health of the database. Set alerts on the numbers that mean players are waiting or failing to connect.
  • A rollback plan for both client config and server builds, practiced before launch day.

Start small. A first playable online build can run with platform login, simple matchmaking, a single region and a handful of admin tools. Add regions, ranked queues and events once real players show where the pressure is.

#How PN Scripts can help

PN Scripts builds gameplay in Unity, Unreal, Godot or WebGL together with the online services behind it: accounts, cloud saves, matchmaking hooks and purchases, in Go, Laravel or another fitting stack. The network model is chosen for your genre, cheating risk and latency budget. You can see how we approach a project on the game development page.

Keep reading

Keep reading

Comments

Comments

Be the first to leave a comment.

Leave a comment

Next step

pnscripts.com/contact

Talk to the team

Ask about an article, or tell us about a project you want built. We reply within one business day.

Write to us

The PN Scripts family

Other PN Scripts sites

Hosting, games and the blog each have their own site, run by the same company.

  • pnscripts.com

    PN Scripts

    Software engineering

    Custom web, mobile, API and game development, plus our open-source products and plugins.

  • games.pnscripts.com

    Games

    Games and game servers

    The home for PN Scripts games and game servers. The catalog is empty for now and fills up as titles and servers go live.

  • hosting.pnscripts.com

    Hosting

    Hosting and infrastructure

    Shared hosting, KVM VPS, dedicated servers and domains, from the same company that builds your project.

  • blog.pnscripts.com

    Blog

    Articles and field notes

    Plain articles on hosting, servers, domains and security, written by the people who work with them.

    You are here