• Like
Service Oriented Applications
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Service Oriented Applications

  • 1,222 views
Published

or how we built letitcast.com

or how we built letitcast.com

Published in Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,222
On SlideShare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
14
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. Service OrientedApplicationsHow we built letitcast.com, Ruby Lugdunum, June 26, 2011Michael BensoussanDeveloper
  • 2. Service OrientedApplications cc @elise_huardHow we built letitcast.com, Ruby Lugdunum, June 26, 2011Michael BensoussanDeveloper
  • 3. Service OrientedApplicationsHow we built letitcast.com, Ruby Lugdunum, June 26, 2011 Monolithic applications are boooring ! cc @apotonickMichael BensoussanDeveloper
  • 4. Tons of
  • 5. It was a
  • 6. MySQLFront-end
  • 7. Redis MySQL API for FTP Rails API users and dir. (sinatra)ConfigsEngine video uploaded Client Library on FTP notifier (sinatra) Rails Rails Frontend 1 Frontend 2 Rails Frontend 3 Configs Auth Engine Engine
  • 8. What did we
  • 9. Scale With Code Complexity
  • 10. Scale With Team Size
  • 11. Monolithic applications don’tscale
  • 12. Let’s build an API and multiple Front-ends
  • 13. Choose a communication layerand a serialization format
  • 14. We choose HTTP
  • 15. We choose HTTP andJSON
  • 16. Build theAPI !
  • 17. Tip: don’t load therails libs you don’t need
  • 18. require "rails/all"
  • 19. # Pick the frameworks you want:require "active_record/railtie"require "action_controller/railtie"require "action_mailer/railtie"# require "active_resource/railtie"require "rails/test_unit/railtie"
  • 20. [ ActionDispatch::Flash, ActionDispatch::Session::CookieStore, ActionDispatch::Cookies, ActionDispatch::Static].each do |klass| config.middleware.delete klassend
  • 21. Tip: Build the APIresponse
  • 22. fabrik42 / acts_as_api
  • 23. class User < ActiveRecord::Base acts_as_api api_accessible(ApiAccessible.init(:user)) def name "#{user.firstname} #{user.lastname}" endend
  • 24. :user: :default: - :id - :name :full: - :id - :name - :birthday - :created_at - :updated_at
  • 25. def show user = User.find(params[:id]) render_for_api :full, :json => userend
  • 26. MySQLRails API
  • 27. Build your ClientLibrary
  • 28. citizencast / restparty
  • 29. class Casting < LetitCastClient resource_for :castings, :except => [:delete], :association => [:parts, :productions], :member => { :add_production => :post, :remove_production => :delete }, :collection => {:search => :get}end Casting.find(:all) # GET /castings.json casting = Casting.find(42) # GET /castings/42.json parts = casting.parts # GET /castings/42/parts.json Casting.delete(1) # DEL /castings/1 Casting.search(:q => "Mike") # GET /castings/search?q=Mike
  • 30. class Casting < LetitCastClient resource_for :castings, :except => [:delete], :association => [:parts, :productions], :member => { :add_production => :post, :remove_production => :delete }, :collection => {:search => :get}end Casting.find(:all) # GET /castings.json casting = Casting.find(42) # GET /castings/42.json parts = casting.parts # GET /castings/42/parts.json Casting.delete(1) # DEL /castings/1 Casting.search(:q => "Mike") # GET /castings/search?q=Mike
  • 31. MySQL Rails APIClient Library Rails Frontend 1
  • 32. MySQL Rails API Client Library Rails RailsFrontend 1 Frontend 2
  • 33. Rails Engines !
  • 34. Rails 3 Rails 3.1gem install enginex rails plugin new auth --fullenginex auth
  • 35. Rails 3 Rails 3.1gem install enginex rails plugin new auth --fullenginex auth
  • 36. MySQL Rails API Client Library Rails RailsFrontend 1 Frontend 2 Configs Auth Engine Engine
  • 37. HTTP is slow !
  • 38. Cache !
  • 39. jodosha / redis-store
  • 40. Redis Cache Invalidate HTTP calls CacheFrontends Rails API
  • 41. def show @casting = Rails.cache.fetch("controller/castings/#{params[:id]}") do Casting.find(params[:id]) endend
  • 42. class CastingSweeper < ActionController::Caching::Sweeper observe Casting def after_save(casting) Rails.cache.delete_matched("controller/castings/index*") Rails.cache.delete_matched("controller/castings/#{casting.id}*") endend
  • 43. Redis MySQL Rails API Client Library Rails RailsFrontend 1 Frontend 2 Configs Auth Engine Engine
  • 44. Redis MySQL API for FTP Rails API users and dir. (sinatra)ConfigsEngine video uploaded Client Library on FTP notifier (sinatra) Rails Rails Frontend 1 Frontend 2 Rails Frontend 3 Configs Auth Engine Engine
  • 45. Questions?