4 ms·
Yet another "Originally wrote in X, rewrote the application (in Y), and it was so much better!" story. I think the problem is that all of the focus arrows in o
by falcolas 10y ago
Yet another "Originally wrote in X, rewrote the application (in Y), and it was so much better!" story.
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...
- overcast 10y agoCorrect. Unless we're talking about extremely specific software, new performance typically just comes from newly learned skills. More efficient database calls, removal of long running loops, yada yada. I've revisited software I wrote for a company in my school days, only to decrease SQL calls from one minute to less than a second.
- christophilus 10y agoI agree. I'm not sure if the system would show a 10x improvement, but every time I've done a rewrite-- usually in the same language as the original-- almost everything improved dramatically (UX, performance, maintainability, etc). I now think that V1 should be considered throwaway, or at best research intended for exploring and understanding the problem space.
- noop123 10y agoPutting all the success in terms of "rewriting" is as misguided as accounting it all on the technology change. I have seen rewrites using the same technology fail due to scope issues. I have seen rewrites fail because they could not master a new technology. 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.
- xutopia 10y agoExcept Phoenix and Elixir are just faster out of the gate than Rails and Ruby! "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-showdown-phoenix-vs-rails 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.
- tarr11 10y agoI briefly looked into this, but it looks like there are a few differences in ecto migrations which mean that it's not perfectly smooth to use the same database. 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.
- josevalim 10y agoI'd recommend setting the `:migration_source` in your Ecto repository configuration and picking a different table name than Rails. But be careful, having two different sources changing the same database can be a disaster waiting to happen.
- falcolas 10y ago> Except Phoenix and Elixir are just faster out of the gate than Rails and Ruby! 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).
- true_religion 10y ago> 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. 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.
- falcolas 10y agoHave you tried re-writing the Java version again with a modern version of Java, and with other lessons learned? Just curious. That said, cool set of experiments, and IMO a great way to learn new languages.
- yetihehe 10y agoI'm currently writing a java server after working on an erlang server and I miss erlang daily. "Concurrent" libraries like vert.x feel just odd with their callbacks although lambdas made this a little less awkward.
- true_religion 10y agoNo, I haven't done that but it is a great idea since the language has really gone through improvements. 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.
- losvedir 10y agoDo you respond like this when people talk about rewriting the hot loop part of their Python in a C extension, too? 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.
- falcolas 10y agoRuby is slow. But a database is orders of magnitude slower. So is a O(n) function when compared to a O(log(n)) function. So is transferring unoptimized files; or not serving static files over a CDN... There's a lot of optimizations which had a larger effect on the speedup than the choice of language.
- TylerE 10y agoThe thing is that all your database communication is going through your language as well. Accessing a slow DB in elixir will be faster than accessing a slow DB in ruby.
- anorwell 10y agoI don't think "slow" is the real issue here, but rather concurrency models for IO-bound applications. 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.
- abritinthebay 10y ago(N.B. I work at Bleacher Report, but this is just my opinion) 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.