Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tale of a Rewrite: Lessons Learned Rewriting Ra...

Jess Martin
December 05, 2012

Tale of a Rewrite: Lessons Learned Rewriting Ranger

"Build one to throw away. You will anyway." -Fred Brooks
Few of us are brave enough to follow this advice. And yet sometimes we have to start over to move forward. With Ranger, we faced that decision. This talk discusses the rationale for the rewrite and certain key considerations we had to make during the migration.

Jess Martin

December 05, 2012
Tweet

More Decks by Jess Martin

Other Decks in Technology

Transcript

  1. He has told you, O man, what is good; And

    what does the LORD require of you but to do justice, and to love kindness, and to walk humbly with your God. - Micah 6:8
  2. Server  Costs 200.00% 400.00% 800.00% 1600.00% URLs  to  Monitor 500

    1000 2000 4000 8000 URLs  Per  Box 25 25 25 25 25 Servers  Needed 20 40 80 160 320 Monthly  Cost $799.00 $1,598.00 $3,196.00 $6,392.00 $12,784.00 Annual  Cost $9,588.00 $19,176.00 $38,352.00 $76,704.00 $153,408.00 Pricing  Models Cost  per  URL  per  month $1.60 $1.60 $1.60 $1.60 $1.60 Price  per  URL  per  month $3.00 $3.00 $3.00 $3.00 $3.00 Margin  per  URL  per  month $1.40 $1.40 $1.40 $1.40 $1.40 Gross  Margin 87.73% 87.73% 87.73% 87.73% 87.73% Monthly  Gross  Profit $701.00 $1,402.00 $2,804.00 $5,608.00 $11,216.00 Monthly  Gross  Revenue $1,500.00 $3,000.00 $6,000.00 $12,000.00 $24,000.00 Annual  Profit $8,412.00 $16,824.00 $33,648.00 $67,296.00 $134,592 URLs Per Box 25 URLs to Monitor 500 Cost Per Server $39.95 Price Per URL $3.00 Spreadsheets!
  3. The best developers understand the benefit to the business of

    the code they are writing. Assertion #1
  4. Start at the whiteboard Ranger Architecture Diagram Rails App Server

    Users Apps Dependencies Watchers Postgres (stored in Postgres for now) Dependency Statuses every 1 minute check dependencies write new status if needed, enqueue email Recon.Perform API Heroku User URLs being checked Email Queue (resque) Redis PostMark Emails User Terminal in App Repo User Browser Under Development curl heroku-ranger User App heroku addons:add ranger heroku addons:remove ranger heroku ranger heroku ranger dependencies:add heroku ranger watchers:add provision/deprovision
  5. Research with spikes require 'typhoeus' require 'json' api_key = "81a11b50-fd5d-012f-2d86-705681b14663"

    # Create a hydra instance hydra = Typhoeus::Hydra.new(:max_concurrency => 5) hydra.disable_memoization # Get a batch of dependencies to check response = Typhoeus::Request.get("http://localhost:3000/missions/next.json?internal_api_key=#{api_key}") puts response.body exit unless (response.code == 200) && (response.body != "null") dependencies = JSON.parse(response.body) # Queue the HTTP requests checks = dependencies.collect do |dependency| request = Typhoeus::Request.new(dependency["url"], :timeout => 5000) hydra.queue request {:id => dependency["id"], :request => request} end # Run the HTTP requests hydra.run # Build the results hash results = [] checks.each do |check| response = check[:request].response result = { :id => check[:id], :code => response.code, :time => response.time, :curl_return_code => response.curl_return_code, :curl_error_message => response.curl_error_message }
  6. Developers need to understand the overall architecture in order to

    make smart decisions at the code level. Assertion #2
  7. 50 active users. No downtime allowed. Checking uptime every 5

    minutes. So, 5 minute window to make the move.