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

What you don't know about clouds could kill you!!!

What you don't know about clouds could kill you!!!

A talk given at the Scottish Ruby Conference 2011 about pitfalls encountered and lessons learned as we built an app deployed on Google Sites and Heroku.

Gar Morley

April 24, 2012
Tweet

Other Decks in Programming

Transcript

  1. — the ‘ External infrastructure Easy commissioning ! Easy scaling

    Less maintenance Focus on what makes your app different • • • •
  2. times_tried = 0 max_retries = 5 begin times_tried += 1

    feed = HRApi.get_employee_feed rescue => e if times_tried < max_retries sleep 4 ** times_tried retry end raise e, "max retries reached" end
  3. Intranet HR service GET /user/23 { user 23 + ETag

    } GET /user/23 + ETag 304 Not Modified
  4. #users_controller def show @user = User.find(params[:id]) expires_in 24.hours if stale?

    (:etag => @user, :last_modified => @user.updated_at) respond_to do |wants| wants.html wants.xml { render :xml => @user } end end end
  5. #client code def get_user u = User.find(23) return u if

    u.max_age < Time.now.utc headers = { 'If-None-Match' => u.etag, 'If-Modifed-Since' => u.last_modifed } ... data = request.get(path, headers) ... return u if response.code == 304 return u.update_attributes(data) end
  6. Rules of thumb Reduce number of HTTP calls Be prepared

    for APIs to change Expect services to fail Reduce time and cost of HTTP calls 1. 2. 3. 4.
  7. Thanks $ git log --format='%aN' | sort -u @rogerbooth @mrloop

    @cframe @grahamsavage @douglasfshearer @aw221 @jaz303 @lenary @subblue