However, I’ve gotten to the point now, since our game is instanced based and I want players to be on the same instance as a game that they created… Nodejs is really becoming a pain in the ass. I heard elixir handles all the “single threaded issues” that nodejs has for you and utilizes your entire server regardless of how many cores you have. Is that true? And do you think moving over elixir would be beneficial? I know I would have to do some code conversion and it will take a while… I am also curious if elixir would be fine running under debian as that is our main server OS.
Yes, because in Elixir data is immutable, and no state is shared between processes, it is possible to have true concurrency without deadlocks.
Other things Elixir will do for you:
You’ll probably not need Redis, as there are many solutions for data storage (both persistent and ephemeral) that work inside your Elixir application.
You’ll only need a single Elixir server (opposed to multiple node servers), as it will be able to evenly distribute itself over all CPU cores. But if at some point this turns out to be not enough, it is possible to start a second server whose processes communicate with the first. – this is built into the language.
Elixir and Erlang apps work in a different way. Instead of spawning multiple system level processes, your application would consist of multiple Erlang processes. Those processes are basically looped functions that wait for incoming messages or do some stuff on regular intervals.
These processes communicate by sending messages to each other, rather than calling functions. This is important bit, because it allows you to build Elixir cluster. When you start your Elixir app, it runs in a cluster already, that has 1 node in it. But you can add more nodes to the equation, and processes will be able to communicate across network, as they were on the same host.
Okay. To sum up: I think Elixir would be perfect for your problem. This is already proven by many users using it in similar context to yours.
Is there any way you could work a small spike in Elixir? Something that would allow you to try out a little bit of Elixir for yourself without committing to totally converting your codebase?
No doubt I’m a huge fan of Elixir so I’m really inclined to say “Elixir will beat Node for multithreading” but that’s not the only concern you should have. One thing:
Elixir won’t allow you to share memory between processes either. This is actually a good thing in terms of scaling and reliability because if one process crashes it won’t corrupt memory which may be used by other processes. And, to be sure I’m being clear–Elixir processes are not the same as OS processes.
Overall though my suggestion would be try a small project with Elixir and see how it works out for you. Then if Elixir seems like a fit start moving your existing stuff off of Node piecewise as you can.
Maybe can I am not 100% elixir expert, but I can some feedback.
Elixir runs on Erlang virtual machine. (good support linux/windows -very mature) It has concurrent actor based model ( The actor model in 10 minutes ). What this mean it is concurrent and fault tolerant. Maybe I will not get in the details but Elixir/Erlang is best suited for creating distributed fault tolerant systems Let It Crash! The Erlang Approach to Building Reliable Services with 99.99% availability. Due to actor model it easy scale to use all CPU resources.
I think it will be good suited for your needs but except language itself you will need to learn Erlang OPT -> how to design concurrent applications in Erlang/Elixir based on actor model.
If you still want to write code in javscript and have something more than nodejs can offer check http://vertx.io/
You’ll only need a single Elixir server (opposed to multiple node servers), as it will be able to evenly distribute itself over all CPU cores.
Wow, well that just got me onto the “Elixir Train”, if you will. I feel like I just wasted a ton of time with node now… hearing this. But I also feel excited that something like that does exist, I’m very eager to jump in the docs / books and start learning.
Thanks for your response Q, it’s really appreciated. The Phoenix framework just makes it seem like the language gets better and better! I will be looking at Websocket benchmarks later as I have a feeling it blows node out of the water.
@hubertlepicki I will be bookmarking this thread because It will take a bit of time for all this information to sink in. I feel happy that I was not the only one :).
@Onor.io Yeah, good idea. I was thinking of just setting up the Phoenix/Websocket framework first and then once I really feel comfortable I will start with converting our RPG functions. I found this, and It looks like a good tutorial to start with. (I hope :P)
Anyways, thank you for the responses. Didn’t know I was going to get that many, I’m diving into the docs and tutorials now.
Aside from all the amazing things Elixir (Erlang/OTP) provides think how much your life would have being easier with Node if you could write blocking code and have long running tasks without worrying about blocking the event loop, which you totally can in Elixir. All your experience with async code is still handy since the only way processes communicate is by asynchronous message passing.
Hi dillybob. How is the elixir gameserver going? I’m curious to know if you had any issues. Any gotchas? Correct me if I’m wrong but one thing that might be a disadvantage with elixir is that it’s not possible (AFAIK) to run the same js library such as p2 physics on the server and client. Maybe those libraries can be accessed from elixir with ports but that would add complexity. Another possibility is to use a c/c++ library with webasembly and access the library with port on the server and webassembly on the browser.
Is it still worth using elixir even with the added complexity of having to use ports or NIF etc for game servers?
Are elixir ports low latency enough for game servers?
I haven’t been able to find instructions on how to integrate node and elixir.