Successfully reported this slideshow.

Get your ass to 1.9


Published on

This is the story of how New Relic upgraded our five year old, 125,000+ line Rails app from Ruby 1.8.7 to 1.9.3 without stopping the rest of our business. There are a lot of apps still out there running 1.8. All the easy ones are upgraded already, this is how to handle the rest of them.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Get your ass to 1.9

  1. 1. GET YOUR ASSTO 1.9!@nicbenders @ralphbod
  2. 2. GET YOUR ASSTO 1.9!@nicbenders @ralphbod
  3. 3. Ruby 1.9 has been out since 2009(Ruby 2.0 is even out now)Ruby 1.8 will reach EOL in JuneREE has already reached EOL
  4. 4. 03750750011250150001.8.6 1.8.7 1.9.2 1.9.3 2.0.0
  5. 5. The New Relic App(as of mid-2012)5 year old codebase70,000 "Code LOC" and 59,000 "Test LOC"Rails 2.3.14 (started as Rails 1.2.3)REE-1.8.7-2010.02
  6. 6. Putting it offRearchitecting the app firstDo it all in a big spike!Have a ruby_19 branchSTUPID THINGS WE TRIED
  7. 7. Do EVERYTHING on masterSetup a CI job for itStart with your smaller appsTHE BIG IDEA
  8. 8. Be on latest Rails 2.3 or newerUse rbenv / rvm everywhereYou already use Bundler, right?Decent test coverage (50% is ok)THE FOUNDATION
  9. 9. Getting the test suite to runUpgrade obsolete 3rd party libsTHE HARD PART
  10. 10. Every commit is run both waysSlowly burn-down the failures(This took us several months)THE GRIND
  11. 11. platforms :ruby_19 dogem debuggergem crypt19endplatforms :ruby_18 dogem ruby-debuggem utility_beltgem fastercsvgem crypt, 1.1.4, :require => nilend
  12. 12. # Rails 2.3 did not get along with Ruby 1.9.3 until we did this# See - ::RUBY_VERSION.split(.)[0,3] == [1,9,3]MissingSourceFile::REGEXPS.push( [/^cannot load such file -- (.+)$/i, 1] )end
  13. 13. # Prevent accidentally calling #[] on a number[Fixnum, Bignum].each do |k|k.class_eval dodef [](*args)raise NoMethodError, "Calling #[] on numbers is wrong."endendend
  14. 14. # Use to_sym to ensure that you always have a# symbol in 1.8 or
  15. 15. require "csv"# In Ruby 1.8, the library is called FasterCSV,# in 1.9 its just CSV. So use some constant tricks# to make sure its always "CSV" for usif CSV.const_defined? :Reader# Ruby 1.8 compatiblerequire fastercsvObject.send(:remove_const, :CSV)CSV = FasterCSVelse# CSV is now FasterCSV in ruby 1.9end
  16. 16. --- a/script/server+++ b/script/server@@ -1,3 +1,3 @@#!/usr/bin/env ruby-require File.dirname(__FILE__) + /../config/boot+require File.expand_path(../../config/boot, __FILE__)require commands/server
  17. 17. MongrelOrdered HashesRegex changesEncodingsEnumerable StringLambda Arity
  18. 18. Local dev environment firstThen each "Staging" envPractice the roll-back planSTARTINGTHE DEPLOY
  19. 19. Roll out servers one-by-oneHave extra capacity availableBe patient!THE BIG DAY
  20. 20. Rotate the knowledgeMake it easy to test both locallyBackground jobs were un-testedTHINGSTO DO BETTER
  21. 21. Changing the wheels on the bus at 80 mph:upgrading to Rails 3 on an active master branchAndrew Bloomgarden and Julian Giuca
  22. 22.