7 ms·
Upgrading GitHub to Rails 3 with Zero Downtime
- reedlaw 12y agoI'm curious how they handled the differences between the Rails 2 and Rails 3 applications once they enabled dual boot. Surely not all of the changes were compatible. In the Gemfile example, there is some conditional logic that loads different gems depending on whether or not they used RAILS3=true. Was the entire codebase similarly littered with conditionals? That seems like it would be quite a mess.
- alttab 12y agoOnly temporary and easy to remove. It would be tricky if entire classes/objects/abstractions were missing entirely. This would require essentially reimplementing that part of the code. For other Rails version changes, for instance, the removal of RJS as a default component in rails 3.1 could require that you re-architect certain user flows or pages in your app.
- holman 12y agoLots of conditionals, yeah. This isn't really a bad thing, to be honest; it's far better than maintaining two separate branches. We already use similar conditionals when dealing with feature flags, so it's not really something that feels out of the ordinary in our app at all. What's more, we found that if there was a file that had a ton of complicated, interwoven logic between the two versions of Rails, it was a clear sign we should see if we could instead backport a Rails 3 or 4 component so that we could nix the entire Rails 2.x-style functionality.
- why-el 12y agoExactly. I handle API changes the same way at my place (Its an internal API exposed to colleagues only).
- ics 12y agoFor those of you keeping score: - Yes, Rails 3 was released four years ago - Yes, the current stable version is Rails 4.1, which left us two major versions behind We had work to do in order to live in the modern world again. Okay, so why didn't aren't they transitioning to Rails 4? I'm not clued in to much more than the version numbers so I suppose there are reasons that go a little deeper than 'the lowest version that works with the gems we want'. They've been working on the transition for six months according to the post, making it recent enough that 4 would be the 'obvious' choice unless there were fears that it wouldn't be stable (IIRC Rails 4 has only been so for a few months).
- reedlaw 12y agoIt's usually wise to handle large transitions incrementally. Rails 3 before Rails 4 is probably a wise choice.
- technoweenie 12y agoWork has started on the move to 3.2: https://twitter.com/charliesome/status/511517393038753794 https://twitter.com/charliesome/status/511517393038753794
- jack_jennings 12y ago2 to 3 was a more difficult update. If I recall correctly, a feature of 4 was that the upgrade path was more reasonable.
- pothibo 12y agoRails 4 support ruby > 1.9.3 whereas rails 3 supports 1.8.x. I believe this could be the main reason why they didn't move to Rails 4. Ruby 1.8.x -> Ruby 1.9.x requires quite some work by itself.
- alttab 12y agoMainly due to string encoding. For something like Github, mistakes there could be disastrous. With all of the special characters and user input there are bound to be wild edge cases.
- flowerpot 12y agoVery interesting! Just wondering, does GitHub actually have so few dependencies as described?
- shayfrendt 12y agoI wish! Nah I just took a snapshot of the Gemfile for brevity.
- rurounijones 12y agoIt would be really interesting to see which (public) gems the Github front-end app itself uses. Would it be possible to post that?
- hemancuso 12y agoAm I the only one who read this as: tl;dr - don't get too far behind Rails, it's fucking painful and expensive if you do.
- brandonmenc 12y agoProbably any framework is painful to be two major versions behind with.
- tonyedgecombe 12y agoWhy would it be any more difficult to migrate from 2.3 to 3 now instead of four years ago?
- raus22 12y agotime == more code that can break
- davidw 12y agoI'm a big fan of Rails, but I think that Rails does not really give a lot of weight to backwards compatibility. The Ruby community in general often feels like it's always charging forward, very often with tons of cool new things, but occasionally leaving broken, incompatible software in its wake.
- yazaddaruvala 12y agoYou seem to imply there is something wrong with that.. As long as you bump the version number and support the old version for bug fixes, it ends up being the best way to move the world forward.
- davidw 12y agoI tried to keep my comment kind of neutral, actually. There are advantages and disadvantages, and the Ruby community does pretty well, by and large.
- yuhong 12y agoSo are they using Rails LTS or forking Rails 3.0 themselves?
- masklinn 12y agoThey're definitely not forking Rails 3, they're not staying on it either: https://news.ycombinator.com/item?id=8322826 https://news.ycombinator.com/item?id=8322826 > We already have the app booting on 3.2; the goal is to try to get to 4.0 and track master fairly quickly. No one's eager to have to go through this whole process again in a year. ;)
- jrochkind1 12y agoI think Rails 3 is _already_ security-fix only. But I understand why they did it. And I sympathize. The Rails treadmill is a harsh regime. I wonder if they're considering what the heck they are going to do when Rails 5 comes out (target: spring/summer of 2015. Less than 12 months) and Rails 3.x stops even receiving security updates. I mean, clearly they have the resources to backport security updates themselves that's not a problem -- it's just that they're still not quite in 'the modern world', they've just kept from falling even further behind.
- holman 12y agoWe already have the app booting on 3.2; the goal is to try to get to 4.0 and track master fairly quickly. No one's eager to have to go through this whole process again in a year. ;)
- InAnEmergency 12y agoRails 3 is already only receiving security updates for "severe" issues, see http://rubyonrails.org/security/ http://rubyonrails.org/security/
- jrochkind1 12y agothanks for that link! While it says `/security`, it's actually the only link I know of with an updated list of how the maintenance policy applies to current versions. I hadn't been able to find such before, only dated news/blog announcements, which can get out of date really quickly as fast as Rails goes.
- tootie 12y agoI feel like the lesson here is not to put mission-critical systems on leading edge software. I'd be porting to Java at this point. GitHub is a big boy company.
- wging 12y agoIn 2014, Rails is not leading-edge software.
- imjoshholloway 12y agoIt's `web scale` and everything
- tootie 12y agoIt was when they started.
- Tenhundfeld 12y agoLeading edge is subjective. Rails was already 3-4 years old and already being shipped standard on OSX when GitHub was launched. IMO, that's not excessively leading edge for a small startup, especially if the founders already know the framework.
- iagooar 12y agoParty hard like it's 1999.
- kevinsf90 12y agoFor a large codebase, these upgrades will be a pain, especially on ruby/rails. To scale in the long run, it'd probably be wise to modularize & split the codebase into microservices, and at the same time, port to, say, a scala or java based framework (like Play).
- lucaspiller 12y agoI'd be interested in hearing a bit more about how GitHub structure their app. From the sounds of it, they have one big monolithic app. Running the tests can't be pretty on that...
- holman 12y agoYup; one monolithic app. Tests run in a tad over two minutes.
- VeejayRampay 12y agoTwo minutes is actually pretty fast for such a large app. Well done. And congratulations on the migration.
- imjoshholloway 12y agoWhat's the coverage on that?
- nathan_f77 12y agoThat is insanely fast, for what must be an enormous codebase. Do you mean it runs in two minutes on your Mac, or on distributed CI servers?
- charliesome 12y agoWe use the test-queue gem (https://github.com/tmm1/test-queue https://github.com/tmm1/test-queue) to run our test suite in parallel across 10x 8 core machines.
- jjuliano 12y agoBeen There, Done That.. yep, I've upgraded a hundreds of thousands of Rails 2 codebase to Rails 3 point or so and it is a real pain. (Not to mention Ruby 1.8.7 to Ruby 1.9.3 conversion, oh boy!) The good thing about the experience is that I have mastered upgrading Rails 2's codebases to Rails 3 or so and Ruby 1.8's codebases to Ruby 1.9's or so.
- chippy 12y agoThe article describes how they compared them for performance but didn't say which was better, and showed a graph which indicated that Rails 3 was worse for longer times in garbage collection for requests. I'd imagine that Rails 2 in GitHub would have been heavily optimized, but.... Is Rails 3 worse performing than Rails 2? Would some performance loss be okay if they had a better codebase?
- dazonic 12y agoIn the multi-version, how would they handle the different DSLs in things like route mapping? map.resources :users vs. resources :users
- charliesome 12y agoRails 3.0 has a legacy routing mapper that lets us continue using the Rails 2.3 routing syntax. The legacy routing mapper is also available as a gem [1] for Rails 3.1 and 3.2. We plan on gradually upgrading our routes file to use the new syntax now that we're on Rails 3, but as you can imagine it's something that we're going to need to be slow and careful about. [1]: https://github.com/pixeltrix/rails_legacy_mapper https://github.com/pixeltrix/rails_legacy_mapper