Live data from Hacker News

Elixir saves Pinterest $2M a year in server costs

paraxial.io

461–470 of 481 posts

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

#461
post #63

Anecdotally, I am beginning to hear more and more about organisations moving away from high level cloud infrastructure (such as lambda and cloud gateway) and going back to plain old virtual servers (like EC2), or even on-prem. Often the cost of supposedly "cheap" cloud environments is WAY more than you might expect and all booked as operational rather than capital expenditure (the latter being often preferable to sha…

I wonder if this will be another effect of higher-than-0 interest rates. With tech companies choosing to leave cloud service providers in order to reduce their costs.

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

#462

Earlier quoted context omitted.

That perfectly describes my usage of Pinterest. People have written browser extensions to remove Pinterest from search results, as it is almost always a dead-end

Maybe to you, but my wife uses Pinterest a ton. It is where a lot of the women I know go to for ideas for just about everything, from house decor to even the ideas for our wedding. Pinterest is useful just not for us nerdy guys. I am not sure why Google keeps it though or how they benefit, unless Pinterest uses AdSense exclusively, then one can determine that its some sort of partnership. You would think Google would…

As someone who uses Pinterest for its intended purpose, like home decor inspiration, fashion ideas, etc.. It’s actually very nice! It’s structured like a moodboard, a format that fits me nicely whenever I‘m looking for ideas… However! Even though I enjoy and use Pinterest, it’s never what I want to see in Google Images. If I need to find the artist of a drawing for example, Pinterest is often spammed to me in the results, often with a link leading to absolutely nowhere. Usually the Pin is locked behind a login, which is annoying since I only use the app on my phone. There’s tons of reasons to dislike Pinterest on Google, it’s not just a dichotomy between nerds and women (not to mention that these groups have overlap anyway, of course).

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

#463
post #404
post #349

Earlier quoted context omitted.

> The go runtime has similar capabilities as the BEAM runtime when it comes to concurrent workloads. Only if you think that the BEAM is similar to being able to easily spawn a function on a separate thread and having channels. Last I checked, goroutines had no mailboxes, supervisors, process monitoring, registry, and its scheduler has a much smaller scope and featureset than the BEAM's. I swear it's obvious when peop…

I've written non-trivial code in both Erlang and Go. Beam doesn't have anything to do with supervisors that's an OTP thing. mailboxes can be simulated with channels and there are conceptual similarities. process monitoring and the registry are unique to BEAM it's true and they have useful properties to leverage. But they aren't core to how the BEAM handles concurrent processing. The schedulers work on a similar conce…

> Beam doesn't have anything to do with supervisors that's an OTP thing.

The key VM feature you're missing is process isolation. Without it, supervisors are not really possible - you can implement something that vaguely looks like them, but it won't provide the fault tolerance guarantees.

Imagine for example an Erlang process that leaks files. At some point it hits an EMFILE, gets killed, and the supervisor restarts it. The system will then go back to operating normally.

Now imagine a Goroutine doing the same. It hits EMFILE, exits, and the supervisor restarts it. This doesn't help anything: it just hits the same error and the system is unusable. There's no way for the VM to guarantee cleanup when a Goroutine exits, because it doesn't isolate Goroutines and track which one owns which resources.

Links and monitors are tools to extend the same behavior to user-managed resources like DB connections and so on. The responsibility for cleanup if a process crashes while holding a DB connection falls on the DB connection library, not on the error handling inside the crashing process.

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

#464
post #404
post #349

Earlier quoted context omitted.

> The go runtime has similar capabilities as the BEAM runtime when it comes to concurrent workloads. Only if you think that the BEAM is similar to being able to easily spawn a function on a separate thread and having channels. Last I checked, goroutines had no mailboxes, supervisors, process monitoring, registry, and its scheduler has a much smaller scope and featureset than the BEAM's. I swear it's obvious when peop…

I've written non-trivial code in both Erlang and Go. Beam doesn't have anything to do with supervisors that's an OTP thing. mailboxes can be simulated with channels and there are conceptual similarities. process monitoring and the registry are unique to BEAM it's true and they have useful properties to leverage. But they aren't core to how the BEAM handles concurrent processing. The schedulers work on a similar conce…

> Beam doesn't have anything to do with supervisors that's an OTP thing

Are you aware Erlang was designed to be a VM(the BEAM), a language for that VM(Erlang) and a comprehensive set of patterns and infrastructure for fault tolerance(OTP)?

All these as a whole are Erlang and the whole reason it has such reputation. I recommend reading https://erlang.org/download/armstrong_thesis_2003.pdf

> But they aren't core to how the BEAM handles concurrent processing.

They are, unless you want to reduce it to "it's just a pre-emptive scheduler with greentrheads".

> In my experience I think my statement still stands.

They're similar in that both have (mostly)pre-emptive schedulers, that's about it.

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

#465

Earlier quoted context omitted.

The bigger cost is that it takes a lot more devs to do the same thing in Python or especially in Java. Productivity per developer is hands-down Elixir's strongest selling point, not reducing server costs. Python and Java have a multitude of web framework authors and yet none have made anything with the capabilities and ergonomics of Phoenix. I don't think they will either. It would take features those languages lack.

> more devs to do the same thing in Python or especially in Java i guess it totally depends on "the thing" in question, but do you have any references for that assertion? that common web framework-ish, orm-ish stuff takes a lot more devs in python and especially in java?

It takes very little effort to ask a question like this and an essentially unbounded amount of effort to answer it to the satisfaction of the asker, so please be understanding if this isn't as much depth as you're looking for. I'll answer in three ways:

The first reference for this assertion is anecdotal. I've been a professional dev for 13 years and grew up with family members and friends in the same line of work. I've seen and heard of many, many projects built in different languages and anecdote after anecdote has been in the direction of people getting more done more quickly in higher-level languages. Writing similar things in Elixir/Clojure/etc goes faster than it does in Ruby/Python/JavaScript, which goes faster than using Java/.Net, which goes faster than using C/Fortran/Pascal. You haven't been around for those anecdotes I've heard, but a public one you may be familiar with is Discord. They scaled to over 5 million concurrent users on just 7 server engineers IIRC. Two years later, at a much larger scale, they still only had 4 engineers focused on infrastructure and 40 total: https://news.ycombinator.com/item?id=19238221. How many cases can you think of where a team of 7 Java or Python devs built something equivalent?

Secondly, there's research. Google "Function Point Metrics". Most research on programming productivity is paywalled but I shared one paper that isn't on one of my first Elixir-focused YT videos 5 years ago: https://www.youtube.com/watch?v=1e2_NXLxi-E&t=412s. Obviously this isn't perfect since it doesn't include what is appropriate for what domains or how well they scale with project size. Still it's a useful data point, as are pure measures of expressiveness: https://redmonk.com/dberkholz/2013/03/25/programming-languag...

Finally, thinking from first principles, why would anyone be adopting newer languages if they didn't offer some advantages over older ones? Why would certain features, such as pattern-matching and macros regularly be adopted by languages of the past 15 years, despite being very rare in languages created in the 90s? Furthermore, why would startups—for which productivity is a matter of survival—be early adopters? The simplest explanation, in my opinion, is that there really are some productivity advantages and sometimes those advantages are enough to overwhelm the difficulty in learning something new and working in a smaller ecosystem.

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

#466
post #444

Earlier quoted context omitted.

Elixir has a repl too! and I mean a repl in the LISP sense of a REPL. I can open a repl on my machine and peer into a production machine and its internals.

I think people underestimate Elixir. Is it easy to pick up?

Yes. I think so. It has an algol type/ style syntax.

If you can wrap your mind around immutability of data structures and understand how to use enumerators instead of loops for iterators, you're golden.

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

#467

Earlier quoted context omitted.

I think dynamic langs are easier to pick up than statically typed ones. But thats just me, I guess.

Easier to pick up, harder to use. A spade is easier to pick up than a digger, but try digging foundations with a spade.

Is it though? I've been using dynamic langs my entire career, and static ones too!

I feel like statically typed langs, (I'm looking at you Java), are a bit more stubborn to work with, especially around API design, prototyping, greenfield stuff.

I do like langs like Haskell and Standard ML where they are statically typed, the the type system is mathematically sounds, and the types are inferred.

I want my type system to be inferred and bomb proof or to just get out of the way. Its the best of both world.

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

#468

Earlier quoted context omitted.

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

Since you mentioned them I think it's worth telling people to take those benchmarks with a larger grain of salt. They've become such a pissing contest that I don't know if they can be called "real-world". There doesn't seem to be much scrutiny of the implementations. Take some Rust frameworks: they write out pre-computed header strings to the output buffer, completely bypassing what the framework's documentation reco…

Hmm, the pre-computed header strings is definitely interesting optimization, and does seem to be a bit non-idiomatic – but IMO, this is the sort of optimization the framework itself should try and do.

If first several bytes of the header are going to identical for many requests, a super-optimized framework would ideally memoize it, and write it directly out, as this benchmark is doing.

(And if the framework itself is doing it, then any user of the benchmark would just inherit that optimization, and not have to resort to non-idiomatic optimizations...)

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

#469

Earlier quoted context omitted.

> they may not have even existed if they were written in staticly typed languages This is pure speculation. There's no way you can back this up with any sort of real data. The inverse isn't true either. StackOverflow was written in C#, and it's been doing perfectly well. I've addressed another commentor making a similar presumption as you, here: https://news.ycombinator.com/item?id=37312297 The only thing I'll conced…

Stack overflow is miniscule compared to Twitter or Facebook. You can just book at Basecamp if you want to pick a smaller company. They are Ruby on Rails and they have been consistently doing well. Ultimately billion dollar companies have been built on dynamic languages. There is nothing stopping you from succeeding with dynamic languages. There just isn't. There are tradeoffs and these companies made them.

I agree that there isn't much necessarily stopping a person succeeding due to the choice of language (unless it's some esoteric or otherwise unrealistic language).

Yahoo used C++ for instance (it would not be my choice, even though it's weakly statically-typed).

But, yea, like you said--there are tradeoffs.

I think dynamically-typed languages has the allure of letting you build quickly initially, but the downsides of dynamic typing start hitting pretty soon afterwrd.

I write a lot of small scripts in Python. It certainly is easier to throw something quickly together, especially when the data model is amorphous, with dynamic typing. But that doesn't mean I'd use Python for a large project.

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

#470
post #223

Earlier quoted context omitted.

Reading higher in the thread, some Elixir folks are saying that the techempower benchmarks used the wrong settings (debug mode, etc) for their Elixir benchmark.

Though that doesn’t change the crux of my question (rather it reinforces it): why invoke that benchmark in this context at all?

The fastest Elixir framework on the list, phoenix, is about as fast as uvicorn. (Both around 10 times slower than dragon.)

I was mostly responding directly to these 2 statements from my parent comment:

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

Which I didn't entirely agree with.

Post reply on HN