News for hackers. Stuff that matters.
Re:Onboarding to Elixir by whalesalad on Tuesday June 22, 2021 @10:17AM (#27591900)
You’re missing a lot! In the case of a simple request/response web app yes it doesn’t do a whole lot. Imagine you’re building a complex system with lots of different behavior patterns. Let’s say a backend that fans out to 100 different 3rd party APIs, like a shipping aggregator that needs to talk UPS, FedEx, USPS, Canada Post, Royal Mail, etc… and you want to be able to carefully control rate limits, batch sizes, etc.. to those endpoints. An actor system with supervision trees is a very good way to build a system like this.

Also... the rhetoric here on HN about Erlang/Elixir vs. Kube really needs to stop. People are misinformed. They are not mutually exclusive, you do not need to choose one or the other. We need to reconcile that because the discourse always goes to this weird war in the comments.

Re:Onboarding to Elixir by LeonenTheDK on Tuesday June 22, 2021 @02:05PM (#27594991)
Jose Valim has a post[0] on the Platformatic blog about how Elixir and Kubernetes can happily co-exist together, and that each solves problems at different levels.

[0] https://blog.plataformatec.com.br/2019/10/kubernetes-and-the...

Re:Onboarding to Elixir by driton on Tuesday June 22, 2021 @10:30AM (#27592096)
That sounds very interesting and specific.

If it's not a random example and if you're at liberty to say, would you mind elaborating further how Elixir specifically excels in that particular use case, and what would an alternative approach, regardless how cumbersome, be?

Re:Onboarding to Elixir by dugmartin on Tuesday June 22, 2021 @11:28AM (#27592896)
This really isn't an elaboration on the grandparent comment but if you are interested in general in learning how Elixir excels at data pipelines I'd suggest looking at this library:

https://hexdocs.pm/broadway/Broadway.html

Re:Onboarding to Elixir by whalesalad on Tuesday June 22, 2021 @10:33AM (#27592137)
I have been meaning to write a blog post - I am going to escalate the priority on that.
Re:Onboarding to Elixir by bsaul on Tuesday June 22, 2021 @11:51AM (#27593226)
your example is interesting. I assume the reason is that it's an in-between situation between stateful and stateless: aka shipping using 3rd party api is a transient state of a complex process that can be ultimately recreated from the orders stored in the DB, but better not for speed reason.

I wonder if there are other patterns like that.

Re:Onboarding to Elixir by di4na on Tuesday June 22, 2021 @01:54PM (#27594848)
Any kind of long held connection is state ;) So websocket, long http one, database connection, etc.

Being able to tightly define what part of your app is impacted if one of these fail and restore it before the rest of the app is impacted is a game changer.

OTP also deeply force you to think of how you start and how you stop these, taking dependencies into account. It helps in cleaning up stuff.

Re:Onboarding to Elixir by bsaul on Tuesday June 22, 2021 @02:05PM (#27594989)
sure. By state i really meant working end-user business-level data. Those are the kinds that really set the type of guarantees you need for your system.

I guess i'll have to try OTP one time to understand why so many people rave about it. I only know one guy who had made real work with erlang / otp and he told me it was beautiful, but not quite as relevant anymore, because of k8s. But i guess i need to make my own opinion.

Re:Onboarding to Elixir by ch4s3 on Tuesday June 22, 2021 @03:26PM (#27596018)
If the value you're looking for is just 0 downtime, then k8s solves that for you. As others have pointed out, the BEAM/Elixir/Erlang give you great process isolation and resilience to small failures, timeouts, weird transient issues, big short lived spikes traffic, and stuff like that.

With respect to user data, a supervised process can crash and the supervisor can restart with the last known good state of that data. It requires some thought on the part of the developer to achieve this, but it's really powerful.

Re:Onboarding to Elixir by nivertech on Wednesday June 23, 2021 @07:17AM (#27603139)
You don't need k8s for 0 downtime, putting a monolith into an autoscaling group behind loadbalancer solves that ;)
Re:Onboarding to Elixir by bostonvaulter2 on Tuesday June 22, 2021 @03:06PM (#27595781)
> aka shipping using 3rd party api is a transient state of a complex process that can be ultimately recreated from the orders stored in the DB, but better not for speed reason.

Plus some 3rd party APIs are rather terrible and if you end up re-sending a request (because your server/container went down after the request got sent to the API, but before the response got back/was processed) then the 3rd party API could end up in an inconsistent state.