Can Java frameworks like SpringBoot and Play handle multiple requests at the same time by leveraging all the cores on the machine ? If they can do that, then what unique problem is Elixir solving with respect to concurrency? Is it just a different language? Or there is any difference in the computing paradigm itself that brings us lower server costs with Elixir?
First of all you should not compare OOP language to functional language. Secondly Elixir does not only solves concurrency problems. In really really short think about Elixir like a cute version of
BEAM have lots of awesome functionality. I love
Elixir mainly for concurrency and that you are working exactly on what you need and not on everything around. You basically do not need any framework to do everything. I recommend also read about hot code upgrade.
If Elixir was only about concurrency I’d never be a part of this forum, because I learnt Go before Elixir. Elixir has the OTP which is more important. OTP is the collection of libraries which makes creating stateful, distributed applications a breeze. Also Elixir (as any language running on BEAM) has fault-tollerance, because of which your whole application won’t shut-down completely if only a piece of it behaved wrong.
Also Elixir’s concurrency is a lot different than Java’s concurrency. Elixir has light-weight processes (somewhat similar to Go’s goroutines), while Java’s concurrency is based on OS threads.
Elixir’s processes are supervised by supervisors, so if a processes goes down, Elixir will let it crash and replace it with another bran-new process, and that’s why Elixir is fault-tollerant.
edit: Please also watch this video.
Here’s one way to think about it. If your java thread answers an HTTP request, and as part of doing so suddenly has to do a very complex calculation, have many clients does that calculation block? Just the one doing the request or many more? With Java the answer is many more. A single java thread can handle many different HTTP requests but not really “at the same time”. It just does some work on one of them, and then if it’s written to do async IO, then it can move on to another. If it isn’t using Async IO, or if it does a complex calculation, it will block.
This is one of the ways that Elixir is different. Each Elixir HTTP request is handled in a concurrent process. Even if one of them hits an infinite loop, other HTTP requests can be handled at the same time.
Also take a look at this thread: