Live data from Hacker News

Elixir and Phoenix after two years

nts.strzibny.name

31–40 of 111 posts

Re: Elixir and Phoenix after two years

#31
post #2

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?

> I have used Erlang very successfully in a semi-embedded context 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 no…

> Elixir is really quite good in the semi-embedded space

Yeah, I don't need any convincing there. Erlang was a perfect fit for the device I worked on. High level enough to get things done quickly, but with a really solid, predictable runtime.

Re: Elixir and Phoenix after two years

#32
post #2

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?

>> but that's quite different from a web server that can usually be scaled horizontally pretty easily 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 worr…

Not that concerned about scaling - I think it's going to beat Rails there, but for a larger web app growing quickly, the difference between going to N web servers from 1 might not be that many months.

Re: Elixir and Phoenix after two years

#33
post #16
post #12

Earlier 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…

Ahh, ok. You've sort of hit a weird spot for Elixir. Python will just start up faster and that will be noticeable. Math is much better optimized in Python, though this is changing with NX.

The real gain here would probably be streaming chunks of rows out of ecto and maybe firing those off to tasks per CPU core. Which is easier than it sounds.

That said, you had working code so no real reason to rewrite it except as a learning exercise.

Re: Elixir and Phoenix after two years

#34

Oh no same crap of mixing hash symbol and string keys as in ruby? You didnt have to borrow that Elixir! Does Elixir also have HashWithIndifferentAccess?

You really should never mix them, String keys are basically only there for accepting untrusted input, and should get sanitized. Any internal map should only have atom keys. String keyed maps exist so that you can accept inputs from untrusted sources without worrying about a malicious or malformed input from overflowing the atom table and crashing your VM.

Re: Elixir and Phoenix after two years

#35

Oh no same crap of mixing hash symbol and string keys as in ruby? You didnt have to borrow that Elixir! Does Elixir also have HashWithIndifferentAccess?

Elixir does not have HashWithIndifferentAccess

Not built in, and not remotely suggesting anyone use this, but as an experiment I did build this a few years ago as a toy/to play with a few ways it might look if we ever wanted something similar.... https://hex.pm/packages/indifferent_access https://github.com/bglusman/indifferent_access (see also https://github.com/vic/indifferent )

Re: Elixir and Phoenix after two years

#36
post #4
post #2

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?

It's pretty great anywhere that you might use Rails or Django, but if you expect spike in traffic that are hard to predict you get nice stable worst case latency. I think it's also really good if you need to hold state server side for any reason.

Rails has a ton of high quality code available for it. It looks to me like Phoenix is certainly 'good enough' for a lot of tasks, but it just hasn't been around as long.

I'm looking for those use cases where someone picked Phoenix and it was just clearly a better tool than, say, Rails because of X, Y, and Z, despite maybe being inferior for one or two other things.

Re: Elixir and Phoenix after two years

#37
post #3

To 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…

> Sometimes simply reading a switch statement or if/else/then is much clearer

Case statements are pretty common, and for code I read the with statement[1] is even more common. This allows you to code a happy path broken into small steps and then collect your edge cases. It doesn't solve every case for if/else or cases, but it's a nice tool.

[1]https://hexdocs.pm/elixir/Kernel.SpecialForms.html#with/1

Re: Elixir and Phoenix after two years

#38
post #32

Earlier quoted context omitted.

>> but that's quite different from a web server that can usually be scaled horizontally pretty easily 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 worr…

Not that concerned about scaling - I think it's going to beat Rails there, but for a larger web app growing quickly, the difference between going to N web servers from 1 might not be that many months.

Oh, sure, Erlang isn't going to save you from going multi-node...in fact, it shouldn't; just basic resiliency should mean you're starting multi-node.

But the actual number of concurrents per instance, and the effect on latency, is quite another thing.

And it also provides you a better story around shared state within the instance, and better controls around its access.

Re: Elixir and Phoenix after two years

#39
post #18
post #15

Earlier quoted context omitted.

>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…

In my case it was a team of 1 working on OTP 19 and 20. Since that is now 3+ years ago, it is quite possible things have improved in the single-thread performance area.

Elixir single thread performance /is/ much faster than Ruby and Python [1].

Are you sure you weren't just doing something sub-optimal with Ecto?

[1] https://amp.reddit.com/r/elixir/comments/46v1l1/is_elixir_fa...

Re: Elixir and Phoenix after two years

#40
last hype train i joined, was scala... this language reminds me of scala... a HORRIBLE developer experience, yet we zerglings are happy to be lemmings to someone's "best idea evah"

This brings up the pain of scala... only this time im not going to join the fan club.

Post reply on HN