+ All Categories
Home > Technology > Get your ass to 1.9

Get your ass to 1.9

Date post: 26-Jun-2015
Category:
Upload: nic-benders
View: 527 times
Download: 0 times
Share this document with a friend
Description:
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.
Popular Tags:
26
GET YOUR ASS TO 1.9! @nicbenders @ralphbod http://nicbenders.com/ruby-19/
Transcript
Page 1: Get your ass to 1.9

GET YOUR ASS TO 1.9!

@nicbenders @ralphbod

http://nicbenders.com/ruby-19/

Page 2: Get your ass to 1.9

GET YOUR ASS TO 1.9!

@nicbenders @ralphbod

http://nicbenders.com/ruby-19/

Page 3: Get your ass to 1.9
Page 4: Get your ass to 1.9
Page 5: Get your ass to 1.9
Page 6: Get your ass to 1.9

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

Page 7: Get your ass to 1.9

0

3750

7500

11250

15000

1.8.6 1.8.7 1.9.2 1.9.3 2.0.0

Page 8: Get your ass to 1.9

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

Page 9: Get your ass to 1.9

Putting it off

Rearchitecting the app first

Do it all in a big spike!

Have a ruby_19 branch

STUPID THINGS WE TRIED

Page 10: Get your ass to 1.9

Do EVERYTHING on master

Setup a CI job for it

Start with your smaller apps

THE BIG IDEA

Page 11: Get your ass to 1.9

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

Page 12: Get your ass to 1.9

Getting the test suite to run

Upgrade obsolete 3rd party libs

THE HARD PART

Page 13: Get your ass to 1.9

Every commit is run both ways

Slowly burn-down the failures

(This took us several months)

THE GRIND

Page 14: Get your ass to 1.9

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 => nilend

Page 15: Get your ass to 1.9

# Rails 2.3 did not get along with Ruby 1.9.3 until we did this# See - http://bit.ly/WPAj7aif ::RUBY_VERSION.split('.')[0,3] == ['1','9','3'] MissingSourceFile::REGEXPS.push( [/^cannot load such file -- (.+)$/i, 1] )end

Page 16: Get your ass to 1.9

# 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 endend

Page 17: Get your ass to 1.9

# Use to_sym to ensure that you always have a# symbol in 1.8 or 1.9instance_methods.map(&:to_sym).include?(:connection)

Page 18: Get your ass to 1.9

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 usif CSV.const_defined? :Reader # Ruby 1.8 compatible require 'fastercsv' Object.send(:remove_const, :CSV) CSV = FasterCSVelse # CSV is now FasterCSV in ruby 1.9end

Page 19: Get your ass to 1.9

--- 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'

Page 20: Get your ass to 1.9

Mongrel

Ordered Hashes

Regex changes

Encodings

Enumerable String

Lambda Arity

Page 21: Get your ass to 1.9

Local dev environment first

Then each "Staging" env

Practice the roll-back plan

STARTING THE DEPLOY

Page 22: Get your ass to 1.9

Roll out servers one-by-one

Have extra capacity available

Be patient!

THE BIG DAY

Page 23: Get your ass to 1.9
Page 24: Get your ass to 1.9

Rotate the knowledge

Make it easy to test both locally

Background jobs were un-tested

THINGS TO DO BETTER

Page 25: Get your ass to 1.9

Changing the wheels on the bus at 80 mph: upgrading to Rails 3 on an active master branch

Andrew Bloomgarden and Julian Giuca

Page 26: Get your ass to 1.9

JOIN THE TEAMnewrelic.com/about/jobs


Recommended