Is Elixir suited for a performance game server?

Hello to you

I create a private server for World of warcraft, is Elixir a powerful enough language for this kind of project?

2 Likes

I’m not familiar with World of Warcraft servers, can you explain a bit more what kind of server this is? What does it do mostly? What kind of traffic are you expecting? I/O bound or CPU bound? Etc.

3 Likes

Elixir and the BEAM have been used for game servers before so I’m sure it would do well. Your main challenge will be implementing all the logic which I’m sure is non trivial. If your goal is to have a customizable WOW server you may get what you want more quickly by forking some existing open source implementation.

1 Like

The most popular multiplayer games like World of Warcraft, Call of Duty or Minecraft, as well as thousands more online games, work basically the same way. Players install a “client” for the game on their computer and then connect to the game servers via an internet connection. There are several different servers that are required to play these games.

Before you can actually start playing, you need to get into the game. So you need login servers. Whenever you are trying to connect, the login server is confirming the data of your account in the database to know who you are. After you select a character from your character list, the login server acts as a road sign, guiding you to the correct game server.

These servers are generally distributed around the world as it guarantees access to the game even if one of the login servers is not available. If a server fails, players can still enter the game through the other servers.

After having checked the data of a player, the client is connected to the game server. That’s where the game happens. Games with very large maps host a game world on multiple servers.

Game servers also regularly send customer data checking if the player is still online. If they do not get a reaction, the character will be “kicked” from the game.

The tasks are quite varied, for example for map generation I think it is quite demanding in CPU / Calculation and for the rest moving players, quest etc. I don’t know too much

1 Like

Only Elixir? I don’t think so, Elixir is weak on calculations, so for example heavy calculation systems like geometry engine, pathfinders will not perform really well on Elixir, so that stuff can be done as a NIF (could be rust or c++ I’d recommend Rust tho)

Everything else Elixir is capable of it, all the spell cooldown management, inventory systems, battle sytems, markets etc… could be done with Elixir without any problem

Tho keep in mind that Elixir is a functional language so some solutions like Entity systems and such can take a bit more of effort compared to OO languages

1 Like

Hi, I’m confused. If you already have a private server, where do you want to use Elixir? or is it something that you want to build from scratch?

Let me start by saying that it’s not an easy task, popular implementations of World of Warcraft servers are written in C++ and took years to get where they are now, with hundreds of contributors helping with the code. You need to communicate your app with the WoW client, recreate maps, battlegrounds… implement the structure of the database with the skills, quests, achievements… I’m being scared by only thinking it.

Anyways, Is Elixir suitable for gaming servers? Yes. Is Elixir suitable for high performance gaming servers? Probably not, or at least not alone.

1 Like

Hello,

What do you mean by high performance? I see… I might get my hands on a Minecraft server to see

But then, if I use another language for the map generation, Elixir can do the rest?

Do you consider Counter strike global offensive or Leauge of legend servers as high performance servers?

