Game Backend Servers are different from Game Servers when it comes to gaming domain:
- Game Backend Servers: infra services like auth, storage, economy, etc
- Game Servers: multiplayer servers handle player presence and sync data between clients like mobile apps, web pages, etc.
Game Backend Servers you can build in Elixir/Erlang. When it comes to Game Servers the answer is a little bit complicated.
There are different genres of games like FPS, RPG, MMORPG, Casual, Turn based, etc and each one has a different latency requirement. First person shooter (FPS) games need a very low network latency (in milliseconds). Turn based games on the other hand can have higher network latency like a second or two.
Most of the game engines like Unity have multiplayer frameworks like Mirror, DarkRift, Unet, etc. There are different client server architectures in game networking like authoritative, relay, etc.
Process of building a multiplayer game server using networking libraries like mirror on Unity, etc is completely different from regular servers. Take an example of building an authoritative multiplayer game in Unity using Mirror:
- Few Mirror framework callbacks relating to game functionality need to be implemented for Server and Client in C# classes. Callbacks for client and server are colocated in C# classes - like client code and server code are in same file but with annotations that it is server code and this is client code.
- Select a transport which is most suitable for the game - tcp or udp based.
- Two builds can be generated from Unity Editor a game client build (which can be android app or iOS app) and a headless server build.
- A headless server build is generated using Unity Editor. This headless server build contains everything except graphics. This is no different from a unity game client (iOS/Android) - Unity runtime manages everything.
- For every game session, a new instance of headless game server is spawned. This instance is killed when the game is over.
For games with low latency requirements like FPS, MMORPG - Elixir/Erlang runtime is more suitable to build relay servers(not authoritative servers) which fan out the incoming messages. One of the client acts as Server and it will makes all decisions relating to the game. Other clients contain approximations relating to game data until state is synced by Client Server(client which is acting as server). Relay is used as medium to sync data between Client Server and clients. Physics simulations, transforms, lag compensations are very difficult to implement in Elixir/Erlang for lack of libraries and a way to import game environment( OBJ files like models, meshes, etc) into the Elixir/Erlang world. There is no point in reinventing the wheel - there are many mature networking libraries which handle these scenarios. Even if some one wants to use Elixir/Erlang for relay servers - they have to implement a custom relay transport in the networking libraries like Mirror.
In case of turn based casual games like card games, board games, bingo, battleship, chess, etc - Elixir/Erlang runtimes can be used to build Game Servers. Phoenix Channels + GenServer + Postgres using Ecto will be enough to implement a turn based game server.
What are you looking to build Game Server or Game Backend Server? What genre is your game? What are the latency requirements ?