Live data from Hacker News

Elixir saves Pinterest $2M a year in server costs

paraxial.io

191–200 of 481 posts

Re: Elixir saves Pinterest $2M a year in server costs

#191
post #3

By the title alone, this means nothing. How much would it cost otherwise? What is the percentage savings? In TFA, it gets better though: "Steve: That’s pretty easy. When I started on the spam team, we had close to 1,400 servers running. When we converted several parts to Elixir, we reduced that by around 95%. One of the systems that ran on 200 Python servers now runs on four Elixir servers (it can actually run on two…

Second system syndrome. They did savings by re-implementing their services and attribute those savings to the new tool / programming language. I wonder what the saving would look like if they chose another tool for the second / optimized system. I doubt it would differ much if they went with Go, Java or stayed with Python.

This is a pretty realistic balanced real-world benchmark of web frameworks (and languages): https://www.techempower.com/benchmarks/

It shows that Python with Django is literally 40 times slower than the fastest framework. Python with uvicorn is 10 times slower.

The use of languages like Python and Ruby literally results in >10x the servers being used; which not only results in higher cost, but also greater electricity use, and pollution and carbon emissions if the grid where the data center is located uses fossil fuels.

Not to mention, dynamically-typed languages are truly horrible from a code readability point of view. Large code bases are IMO difficult to read and make sense of, hard to debug, and more prone to bugs, without static types. I'm aware that Elixir is dynamically-typed, but it (along with JS) is an exception in terms of speed. Most dynamically-typed languages are quite slow. Not only do dynamically-typed languages damage the environment as they're typically an order of magnitude slower, they also lower developer productivity, and damage the robustness and reliability of the software written in it. To be clear, I'm in favor of anything that increases productivity. If Kotlin were 10 times slower, I'd be happy to pay that price, since it is genuinely a great language to work with, is statically typed, and developers are more productive in it. I'm not sure how Elixir mitigates the downsides of dynamic typing (maybe lots of 'type checks' with pattern matching?), but it would definitely be super-nice if a well-designed (Kotlin or Haskell like?) statically-typed language targeting the BEAM existed...

Re: Elixir saves Pinterest $2M a year in server costs

#192

Earlier quoted context omitted.

You seem to be wrong, at least based on the quote you chose to use here, as Steve doesn't even mention anything related to functional programming?

Elixir is a functional language for the Erlang VM. Most C++/Java/Rust/... programmers wpuld have hard time understanding it. But if you are in a bubble where everyone uses Haskell and talks about Monads, then OPs statement may be valid

Monads and Haskell is not a requirement to understand a functional programming language.

Also, I find it hard to believe that anyone who knows N+1 programming languages would have a hard time understanding Elixir quickly, it looks like most mainstream programming languages used today, with slightly different syntax for some things.

Take a look at https://elixir-lang.org/crash-course.html and you'll see what I mean, it's basically Ruby with some slight modifications.

Re: Elixir saves Pinterest $2M a year in server costs

#193

I am very skeptical about this. The title makes it look like it's all about Elixir, but there seems to have been a fair amount of re-architecturing. "One of the systems that ran on 200 Python servers now runs on four Elixir servers" This alone is a major telltale.

I don’t know about Elixir specifically, but python is slllllooooowwww. If the operation is CPU bound, you can easily get a 100X performance improvement by rewriting carefully optimized Python in naive Go, Java, Rust, C#, etc. And if you make an optimization pass on that you can usually eke out another 10X.

Even on I/O bound operations, in Python you have to choose between the error-prone async framework if you want to improve resource utilization or you stick to the synchronous world and accept extremely low resource saturation.

Either way, I can entirely believe that another language would beat Python on both counts. I’ve seen similar results rewriting a Python system in Go with extremely minimal rearchitecting.

The silliest thing is that the title credits the improvement to moving toward Elixir rather than moving away from Python (or maybe their case really is ideal for the BEAM VM and wouldn’t translate easily to, say, Go’s runtime model although I doubt it).

Re: Elixir saves Pinterest $2M a year in server costs

#194
post #39

It’s interesting because while this is an extreme case of performance improvement, the ROI doesn’t seem amazing. "rewriting in another language reduced the number of servers by 95%" is hard to beat, but at the same time, this saves "only" 2m a year, or about 0.3% of FY22 cost of revenue (per another post) Pinterest per employee revenue seems to be around 1m, which basically suggest that this could even be a worse tha…

It more than just server costs. They reduced the complexity of their services by a lot. Having to maintain 95% less servers is worth it even if they didn't save any money IMO. This also could lead to them reducing their engineering team that maintains these services which would reduce costs even more.

Can switching to an esoteric functional language from Python and Java really be considered reducing complexity? No matter how well it is written, I'm willing to bet that way fewer people in the company/industry understand the new codebase and can make changes to it.

Re: Elixir saves Pinterest $2M a year in server costs

#196

Earlier quoted context omitted.

I think second syndrome is probably a significant factor, but I can also believe that ditching Python was also a significant factor. EDIT: I’m being rate limited because I guess my comments are too spicy for the HN mods, but anyway I agree that there’s no reason other non-Python languages would fare much worse than Elixir.

Even if we take this as a factor, there's still no reason why would a Go or Java or SBCL implementation be significantly worse than Elixir.

There is a reason: the BEAM is almost not prone to huge GC pauses. Bigger load results in every actor responding very slightly slower. Nothing else.

Many other systems don't have this property. They fall down under pressure.

Gosh, a huge chunk of HN is always so dismissive. At least read up a bit beforehand, man. The criticisms should be informed and benefit the readers, not only express a generic skepticism.

Re: Elixir saves Pinterest $2M a year in server costs

#197
post #151
post #64

Earlier quoted context omitted.

The advantages of Elixir are not performance-related. There is a lot of focus on raw performance on web-related services, when in reality most of their running time is spent waiting for IO. If there are two things the BEAM excels at, is IO and turning almost any problem into half a dozen processes that are scheduled and run in parallel, if not geographically-distributed, with 1/50th the effort of any other language.…

> ... with 1/50th the effort of any other language. To junior developers reading this, such statements are never true.

What's your counter-argument?

Re: Elixir saves Pinterest $2M a year in server costs

#198
post #66

My problem with Elixir is that the syntax is too noisy: defmodule Math do def sum(a, b) do a+b end end Compare that with Python: def sum(a, b): return a+b Having the name of the file be the name of the module and whitespace defining the blocks is the perfect approach for me.

def sum(a, b), do: a+b

Sure, if you don't like having the name of a module/class at the top of a file that excludes a lot of language.

Re: Elixir saves Pinterest $2M a year in server costs

#199
post #64

Earlier quoted context omitted.

> When our notifications system was running on Java, it was on 30 c32.xl instances. When we switched over to Elixir, we could run on 15. Would be curious to know how they tried to optimise the Java stack. Because on every benchmark I've seen the JVM is faster in every which way than Elixir. Except for memory where often people will over-provision the JVM rather than look at where their code might be over-allocating o…

The advantages of Elixir are not performance-related. There is a lot of focus on raw performance on web-related services, when in reality most of their running time is spent waiting for IO. If there are two things the BEAM excels at, is IO and turning almost any problem into half a dozen processes that are scheduled and run in parallel, if not geographically-distributed, with 1/50th the effort of any other language.…

I wrote the same kind of tool in both Elixir and Go, the performance difference was huge between the two, Elixir / Erlang is pretty slow overall.
Post reply on HN