Most of those games are made with engines, for example, unity3d, unreal engine, godot… (c++, c#).

There is now a c# library for connecting to phoenix websocket, called Fenix.

You don’t need to write a new engine in Elixir, but You can use existing engine, and use Elixir as communication (match maker, presence, chat, lobby etc.)

I read some blogs about Elixir and Unity3D, and tried also, but it’s heavily under rewrite (Network, Entity system). It’s funny how they are trying to use multicore processing with there new ECS. It looks they have discovered benefit of immutability, and functional programming :slight_smile:

1 Like

I understand, but my goal is to reimplement the critical elements and not just the match making.

game servers don’t perform a lot of computation usually. Most of the time it’s about receiving new coordinates and sending that data to the other players in the same zone, send data about the movement of fauna and NPC (and this could be computed on the client as well if we just send the paths they are supposed to take), and less often sending info about other actions like fighting and etc. Aside from message passing, it stores every meaningful actions in logs/DB/whatever and that’s it, so the computation can really be minimal (depending on the game most things could be done on the clients, with the server only arbitering the results).

The server has to check the players are not cheating of course, but that can be done in another program which analyses the logs output by the elixir server. Or at least that’s how I would do it, except for really important stuff related to money which would be computed on the main server.

2 Likes

I think they are, not because the type of game, but the number of players connected simultaneously, since those kind of games have a multiple servers available and limited to X number of players. Riot blogs about its infrastructure and other things, so their engineering blog should be a very valuable resource for you: https://technology.riotgames.com/. Let me highlight a piece of this article:

We write Riot chat servers primarily in Erlang (check out this video if you’re curious about the language), although we use C for bindings to certain lower-level operations such as XML parsing, SSL handling, and string manipulation. 10% of our chat server codebase is written in C while 90% is pure Erlang (ignoring external libraries and the Erlang VM itself).

Replace Erlang by Elixir and you have a nice use-case for using it in a professional game, they also use Electron as its GUI client. The key takeaway here is “use the right tool for the job”, a complete game like WoW, LoL, CS… requires a stack of many technologies playing together, for example:

Game: C / C++ / Rust / C# / Java
Game server: C / C++ / Rust
AI: Lua / Python / JavaScript
Chat system: Elixir / Erlang
GUI client: Electron / C# / Java

Of course some parts are redundant, for simple games you implement multiple things with the same language, this is just to illustrate a very complex and professional stack, and it’s not viable to do something like this alone. However when it comes to experimenting, prototypes and so on, you can ignore the initial step of valuating technologies in search of the best performance, sometimes the initial result is better than you would expect.

This is not about gaming but online servers, an interesting article of how Figma started with a pure TypeScript stack before migrating to Rust: https://www.figma.com/blog/rust-in-production-at-figma/.

The multiplayer server we launched with two years ago is written in TypeScript and has served us surprisingly well, but Figma is rapidly growing more popular and that server isn’t going to be able to keep up. We decided to fix this by rewriting it in Rust.

As you can see, the initial implementation were not that bad, and it was pure JavaScript at the end of the day, something like Elixir should have played better than this.

2 Likes

Hey thank you for your answers! This means that 90% of League of legend servers are written in Erlang O_o

That’s fantastic!

Compared to Figma and Typescript, I think Elixir could have been enough, right?

Oh, I just read… it’s just the chat server, not the game server. ;(

Yes, even if it’s not a game, the server manages multiple users online, so the use-case is pretty much the same. Figma was founded in 2012, so at that time Elixir was very new, but I think Erlang would have been a better option than JavaScript.

We’re talking about the infrastructure, Erlang (and thus Elixir too) isn’t suitable for game programming. Anyways the chat system is a very complex part too, don’t understimate it! and chosing a concurrent language for real-time communication is a very smart decision.

You might checkout the Battlestar Galactica Online game which is written in Erlang. At this level of discussion Erlang and Elixir are equivalent. It definitely shows that implementing a game in Erlang is definitely feasible to do.

9 Likes

Thank You for the resource, I like using Erlang/Elixir for game server :slight_smile:

As mentionned in the link, the client is made with Unity3D. I suspect the Erlang server is used for communication only and does not manage the gaming rules. (Physics, collision detection, characters animation)

Hello,

I fully understand that Elixir is a good choice for making chat servers, websites, match making

In the end, if I follow what I’m told here:

This means that I could also do a server implementation of a known game?

I would like to take the example of Minecraft, spigot is the most well-known implementation and is made in Java! If I start from this principle it means that I could very well do it in Elixir, right?

When you say that BEAM is bad for the calculation, is it bad in relation to C++ or rather in relation to the FMV?

Because in the case of the JVM this does not prevent Minecraft and many other games existed

What I don’t know is how much of Unity3D it used. The rendering and graphics obviously but how much of the “intelligence” in the game was I done in Erlang I don’t know.

1 Like

Hello, I see you’re the one who created Erlang! Could you tell me if you think the BEAM virtual machine is as powerful as the JVM in computation?

Do you know of game server which handle those kind of things? Animations are always client side as it wouldn’t make any sense on the server. Collision detection should be client side and the server could optionaly verify it to ensure no cheating is taking place but that can be done out of band. Physics should be handled on the client as well for the same reason!

Honestly I think Elixir would be a good fit for a game server as long as (de)constructing the network packets from and into data is fast.

@Pondo : I think Elixir could be used to do a server implementation for most known games indeed, especially MMOs as most of the work is message passing. The more (heavy) logic resides on the server, the less it might be convenient to use Elixir maybe, although one could use NIFs, but the more “MMO” a game is, the simpler the logic will be on the server! For a good reason: when you want to create an MMO you want to be able to handle the maximum number of players on a server so that people can enjoy their time together, and that means not computing the world on that server for every frame. A lot of MMOs don’t even use z coordinates to save a third of packet space for coordinates (which means maps cannot have several accessible layers on the z axis), so of course the server won’t compute any kind of complex physics! It’s the role of the clients to move the players and make them act depending on the data broadcast by the server.

About computation it would be in regards to C++ yes, like if you have a game server which should be able to handle the physics you wouldn’t code that part in Elixir. But I’ve never heard of game servers handling the physics, and even if you need to you could do that in C++ in a NIF I guess.

Anyway, I don’t know if minecraft is logic heavy on the server or not, but most probably it isn’t and you could code that in Elixir. You should have a look at the Java implementation to have an idea.