Setting Up Server and Backend for Games
Game server is not "just a backend". Web app processes HTTP requests with seconds interval. Game server in real time processes 20–60 ticks per second from each of 16 simultaneous players. Latency, throughput and uptime requirements fundamentally different.
Choice between managed game backend (PlayFab, Nakama Cloud, GameSparks) and own dedicated server depends on genre, budget and scalability needs. Mistake in this choice discovered at first load test.
Dedicated Game Server Architecture
For real-time multiplayer with authoritative server need dedicated game server—process running Unity or Unreal in headless mode handling game logic authoritatively.
Unity Dedicated Server build (Unity 2021+)—separate build target without graphics. Server-side code marked #if UNITY_SERVER. Physics, collisions, AI, damage calculation—all on server. Client only sends input and receives state updates.
Hosting for dedicated server: Unity Gaming Services Multiplay (managed, auto-scaling, pay-per-hour), AWS GameLift (more mature, server fleets with auto-scaling), own VPS via Docker + orchestrator (cheaper, requires DevOps).
GameLift FlexMatch—managed matchmaking: gathers players by criteria (skill, latency, region), launches server for session, gives clients connection info. Unity integration via AWS SDK.
Nakama as Game Backend
Nakama—open source game server (Heroic Labs), closing most multiplayer needs without custom backend code. Out-of-the-box: real-time multiplayer (WebSocket-based), matchmaking, chat, leaderboards, tournaments, player profiles, virtual economy, notifications.
Deploys via Docker Compose in hours. Unity SDK—official, well-documented. For casual multiplayer (card games, turn-based, party games) Nakama covers 80% of needs without custom server.
Custom logic—via Server-side modules in TypeScript or Go (Lua deprecated). Example: game action validation, ELO rating calculation, custom matchmaking rules. TypeScript modules compile and deploy in Nakama without restart.
Real case: mobile card game, PvP 1v1. Requirements: matchmaking, ELO-rating, replay storage, anti-cheat on action validation level. Chose Nakama self-hosted (€40/month VPS for 500 MAU) + custom TypeScript module for move validation and ELO calculation. Server development time—3 weeks instead of estimated 8 weeks with custom backend.
PlayFab for Casual and Mobile Games
PlayFab (Microsoft)—managed game backend with rich functionality: Player Profiles, Cloud Scripts (Azure Functions), Economy V2 (virtual currency, item catalog, inventory), Leaderboards, Segments (for push and A/B testing), Matchmaking.
Pricing: first 1000 MAU free, then by MAU. For hyper-casual 100k MAU—cost can be significant. For midcore with monetization—usually justified.
Important feature: Cloud Scripts / Azure Functions execute server-side, allowing safe currency operations, IAP receipt checking, promo codes. Never trust client with economy operations—only via Cloud Script.
Backend Structure for Typical Mobile Multiplayer
Client (Unity)
↕ WebSocket (real-time game data)
Game Server (Unity Headless / Custom)
↕ REST/gRPC
Game Backend (Nakama / PlayFab)
↓
Database (PostgreSQL / CockroachDB)
Game Server—authoritative game logic, runs while match lasts, then dies. Game Backend—permanent: profiles, economy, leaderboards, auth. Separation important: game server shouldn't know monetization details, backend shouldn't contain game physics.
Setup Process
Start with backend-stack choice based on genre and budget. For turn-based or casual—PlayFab or Nakama managed. For real-time action—dedicated server + Nakama/PlayFab for meta-layer.
Deploy staging environment identical to production (Docker Compose / Kubernetes). Production environment differs only by scale—not config. This eliminates "works on staging, doesn't on prod".
Load testing via k6 or Locust before launch: simulate peak load, check server holds target concurrent users without latency degradation.
| Task Scale | Estimated Timeline |
|---|---|
| Nakama self-hosted setup + basic Unity integration | 1–2 weeks |
| PlayFab integration (auth + economy + leaderboards) | 2–3 weeks |
| Dedicated game server (Unity headless) + hosting | 3–6 weeks |
| Complete multiplayer backend (server + meta-layer) | 6–12 weeks |
Cost determined after analyzing genre requirements, player count and infrastructure budget.





