What are people finding as the real sweet spots for Phoenix? I have used Erlang very successfully in a semi-embedded context, but that's quite different from a web server that can usually be scaled horizontally pretty easily. One obvious one is if you have to hold open a lot of concurrent connections like web sockets. It'd be great for that. Others?
In terms of language, Phoenix is a complete replacement for Rails for me. I feel more comfortable growing a functional codebase, and the BEAM means I don't have to worry about scaling as soon as I would with Rails. I think it's a good fit for when you want to do more with a small, experienced team. I would reach for Rails when I'm concerned about finding developers (Elixir devs are fewer and more expensive, generally…
Elixir and Phoenix after two years
11–20 of 111 posts
Re: Elixir and Phoenix after two years
#12To add to the author's experience, I spent 18 months of production time with Elixir and Phoenix. As he says, the templates are compiled and are blindingly fast compared to Rails. Pattern matching is really really nice when used in the right places (and you'll miss it if you go back to Ruby); but it can be overused. There's a faction of Elixir folks who attempt to avoid all conditionals and instead seem to prefer mult…
I'd be interested to see an example here. Using Plug+Ecto has been roughly on par with most real world examples I've seen with SQLALchemy and Flask for single request performance. Python might be a bit faster for some workloads but once you start saturating the CPU, Elixir/BEAM really shines.
Re: Elixir and Phoenix after two years
#13What are people finding as the real sweet spots for Phoenix? I have used Erlang very successfully in a semi-embedded context, but that's quite different from a web server that can usually be scaled horizontally pretty easily. One obvious one is if you have to hold open a lot of concurrent connections like web sockets. It'd be great for that. Others?
Elixir is really quite good in the semi-embedded space with several successful companies having their IOT bread and butter in Elixir Nerves platform. The deployment story is getting really mature in Elixir.
The article has some really salient points: Testing and Documentation and really amazing in Elixir. Concurrent tests are amazing. So for example normally a "database" would be a global resource and running concurrent tests against the database is really tricky. It's basically turnkey in Elixir (need to set up two settings).
With a bit of work, it's not terribly hard to write concurrent tests that exit the VM and come back into the vm and use a test-shard of a global resource. So, for example, you write a test that issues an HTTP request to itself, and the request is instrumented with parameters to connect it back to the test process and use the correct "temporary shard" of the database. (In the case of the database it's a transaction, I use the phrase "temporary shard" because the same mechanism can extended to other concepts too, like module mocks, ets tables, process registries, etc, which all use the same mechanism, you only have to set it up once).
Re: Elixir and Phoenix after two years
#14Re: Elixir and Phoenix after two years
#15To add to the author's experience, I spent 18 months of production time with Elixir and Phoenix. As he says, the templates are compiled and are blindingly fast compared to Rails. Pattern matching is really really nice when used in the right places (and you'll miss it if you go back to Ruby); but it can be overused. There's a faction of Elixir folks who attempt to avoid all conditionals and instead seem to prefer mult…
Is that still the case? I thought BeamVM recently added JIT? I don't expect it to be LuaJIT or JS V8, but Ruby and Python Single Thread performance should be reasonable expectation?
I also wish some of these experience has more context in terms of code base size and team size. A Production environment of a small project with a team of 2 is very different to production environment of a project that is large and team of dozens if not hundreds.
Re: Elixir and Phoenix after two years
#16To add to the author's experience, I spent 18 months of production time with Elixir and Phoenix. As he says, the templates are compiled and are blindingly fast compared to Rails. Pattern matching is really really nice when used in the right places (and you'll miss it if you go back to Ruby); but it can be overused. There's a faction of Elixir folks who attempt to avoid all conditionals and instead seem to prefer mult…
> In my anecdotal experience, the same external service written with Elixir+Ecto was 25-50% as performant as a Python+SQLAlchemy program I'd be interested to see an example here. Using Plug+Ecto has been roughly on par with most real world examples I've seen with SQLALchemy and Flask for single request performance. Python might be a bit faster for some workloads but once you start saturating the CPU, Elixir/BEAM real…
The case was a recurring calculation system which would take a few hundred thousand records and do about a dozen different calculations against those (some calculations requiring additional lookups).
The original script was in Python, and then after the new webapp was built in Elixir, I rewrote it also in Elixir. I discovered that even tuning the batch sizes, the Elixir/Ecto version was much slower than the Python version. Then I looking into per-thread Elixir performance and found out that that is not its strong suit :). So the answer there of course is to leverage the strength of the tools and parallelize it; but I had no need to do that since I already had a working Python version. Could Elixir have been faster if multi-threaded? Probably. Single? No, I doubt it.
Re: Elixir and Phoenix after two years
#17What are people finding as the real sweet spots for Phoenix? I have used Erlang very successfully in a semi-embedded context, but that's quite different from a web server that can usually be scaled horizontally pretty easily. One obvious one is if you have to hold open a lot of concurrent connections like web sockets. It'd be great for that. Others?
So a lot of the other responses are comparing it against Rails and the like, but it sounds like you may be asking specifically around scaling.
Erlang (and by extension, Elixir), is nice even when scaling because the actor model will scale to I/O or CPU bound workers simply, without having to tweak threadpools or worry about thread starvation or etc. Other languages that provide n:m concurrency here have the same benefit though (i.e., Golang).
Where it shines in comparison to those is in its fault tolerance and memory model. Immutable non-shared data + supervisor hierarchy gives you tools to tackle state that are less error prone than most other languages.
And the fact it has a Rails like environment in Phoenix (and Plug, and Ecto, and the whole ecosystem) means you get the same quick-to-build app functionality, without giving up the performance and state management.
It's basically having all of these that make it desirable on this front; you can write code as quickly and simply as in Rails, getting the braindead simple scaling behavior of any actor/CSP based model, with the state management of an immutable language, and the fault tolerance of Erlang.
Re: Elixir and Phoenix after two years
#18To add to the author's experience, I spent 18 months of production time with Elixir and Phoenix. As he says, the templates are compiled and are blindingly fast compared to Rails. Pattern matching is really really nice when used in the right places (and you'll miss it if you go back to Ruby); but it can be overused. There's a faction of Elixir folks who attempt to avoid all conditionals and instead seem to prefer mult…
>Lastly, single thread performance is basically a dog. Is that still the case? I thought BeamVM recently added JIT? I don't expect it to be LuaJIT or JS V8, but Ruby and Python Single Thread performance should be reasonable expectation? I also wish some of these experience has more context in terms of code base size and team size. A Production environment of a small project with a team of 2 is very different to produ…
Re: Elixir and Phoenix after two years
#19Earlier quoted context omitted.
> In my anecdotal experience, the same external service written with Elixir+Ecto was 25-50% as performant as a Python+SQLAlchemy program I'd be interested to see an example here. Using Plug+Ecto has been roughly on par with most real world examples I've seen with SQLALchemy and Flask for single request performance. Python might be a bit faster for some workloads but once you start saturating the CPU, Elixir/BEAM real…
I should have been clearer in my final note. My Elixir vs Python example was for standalone batch (script) processing. It was not in the context of a webapp. The case was a recurring calculation system which would take a few hundred thousand records and do about a dozen different calculations against those (some calculations requiring additional lookups). The original script was in Python, and then after the new weba…
Re: Elixir and Phoenix after two years
#20Earlier quoted context omitted.
In terms of language, Phoenix is a complete replacement for Rails for me. I feel more comfortable growing a functional codebase, and the BEAM means I don't have to worry about scaling as soon as I would with Rails. I think it's a good fit for when you want to do more with a small, experienced team. I would reach for Rails when I'm concerned about finding developers (Elixir devs are fewer and more expensive, generally…
I fear it would be difficult to hire Elixir people as well, but now I realize it's actually also hard to hire decent Ruby/Rails people. Honestly I think we should just accept anyone who can demonstrate thinking and programming skills of any language and then plan for 2-3 months of ramp-up time to get them into our language of choice.