How is the performance of elixir in game backend project?

I have an idea for a mobile game app, I want to use elixir for backend, how is the elixir performance for game backend, any idea?

1 Like

Elixir is a great fit for a game server, if you did come to find some bottlenecks there is always space to optimize performance by using a NIF (Rust with Rustler, etc), but that would only be the case if CPU bound tasks would come into play.

But to answer correctly it really depends on what you are doing on that game server, If it would be taxing on the CPU maybe a better solution could be found on a lower level language.

You can find a good discussion about the same topic here: Is Elixir suited for a performance game server?

5 Likes

Elixir is great for backend of games
When that game is multiplayer .
Or need Process players data and communicate between them .

Like Chess,

But you enjoy from Elixir performance when you write a game like GTA Online.

My mean is you have 1K / 100K / 1M players
they can be play over your servers and very simple share information without think about which player exist on which server .

If you need write many rule based logic or handling level of each player or some low cost processing Just use Elixir and forget NIF ( using aother language with Elixir )

If you need some heavy algorithm processed inside your server instead of mobile/Xbox/Ps4
then your work is harder.

I wrote a Rule based game engine that need to much share info between players. In Erlang ( that is brother of Elixir :grin: ) works great.

My suggest :

  1. Use ETS to much ( storage in-memory )

  2. Use Mnesia to much ( storage in-memory + persistent + Distributed )

  3. For implementing Room/Channel if you
    need, use pg module or phoenix pubsub

Good luck my friend

3 Likes

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 ?

22 Likes

tnx so much :slight_smile:

tnx I get it :slight_smile:

1 Like

I have a planing to develop mobile game app like soccer online, but simple app, I get it, but I do not know which game engine I can use for it?

Unity is best and simple for mobile app.

and also Call of duty use Erlang/Elixir for whole backend

1 Like

If you need drawing great player face ( 3D ) maybe need to ZBrush and may need other tool/software if you want great textures for teams shirt

I guess ZBrush not a game engine right?

Yes . ZBrush is a tool/software for Drawing great 3D object

And often all charactor designer use it
For drawing Face

Actually game design have itself world .
You just start a book or online tutorial for Unity.

If you want , find correct way

I liked this classification:

Elixir would do fine for “1 hour” and “1 second” scenarios, even with tons of users. For the “200ms” one, it depends!

3 Likes

If I were to build a soccer game - which involves syncing the positions of the ball and players - i would do with either

  • Unity with Mirror or Photon
  • Unreal

https://www.udemy.com/course/unity-multiplayer/ is a good course to start out.

For any assets, i would buy from Unity asset store or use a primitive objects like sphere, cylinder, etc and complete game play first.

I would not touch any asset tools before completing game play unless I have a team which creates assets.

4 Likes

understand, very well, appreciated

1 Like

There are communities on discord which can help you on multiplayer game development -
Official Unity Discord

1 Like

great, I love it, tnx so so much :slight_smile:

1 Like

hi again, id I want to develop like that game which engine will be better for me?

Unity or Unreal are the more popular ones with huge community and plugin ecosystem.

Try out and find out, I have developed in many frameworks like Cocos, Unity, html5 and Godot.

I finally settled down with Unity3d as default engine for developing games. You can try out and find out which one appeals you the most.

Rise up game can be built using Unity3d. It has 2d elements with collision (from the play store listing).

Found a small tutorial on Youtube - How to make Perfect RiseUP Game in Unity3d full tutorial - YouTube on a portion of gameplay similar to Rise UP.

You can learn basics of unity game dev from video course from youtube, unity or udemy.