Is Elixir suited for a performance game server?

Hey, thanks for your answer.

I’m still wondering, the JVM is good in calculation so for Beam wouldn’t be?

If you mean pure numerical computation then both JVM and BEAM are equally as bad. For this most people still reach for C/C++ or Fortran.

They follow completely different philosophy and architecture, but in short I would say the JVM will give you faster computation whereas the Beam will give you shorter latency. And for a server, the latency is key. I’m not a specialist but IMHO Elixir should do the job really well, and if you have some algorithm which take too much time you code them in C++ or Rust and put them in a NIF. It’s probable that it won’t be as fast as a full C++ server, but it also won’t be such a pain to dev and fine tune…

MachineZone made several billion dollars running their backend system on Erlang. I would imagine it’s quite possible.

I think they moved a significant amount to C eventually.

But they have been big backers of the Erlang community for a while.

I made a Minecraft server (way way back in the Minecraft Alpha days) a long time ago. Terrain generation was the slowest part (so much math on so much stuff!) but entities being each their own little actor process was so fun to work with. It is mostly just a see if I can do it thing so I never ended up releasing it, but for something not twitch or math intensive it was perfectly fine (and those can be slaved out to NIF’s pretty easily, I think ‘NIF’ either didn’t exist or was brand new at the time though so I didn’t use it back then).

2 Likes

Hello, thank you for your answers! If I summarize this means that Elixir is a very good choice for game servers except for tasks that require a lot of computation (like field generation in Minecraft) and for this kind of case we do a module in C/C+++/Rust and we use NFI?

1 Like

Yes, but it’s Native Implemented Functions (NIFs)

1 Like

Hi, NIFs are a good way of empowering the BEAM (Erlang’s VM), I didn’t try NIFs for serious projects, but a game server should be a good use-case.

What kind of game server do you have in mind? did you started something or are you just evaluating technologies? I think we could guide you better if you provide more information. Like @OvermindDL1 said, a “simple” Minecraft server is very complicated to implement, so you may want to start with something easier to achieve alone, e.g. A multiplayer tic-tac-toe with Phoenix, so you don’t need to manage 3D graphics, collisions, etc… otherwise you may get overwhelmed by the complexity of the project.

If you’re decided to give Elixir a go, you have multiples resources (books and videos) that implement mini-games via web with Phoenix, so this will introduce you to advanced topics like Supervisors, GenServers and more.

On the other hand if you’re interested in multiplayer game servers and how they work behind the scenes, you’ll have to read a lot of books (mostly C++ books), here’s a good starting point: https://github.com/miloyip/game-programmer

Specifically you’ll need some books of the following sections: Mathematics for Game Programming (only if you struggle with maths), Game Physics and Animation (only the books related with Physics) and Multiplayer Game programming (most of them). Obviously there’s more (being a game developer even if it’s just a server is too hard!), but this will be more than enough to get you started.

1 Like

Hello,

The implementation of the world of warcraft server should be able to be done in Elixir via the Erlang Virtual Machine (BEAM) however heavy tasks such as field generation should be done in C/C++ via NFI

By private server, I mean a new implementation of the game mechanics and main quests at first

1 Like

Don’t you have some gameboard server-side in many types of multiplayer games?

Imagine a multiplayer 2d RTS with fog of war. If you send the whole map to the client, and then only player movements and such, a player could hack the client and make the map all visible.

So let’s say the gameboard is stored in Elixir. Which data structure would you use? None is adequate. List: accessing an element requires traversal. Tuple: updating an element will lead to creation of a new tuple every time, due to immutability. Would have been nice to have a MutableTuple element for these very specific use cases.

It gets even worse when you think of open world games with dynamic map generation. I don’t see how you can manage the access and update of very large data structure without mutability.

I’m not experienced in this topic but I was thinking about creating a multiplayer game as a side project which led me to these concerns. So let me know if I’m wrong on some points.

I wrote a simple FPS online game over a decade ago, using Java & OpenGL.
For the gameserver Elixir had been a perfect fit, as most of its job was handling connections, player coordinates, fighting actions and chat.
However, on level change, it did also some terrain generation, and there comes the weak spot of Elixir/Erlang/Beam: Computation on big data structures. This would not have been a problem in my case as the levels weren’t too big and the computation was only on levelchange, waiting a second longer wouldn’t harm anyone there. But things like that would be a nice job for a Rust NIF :wink:

2 Likes

I know this is an ancient thread, but I wonder if you could do the big data structure stuff in Euphoria. The selling point was the ability to very quickly process large series of data in simple calculations, almost instantly. And you can compile the finished product into C.