Get Your Ass to 1.9!

Get Your Ass to 1.9!

You already know that you _should_ be running Ruby 1.9, why aren't you? This is how New Relic upgraded our big-ass, five year old Rails 2.3 app to Ruby 1.9.

B5b0f56c5edce4c54f1fea72e31d8378?s=128

Nic Benders

March 07, 2013
Tweet

Transcript

  1. GET YOUR ASS TO 1.9! @nicbenders @ralphbod http://nicbenders.com/ruby-19/

  2. GET YOUR ASS TO 1.9! @nicbenders @ralphbod http://nicbenders.com/ruby-19/

  3. None
  4. None
  5. None
  6. Ruby 1.9 has been out since 2009 (Ruby 2.0 is

    even out now) Ruby 1.8 will reach EOL in June REE has already reached EOL
  7. 0 3750 7500 11250 15000 1.8.6 1.8.7 1.9.2 1.9.3 2.0.0

  8. The New Relic App (as of mid-2012) 5 year old

    codebase 70,000 "Code LOC" and 59,000 "Test LOC" Rails 2.3.14 (started as Rails 1.2.3) REE-1.8.7-2010.02
  9. Putting it off Rearchitecting the app first Do it all

    in a big spike! Have a ruby_19 branch STUPID THINGS WE TRIED
  10. Do EVERYTHING on master Setup a CI job for it

    Start with your smaller apps THE BIG IDEA
  11. Be on latest Rails 2.3 or newer Use rbenv /

    rvm everywhere You already use Bundler, right? Decent test coverage (50% is ok) THE FOUNDATION
  12. Getting the test suite to run Upgrade obsolete 3rd party

    libs THE HARD PART
  13. Every commit is run both ways Slowly burn-down the failures

    (This took us several months) THE GRIND
  14. platforms :ruby_19 do gem 'debugger' gem 'crypt19' end platforms :ruby_18

    do gem 'ruby-debug' gem 'utility_belt' gem 'fastercsv' gem 'crypt', '1.1.4', :require => nil end
  15. # Rails 2.3 did not get along with Ruby 1.9.3

    until we did this # See - http://bit.ly/WPAj7a if ::RUBY_VERSION.split('.')[0,3] == ['1','9','3'] MissingSourceFile::REGEXPS.push( [/^cannot load such file -- (.+)$/i, 1] ) end
  16. # Prevent accidentally calling #[] on a number [Fixnum, Bignum].each

    do |k| k.class_eval do def [](*args) raise NoMethodError, "Calling #[] on numbers is wrong." end end end
  17. # Use to_sym to ensure that you always have a

    # symbol in 1.8 or 1.9 instance_methods.map(&:to_sym).include?(:connection)
  18. require "csv" # In Ruby 1.8, the library is called

    FasterCSV, # in 1.9 it's just CSV. So use some constant tricks # to make sure it's always "CSV" for us if CSV.const_defined? :Reader # Ruby 1.8 compatible require 'fastercsv' Object.send(:remove_const, :CSV) CSV = FasterCSV else # CSV is now FasterCSV in ruby 1.9 end
  19. --- 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'
  20. Mongrel Ordered Hashes Regex changes Encodings Enumerable String Lambda Arity

  21. Local dev environment first Then each "Staging" env Practice the

    roll-back plan STARTING THE DEPLOY
  22. Roll out servers one-by-one Have extra capacity available Be patient!

    THE BIG DAY
  23. None
  24. Rotate the knowledge Make it easy to test both locally

    Background jobs were un-tested THINGS TO DO BETTER
  25. Changing the wheels on the bus at 80 mph: upgrading

    to Rails 3 on an active master branch Andrew Bloomgarden and Julian Giuca
  26. JOIN THE TEAM newrelic.com/about/jobs