Just a general question, if Twitter had used Elixir/Erlang as a backend instead of Scala, would they have had even more performance? I mean if we use the same hardware for benchmarking api call requests per second how will Elixir vs Scala compare?
Is Elixir a good choice to use for Twitter like websites? Are there any drawbacks?
Yes. No. Maybe. It depends. However I doubt it, as there was sh…load of money pushed into optimisations of JVM. BEAM never had such funding.
However I do not think that the VM performance is the problem for the Twitter. It is storage of data. Of course slow VM (like Ruby earlier) do not help, but BEAM vs JVM should not introduce big change there.
As good as any other language.
The main problem with Twitter is scale, not complexity of the platform as is. At scale language do not matter much (even while Erlang is famously good there, it do not solve all problems, and it still will be hard).
I think it is a mistake to discuss performance as if it was a single measure, directly influenced by the choice of language. First of all, performance is not one single thing: page load speed, data throughput, requests per second that our system can serve, max concurrent connections, system resources necessary to run an instance of our app… these are all possible facets of performance for a web app, and each of them is a complex topic in itself.
On top of that, in a real system, each of those metrics of performance is affected by a multitude of factors. The choice of language is merely one. Real applications are designed with a multitude of constraints and goals, and the choice of technology is almost never a matter of comparing languages on a single measure of speed.
Even the “speed” of a language is not one single thing: there are completely different workloads, and most languages optimize for a few of them. It is already misleading and difficult to compare the performance of languages on the basis of specific benchmarks, doing so on hypothetical implementations of a complex application is basically impossible.
Could Twitter be written in Elixir? Yes. Would it be a good choice? I would say yes, but the same could be said of other languages. Would it be faster than the current implementation? I don’t think we can give a meaningful answer to this question.
Seeing as the OPS teams of big companies hyper-optimise their available servers for the parameters where their dev choices are strong (or weak) at then I’d say switching a technology stack on an already well-working product would be a disaster of epic proportions.
Example: I’ve had customers who had very clever sysadmins who quickly figured out that the biggest app of the company – written in Ruby on Rails – required very fast CPUs but mediocre I/O speed and medium RAM sizes were fine. So they carefully picked cloud compute with those parameters and their Rails app was doing really well there.
It’s not that I like Rails (I dislike it a lot and I worked with it 6 years to have an informed opinion). But the people in that company went all-in and accepted the tradeoffs and optimised their process around them. And the results were very good.
So I think when discussing if Elixir would be a better fit for Twitter-like apps, we should more ask the questions like “But what would the load on a Twitter-like app server look like?” If there’s much more I/O load than a CPU and RAM load then a transparently-parallel language/runtime like Erlang/Elixir would do excellently.
But if you have to do millions of messages per minute which include a lot of message passing – and thus memory copying – then it’s likely that a BEAM language could perform badly and that you should look at something with [zero|small]-cost abstractions like Rust. Or just swallow the cloud bill and use whatever language you have the most programmers in your company familiar with.
It all boils down to what tradeoffs are you willing to make and live with.
Wow I just watched that talk. Elixir’s response time for their KNN testing was about 50s compared to Scala’s ~6s. With tuning and delegation to C for the number crunching with NIFs they got it down to ~30ms. Very cool, and quite impressive! Really shows why interop with C is an important part of a language. There’s a reason most of Python’s ML libs are written in C.
For comparison with JNI they got the Scala response time to ~3ms.
Another interesting takeaway was that they got the Scala response time down to ~10ms by throwing extra cores at it (8 cores to 36), but Elixir only went down to ~20s by throwing the same bump in cores at it.