News for hackers. Stuff that matters.
Re:Elixir Saves Pinterest $2M a Year in Server Costs by jeswin on Tuesday August 29, 2023 @07:24AM (#37306100)
> ... with 1/50th the effort of any other language.

To junior developers reading this, such statements are never true.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by knewter on Tuesday August 29, 2023 @07:36AM (#37306215)
Though if people consistently over decades sing a language's praises on a single point consistently like they do the beam on this point, it's usually not without merit
Re:Elixir Saves Pinterest $2M a Year in Server Costs by javanonymous on Tuesday August 29, 2023 @09:24AM (#37307524)
They wrote it from scratch with the benefit of all the knowledge they had gathered after running the old system for years. A 2X improvement would not be surprising to me, even if they had rewritten it in the same language. .

According to others in this discussion they also made architecture changes (DB, Kafka etc.). Do we know if that improved the performance?

There is no objective way we can tell if Elixir had any performance impact. It could have been due to the rewrite, the architecture change or a combination of both.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by ch4s3 on Tuesday August 29, 2023 @09:44AM (#37307834)
Not to just toss around anecdotes, but I once rewrote an email service in elixir for a company from a literal sketch on a piece of printer paper describing what their old system did. The new service ran on 1 server vs half a dozen and was both faster at crunching through their mail queue and used far fewer resources. Some tasks are embarrassingly parallelization and the BEAM excels at those tasks. Sure you might want features it doesn't have for certain systems, but for some things it really is the right tool.
Re:Elixir Saves Pinterest $2M a Year in Server Costs by pessimizer on Tuesday August 29, 2023 @10:06AM (#37308164)
Whatsapp took over the world running on Erlang/BEAM, with barely any servers and a few engineers. I honestly don't know what could be a better success story than that, but Discord has also done pretty well. The BEAM + Rust combination is looking scarily effective right now.
Re:Elixir Saves Pinterest $2M a Year in Server Costs by ch4s3 on Tuesday August 29, 2023 @10:44AM (#37308712)
I'd be willing to accept the argument that Whatsapp happened to have assembled an uncommonly good team, but it is a signal.

Yeah the BEAM with some Rust NIFs is a great combo. I'd definitely consider it in the future for many types of problems and anything involving a HTTP or GraphQL interface.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by weatherlight on Tuesday August 29, 2023 @11:54AM (#37309765)
Elixir/BEAM's (Erlang Virtual machine) frugality isn't just theoretical; it's got real-world creds. Originally tailored/optimized for 1980s telecom switches (a fleet of single core low, extremely powered machines.) Fast forward, and you've got a setup that's less demanding on your A/C and optimizes multi-core usage like a champ. it utilizes the same concurrency abstractions whether its 2 cores across two machines or 64 cores on the same machine, it makes no difference to the BEAM

Take the hot code reloading and actor model-based concurrency as a prime example. It's like getting AWS-level functionality without the steep bill for a lot of companies.

Though, I gotta admit, it used to be a hard sell for CPU-heavy workloads, especially number crunching. But Elixir is stepping it up with their Nx library, so that's changing.

Examples of companies cashing in on BEAM's efficiency:

    Bleacher Report: Went from 150 servers down to 5. No joke.

    Discord: Handles millions of real-time users without breaking a sweat or the bank.

    Financial Times: Their content recommendation engine got both efficient and cost-effective.

    Change.org: More petitions, fewer servers.

    Podium: A million SMS messages a day and didn't have to massively scale hardware.
Re:Elixir Saves Pinterest $2M a Year in Server Costs by twelve40 on Tuesday August 29, 2023 @12:33PM (#37310351)
> a fleet of single core low, extremely powered machines.

what are "extremely powered machines"?

> It's like getting AWS-level functionality without the steep bill

which part of AWS functionality? load-balancing Beanstalk-style is free. AWS compute is not free, but neither is compute free with Elixir or whatever stack you run.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by weatherlight on Tuesday August 29, 2023 @12:52PM (#37310614)
sorry i meant (low powered*) typo
Re:Elixir Saves Pinterest $2M a Year in Server Costs by weatherlight on Tuesday August 29, 2023 @12:56PM (#37310675)
Totally get your point about AWS having free-tier services and compute never being free, regardless of the stack. My point wasn't that BEAM offers free compute, but rather that its inherent features can sometimes make certain AWS services redundant. For instance, Elixir has built-in fault tolerance with its actor model and supervision trees. This means that even when a process fails, it gets rebooted automatically without messing up other processes—kind of like what you'd use Auto Scaling and backup services for on AWS.

Similarly, distributed Erlang allows Elixir to run across multiple nodes. This could cut down the need for extra AWS instances or orchestration layers like Elastic Beanstalk. And when it comes to deployments, Elixir's hot code swapping can simplify what might otherwise require rolling updates or blue-green deployments with Elastic Load Balancers in the AWS ecosystem.

On the concurrency front, Elixir is designed for handling a high number of users and tasks simultaneously, which might reduce your reliance on EC2 or Lambda. Phoenix, Elixir's web framework, even has real-time capabilities baked in, so you don't need extra services like AWS WebSockets for that.

Finally, Elixir's actor model can serve as an in-memory message queue, which could potentially negate the need for something like AWS's SQS. So, while you're still incurring compute costs, the need for additional AWS services could be lessened, thereby simplifying your architecture and perhaps lowering overall costs.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by fsloth on Tuesday August 29, 2023 @08:06AM (#37306488)
It does not sound too incredible to me.

Erlang and BEAM was designed to handle Ericson's telephony services. Piping-lots-of-stuff-in-parallel in fault tolerant fashion is the main use case around which it was designed.

Of course this is anecdotal.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by pdimitar on Tuesday August 29, 2023 @08:13AM (#37306556)
What's your counter-argument?
Re:Elixir Saves Pinterest $2M a Year in Server Costs by wredue on Tuesday August 29, 2023 @08:45AM (#37306930)
They don’t need one.

When a person makes a claim, especially such a ridiculous one, it is perfectly valid to outright reject that claim without any argument. Why? Because no argument was provided in the first place.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by pdimitar on Tuesday August 29, 2023 @08:46AM (#37306954)
Well, I am trying to be better than them.

Also I dislike FUD spreading so there's that, I am trying to engage them in a more-informed manner.

Though I am not sure whom you are addressing, my parent poster or theirs.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by coldtea on Tuesday August 29, 2023 @09:21AM (#37307481)
>Also I dislike FUD spreading so there's that

Hype and FUD are different sides of the same coin

Re:Elixir Saves Pinterest $2M a Year in Server Costs by pdimitar on Tuesday August 29, 2023 @09:27AM (#37307575)
I agree.

Do you feel that Elixir is being needlessly hyped?

Re:Elixir Saves Pinterest $2M a Year in Server Costs by wredue on Tuesday August 29, 2023 @12:38PM (#37310414)
I would say that a person claiming that it provides better results with 1/50 the effort is a claim that needs substantiation and was born from a position of hype, yes.
Re:Elixir Saves Pinterest $2M a Year in Server Costs by pdimitar on Tuesday August 29, 2023 @12:45PM (#37310524)
And why is that so hard to believe for you? Do you think all technology is equal?
Re:Elixir Saves Pinterest $2M a Year in Server Costs by pdimitar on Wednesday August 30, 2023 @09:57AM (#37322254)
And that's why I am gonna drop HN one day, I get the gray treatment for asking questions and for people to clarify nebulous claims.
Re:Elixir Saves Pinterest $2M a Year in Server Costs by coldtea on Tuesday August 29, 2023 @09:20AM (#37307466)
Yes, this is what we call in the industry as "overhype"
Re:Elixir Saves Pinterest $2M a Year in Server Costs by sph on Tuesday August 29, 2023 @09:23AM (#37307521)
If I had said 1/4th the effort would that have invalidated my argument? I pulled that figure out of my arse from experience. YMMV.

You'll note I'm not selling anything here, and no one is paying me a commission.

A junior that got "swindled" by my claims and spends a weekend learning Elixir becomes a better programmer and earns another feather on their cap. How tragic.

Junior devs, if you want to become a senior greybeard like me, learn anything that tickles your fancy, and ignore anyone that says it isn't worth your time. Even learning COBOL will make you a better programmer. I can only promise that Elixir is more fun than COBOL.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by Horffupolde on Tuesday August 29, 2023 @09:39AM (#37307759)
He just means that junior developers don’t understand hyperboles because they don’t have the intuition yet.
Re:Elixir Saves Pinterest $2M a Year in Server Costs by Name_Chawps on Tuesday August 29, 2023 @10:18AM (#37308336)
I'm a junior Elixir dev.

I write concurrent code without much extra effort compared to non-concurrent code. Elixir makes it easy.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by eropple on Tuesday August 29, 2023 @10:22AM (#37308383)
You can do that easily in modern Java--even for older JVMs, tools like Netty and later Vertx have been around forever. Or in Node, even more easily.

Elixir/BEAM do have some benefits that are worth considering for many projects. But they absolutely are not special in this regard, and that's the junior-developer trap about which the person to whom you replied was referring.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by Volundr on Tuesday August 29, 2023 @10:32AM (#37308535)
Java, kind of with Akka or similar, although even with that one always be aware of blocking. Loom should help. Node: not really unless something dramatic has changed. Using 32 cores is going to require 32 separate node (OS level) processes, and your on your own for providing communication between them, plus callbacks aren't near as intuitive as the BEAM process model (think green threads)
Re:Elixir Saves Pinterest $2M a Year in Server Costs by eropple on Thursday August 31, 2023 @09:38PM (#37345781)
Re: Node - most waiting in most web applications is IO-driven, but yes you do want to run under a process controller.
Re:Elixir Saves Pinterest $2M a Year in Server Costs by Volundr on Friday September 01, 2023 @02:16PM (#37354387)
I mean sure, but given the topic at hand is getting performance out of your 32-core server, I'm not sure that's a super relevant observation. "I've been given way more hardware than I need" is an entirely different problem I think most of us would be happy to tackle.
Re:Elixir Saves Pinterest $2M a Year in Server Costs by collaborative on Tuesday August 29, 2023 @01:04PM (#37310790)
I'm a seasoned Java and Node developer, but have never touched Elixir/Erlang. Could you spell out for me the benefits Elixir provides over Java concurrent code? Is it actually a performance gain, or simply a nicer syntax? I am a bit confused by the claims of this post and of the earlier comment. Thanks a lot
Re:Elixir Saves Pinterest $2M a Year in Server Costs by weatherlight on Tuesday August 29, 2023 @02:28PM (#37311878)
So, when you're working with Elixir or any language on the BEAM VM, you're in a world where data is immutable and processes are isolated. It's like having Akka's actor model but at the VM level, so it's super integrated.

The BEAM VM itself is a different beast compared to the JVM. It's more like its own mini-OS designed for real-time multitasking. Each process has its own garbage collection, and it's all non-blocking. So if one process goes belly-up, it doesn't take the whole system with it. Imagine a network of telephone switches; if one gets zapped by lightning, the rest keep chugging along. That's the level of fault tolerance Erlang and BEAM were designed for.

Now, speaking of fault tolerance, let's talk about how easy it is to mess up an Akka system if you're not careful. Say a new Java dev joins your team and doesn't get Akka's actor model. They might introduce shared mutable state between actors, which is a big no-no and can lead to all sorts of race conditions. Or they might do something like put a blocking operation inside an actor, which can hog resources and mess up the whole system's performance. Akka's great, but if you don't follow its principles, you can still shoot yourself in the foot.

So, the beauty of Elixir and BEAM is that a lot of these good practices are enforced by the VM itself. You get that fault tolerance and concurrency baked right in, without having to rely on every engineer knowing all the best practices.

Hope that clears things up!

Re:Elixir Saves Pinterest $2M a Year in Server Costs by collaborative on Tuesday August 29, 2023 @02:31PM (#37311927)
That's interesting, thank you! Now I have new things to learn on my list :)
Re:Elixir Saves Pinterest $2M a Year in Server Costs by kaycey2022 on Wednesday August 30, 2023 @05:32AM (#37319481)
I recently saw a talk on Youtube about "structured concurrency" in Java. It looked pretty interesting. But it seemed to me the way to achieve parallelism is by starting on a procedural code flow and as you come to a part that can be parallelised, you split into a bunch of tasks in a scope and that scope will monitor how those are executed. Once the results are accumulated, we go back into the procedural flow. This is similar to what is done in go IMO and is a pretty good technique.

In Elixir, on the other hand, you could create a module which is like a server process. You can start this server in a procedural flow, or you can "connect" it to a supervisor by giving it the startup information needed and a strategy to be used on how to restart the process in case it crashes for some reason.

A client process (or processes) with it's own module can then send messages to the server which will handle the incoming messages in its inbox sequentially. If you squint at it from an angle, modules look like classes in that they provide a way to separate code logically.

This way of doing concurrency takes getting used to and has a higher initial learning investment. But it feels cleaner and is less prone to user errors. In go for example you have to be careful of closures and shadowing which will result in shared memory and hard to debug errors, even though the initial investment in learning Go is much lesser.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by OkayPhysicist on Tuesday August 29, 2023 @05:40PM (#37314507)
You may be enamored with the "nothing new under the sun" idea that "Turing complete is Turing complete, anything you can do in Python you can do in Brainfuck" but as someone who has written code professionally in about a dozen languages, no, you can't just as easily get the same kind of parallelism out of Java as you can Elixir. To assert otherwise is factually false.

Is it possible to get to the same result? Yes. It is not, however, anywhere in Elixir's ballpark of "easily". Do not discount the power of language-level, not just support, but encouragement. Especially when you're working with junior devs, if "the right thing" and "the thing the language wants you to write" are not in alignment, everything is much, much harder. Erlang and Elixir actively encourage easily parallelized code. Java activity encourages tangles of objects.

Re:Elixir Saves Pinterest $2M a Year in Server Costs by b33j0r on Tuesday August 29, 2023 @06:49PM (#37315177)
To senior developers reading this, such statements are never true ;)
Re:Elixir Saves Pinterest $2M a Year in Server Costs by mowthie on Friday September 01, 2023 @06:38AM (#37348999)
To non-developers reading this, I have no way of knowing whether such statements are ever true, but I am willing to believe they are not!
Re:Elixir Saves Pinterest $2M a Year in Server Costs by bsder on Tuesday August 29, 2023 @09:52PM (#37316693)
To all junior developers--this developer doesn't know what he is talking about.

Erlang and BEAM, the things underlying Elixir, were specifically engineered to be used in a reliable, distributed fashion including a gigantic amount of idioms and support that no other language comes close to.

Erlang's bit syntax is hands down the best byte stream serialization that still exists--both from a perspective of performance as well as expressiveness. OTP is a documented set of idioms and behaviors for building systems that are meant to be highly distributed and deal with failure gracefully. These include things behaviors like in-place upgrades, supervisors which shut down and restart failing processes, error delegation, etc.

Erlang was meant for genuine "five nines" reliability. No other language comes close (maybe Ada does--I'll let their proponents chime in about that).