How Elixir helped Bleacher Report handle 8x more traffic
techworld.com
techworld.com
I think the problem is that all of the focus arrows in on X vs Y, and not "rewrote the application". My opinion, and my experience, has demonstrated that once you understand the domain, a re-write in any language (including the original) is going to result in an improvement of similar magnitude.
They could have re-written it in Cobol and probably seen an improvement of similar magnitude.
But of course, "Y is n-times better than X" makes for a better headline and looks great on a Key Result slide...
It is easy to paint everything with ones or zeros but it is most likely a combination of factors.
A team with more knowledge of the domain, a management willing to try new technologies and a technology that excels at concurrency, which seems to be the problem they had at hand, sounds like a good combination for success.
"tl;dr Phoenix showed 10.63x more throughput over Rails when performing the same task, with a fraction of CPU load"
https://littlelines.com/blog/2014/07/08/elixir-vs-ruby-showd...
You can tack on a Phoenix app on top of a Rails app's database and immediately get big improvements as Rails can be a bottleneck.
Seems like you can choose either rails or ecto to manage DB migrations, but not use both simultaneously. This makes migrating to elixir more challenging.
Sure. So is Java, C#, C, C++, Haskell, Node.js, F#... I could go on. But let's be honest with each other here. What is the real chances that their speedups were really due to a computation bottleneck? And frankly, if it was due to a computation bottleneck, a language on the Beam VM was probably a bad choice.
> get big improvements as Rails can be a bottleneck.
Rails can be a bottleneck. It probably wasn't, though. I can (and have) take an average web app and short circuited a re-write by adding a few choice indexes to the DB. Or I could rearchitect it and move some data processing outside of the critical response sections and do the same. Or I could move a few choice resources onto CDNs and improve end user performance. Or do better compression on PNGs... Or change an O(n) function into a O(log(n)) function...
The list of potential improvements that have nothing to do with the speed of the language in question is almost endless. Ruby and RoR are pretty easy to scale, and if I were a project manager, I would personally have a hard time justifying limiting my hiring pool for the sake of a mere 8x speedup (unless I was honestly operating at a really silly scale).
I have this software that I've been rewriting since I was in university---so about 16 years of rewrites give or take.
Every time I pick up a new language, I rewrite it in the new language. It's an image gallery with bells and whistles, talking to databases, and video conversion. It's not totally trivial.
What can I tell you [1]?
My Java version that I wrote as a 2nd year student was the fastest overall for the next 8 years. Rewrites in Smalltalk, PHP, and Ruby were all worse by many orders of magnitudes. The Haskel rewrite actually made it perform worse [2]. Architecturally they were 'better', but that's only API expression.
The only time I've gotten a 'win' is when I replaced the core database technology (moved from Postgres to Elasticsearch), replaced caching tech (moved from Redis in App-layer to Redis in Nginx) and with Elixir (like Java its fast enough that there's no need for caching).
Elixir has a lot of built in tools and libraries that make handling concurrency a breeze. To give an analogy, it's like working with Lua in Nginx---it feels like you are writing your application right inside of the webservers event loop.
[1] Disclaimer: I am a language hipster, and Elixir is the last language I tried.
[2] Haskel and I do not get along. Odd really. I get along with other functional languages.
That said, cool set of experiments, and IMO a great way to learn new languages.
It'd be interesting too see how well the PHP version does now adays. It was written in 2007, PHP 5.1, and the main issue back then was memory consumption when handling multiple processes. I've heard PHP 8 is much better in that respect, with lower amounts of memory used in name brand applications like Worpdress.
Even if not, I love this idea for learning new toolsets.
Nope, I just fell in love with a class project and expanded it greatly.
If you decide to go this route, I'd suggest picking an old class project too. Class projects are pretty much cut down to whatever a student can build within 2 months, taking into account that their time is split 5 different ways and they are inexperienced in the language.
It's the perfect amount of depth so you're not writing a toy project, but you are also not overwhelmed and consider this a real "side project" or 2nd job.
If you want something smaller---do a chat app. They're dead simple, and will teach you the network stack of whatever language you are using. Add some bells and whistles like image sharing to make it like Yahoo 2.0, and you'll have something fairly meaty.
Ruby is, sadly, just slow. From my testing, Elixir/Phoenix is out of the gate 10x faster than Rails. Now, they saw a 30x speedup here, so I wouldn't be surprised if some of that came from a rewrite, but it's definitely not the case that all of it was.
There's a lot of optimizations which had a larger effect on the speedup than the choice of language.
Accessing a slow DB in elixir will be faster than accessing a slow DB in ruby.
The way Rails apps often work is that something like unicorn is used to maintain a pool of worker rails processes, which handle requests synchronously. That worker process will block while it waits for IO requests such as DB and HTTP requests.
In this model, the worker memory footprint can end up being the problem, rather than speed of execution. Particularly in large Rails with many gems, loading the application can take up to hundreds of MB. This sets a fixed limit for the number of concurrent workers/requests.
Rails doesn't _have_ to be used this way, but trying to write a concurrent-safe application in Ruby/Rails can be an uphill battle, because many gems do not work this way.
Elixir does not have this constraint, because only a small part of the system (a single actor) is blocked waiting on I/O. This makes it much easier to support many more concurrent requests.
You're not wrong - that's certainly a factor - but Elixir is also just massively faster.
Yes, understanding the problem domain helps. But we already knew the domain and had done refractors in Ruby before then: this isn't our first rodeo ;)
Elixir is just much better suited to the highly concurrent tasks we use it for. Seeing 5-10ms response times on some of our services would just not be reasonable in Ruby/Rails. We know - we tried!
But you're not wrong: understanding the problem IS key to building an efficient solution. It's just that the tools you use will also have an impact. Elixir is a great tool.
1) no support from mega corporations 2) not that many developers to choose from 3) while based on BEAM it's still too "new" 4) too slow for raw money crunching
I didn't need rocket fast performance and I didn't need any JVM libraries, but I did like the actor model of concurrency and process supervision, so when it came time to look for greener pastures, Elixir was a solid choice. I've been using it in production just over a year, and it's been excellent.
The BEAM VM is what makes all this possible and the BEAM VM has been around for decades.
Many of my dev friends with hipsterish inclinations jumped on the Elixir hype train in the past year or so. I really don't see how this is different than past "hype phases" of other technologies.
If I am not mistaken Elixir is primarily a front end that generates code for the Erlang VM (BEAM) supported by the Erlang OTP backend.
Having said that the questions remains, why doesn't Erlang get the same hype? I am hazarding a guess that a majority of developers still work in the imperative style and switching to the functional side takes a bit of relearning in the way you think.
Erlang accumulated a lot of worts, but it never really got rid of them.
I don't think Syntax matters all that much. Smalltalk's syntax is pretty odd, but its regular and simple to explain/understand, so people quickly come to like it. Smalltalk's VM's though are a huge barrier to entry.
Erlang is the reverse: great VM... great architectural decisions... great libraries.... questionable language semantics.
Erlang did get the same amount of hype, probably multiple times in the past 20 years. So did many, if not most reasonably well-known languages, programming paradigms, architectural solutions, databases, frameworks and so on.
I do not make any judgement about the merits or maturity of Elixir itself. Elixir is perfectly fine.
As developers we should have a healthy dose of skepticism when it comes to blog posts that claim 10x speed improvements with technology X. Was it just the rewrite? Does your use case match mine? And so on... In short: Everything is a trade off, and there is no silver-bullet.
Not that Elixir is bad, but if you are writing something in it today you are ahead of the curve. As soon as there are a lot of mediocre developers (if we get there) that start using Elixir because they heard it can do no wrong, you'll hear complaints.
Ruby on Rails, ASP.Net, Django, they all have a million and one StackOverflow answers, blog posts, and books written about them. I found out the hard way that Elixir and Phoenix docs aren't as prolific. That and the names are less Googleable.
Some people may like that challenge, but it does add a level of difficulty.
``` @doc This is some useful, markdown documentation, which actually contains usage info.
## Usage
## Examples
```Odd, because I have found the opposite to be true about the docs. I've found the docs proper to be quite prolific, well maintained and well-written with examples. This stems from docs being first-class citizens of the language, a dead-simple docs generation tool, and their dogged commitment on excellent documentation (which is why docs are first-class citizens to begin with).
> That and the names are less Googleable.
That said, the _SO/Google_ aspect (not docs) is _significantly_ less prolific - I totally agree with that. But I've found where with other languages I often find myself on SO (C# and JS mainly), I haven't even needed it because the docs are just so well maintained (and versioned). This, plus their community is _extremely_ active, on the elixir forum and github (also slack, but I use that less).
So now, when I google for elixir info, I'm basically googling to get to the official documentation quickly. If there is any question I have beyond that, I check the elixir forum, rarely (but sometimes) needing to post a new question. Perhaps I've just had a different experience wrt this.
I chalk it up to my C# dev background, where source code was either completely impenetrable, a Sacred Thing that nobody should feel privileged to look at, or both.
I'll have to give it another look sometime.
I think people coming from OOP find FP hard and seem to struggle with things like Ecto and definitely Macros.
Once you have mutable state everywhere and problems with the GIL and throughput on routes being slowed down too much so you start moving everything into queues (celery or rabbit). Then you realise that all of this could have been avoided and made much much easier to test if it were all written in Elixir.
I really don't get this. Elixir is barely FP—just immutability and first class functions. Is it really that hard for a lot of people? It's not Haskell or Clojure (""weird"" syntax).
I'd argue the hard part of Elixir is OTP and taking advantage of distributed computing.
> haven't encountered the problems Rails/Ruby or say Python has.
This is a good reason, honestly. If Ruby is fine, why change? It'll just make learning a new paradigm and OTP less fun because there's no need to learn it.
Or do employees just WFH when they need to actually produce stuff?
Engineering is on a different floor, still open plan, but has lots of small meeting rooms for quiet work too. Also a pool table
This is probably sufficient for an intro video series…
1) Installing, including all of the dependencies: 2) Making a new project. 3) Setting up a data model. 4) Building CRUD routes. 5) Building views. Can you use haml, sass, etc.? 6) What’s the equivalent of the console? 7) Deploying to production. How does that work?
If any Elixir enthusiasts are interested in teaming up, let me know.
BTW, I was a Rails developer before I moved to Phoenix. Given that Phoenix is modelled after Rails that is the easiest transition there is (though it gets more and more different with every release and 1.3 will be a big step - and those are good changes).
We want to build the Rails blog tutorial, but in Elixir+Phoenix, and specifically for Rails users.
Definitely, please send me an email: zack@zackburt.com if you'd like to be involved in the project.
* Bus factor of 1?
* No visibility of improvement process (i.e. PEP)?
* Long term support?
How would you resolve this? do consultancies that build projects for clients in Elixir are aware of that? or notify the client of that?
The core team is made of six members: @josevalim, @fishcakez, @ericmj, @lexmag, @whatyouhide and @true_droid. We have more than 500 contributors on GitHub, it is an accessible codebase. The areas where the bus factor is actually 1 are very rare (and when I can I delegate work to minimize that).
> * No visibility of improvement process (i.e. PEP)?
All planned improvements are currently in the issues tracker: https://github.com/elixir-lang/elixir/issues. It is a short list because it is a stable language and the focus is on the ecosystem rather than the language.
Proposals are sent before hand to elixir-lang-core mailing list for discussion.
> * Long term support?
List of consultancies currently involved with Elixir: https://github.com/doomspork/elixir-companies#consulting
Plus Plataformatec has been doing and supporting Elixir for 5 years and Erlang Solutions has been supporting Erlang for way longer than that and they also provide Elixir support.
I was hoping to catch you here or on IRC :)
For instance, they could have gone with .net and gotten nearly the same results AND had a stable of millions of devs to pull from.