Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Service OrientedApplicationsHow we built letitcast.com, Ruby Lugdunum, June 26, 2011Michael BensoussanDeveloper
Service OrientedApplications              cc @elise_huardHow we built letitcast.com, Ruby Lugdunum, June 26, 2011Michael B...
Service OrientedApplicationsHow we built letitcast.com, Ruby Lugdunum, June 26, 2011                                  Mono...
Tons of
It was a
MySQLFront-end
Redis                       MySQL                                                  API for FTP                        Rail...
What did we
Scale With Code  Complexity
Scale With Team Size
Monolithic applications don’tscale
Let’s build an API and multiple Front-ends
Choose a communication           layerand a serialization format
We choose HTTP
We choose HTTP andJSON
Build theAPI !
Tip: don’t load therails libs you don’t         need
require "rails/all"
# Pick the frameworks you want:require "active_record/railtie"require "action_controller/railtie"require "action_mailer/ra...
[  ActionDispatch::Flash,  ActionDispatch::Session::CookieStore,  ActionDispatch::Cookies,  ActionDispatch::Static].each d...
Tip: Build the APIresponse
fabrik42 / acts_as_api
class User < ActiveRecord::Base acts_as_api api_accessible(ApiAccessible.init(:user)) def name  "#{user.firstname} #{user.l...
:user:  :default:    - :id    - :name  :full:    - :id    - :name    - :birthday    - :created_at    - :updated_at
def show user = User.find(params[:id]) render_for_api :full, :json => userend
MySQLRails API
Build your ClientLibrary
citizencast / restparty
class Casting < LetitCastClient resource_for :castings, :except => [:delete],                 :association => [:parts, :pr...
class Casting < LetitCastClient resource_for :castings, :except => [:delete],                 :association => [:parts, :pr...
MySQL  Rails APIClient Library    Rails Frontend 1
MySQL             Rails API         Client Library   Rails                    RailsFrontend 1               Frontend 2
Rails Engines !
Rails 3               Rails 3.1gem install enginex                      rails plugin new auth --fullenginex auth
Rails 3               Rails 3.1gem install enginex                      rails plugin new auth --fullenginex auth
MySQL               Rails API             Client Library   Rails                         RailsFrontend 1                  ...
HTTP is slow !
Cache !
jodosha / redis-store
Redis         Cache           Invalidate        HTTP calls         CacheFrontends                        Rails API
def show @casting = Rails.cache.fetch("controller/castings/#{params[:id]}") do  Casting.find(params[:id]) endend
class CastingSweeper < ActionController::Caching::Sweeper observe Casting def after_save(casting)   Rails.cache.delete_mat...
Redis                      MySQL               Rails API             Client Library   Rails                         RailsF...
Redis                       MySQL                                                  API for FTP                        Rail...
Questions?
Service Oriented Applications
Service Oriented Applications
Prochain SlideShare
Chargement dans…5
×

Service Oriented Applications

1 709 vues

Publié le

or how we built letitcast.com

Publié dans : Technologie, Formation
  • Soyez le premier à commenter

Service Oriented Applications

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

×