Successfully reported this slideshow.

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

SOA on Rails

  1. 1. SOA AND RUBY ON RAILS a product case study for NYC on Rails Avi Flombaum July 6th 2011 DesignerPages.com Infogroup
  2. 2. WHAT’S A SERVICE? a system that responds to HTTP Requests, usually to write, retrieve, or modify data. Service Client Amazon AWS: S3 DesignerPages.com HTTP PUT PUT /ergoergo.jpg HTTP/1.1 Host: designerpages.amazonaws.com Date: Wed, 12 Oct 2009 17:50:00 GMT Authorization: AWS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE= Content-Type: text/plain Content-Length: 11434 Expect: 100-continue [11434 bytes of object data]
  3. 3. WHAT’S A SERVICE? Services can be internal. “If you hit the Amazon.com gateway page, the application calls more than 100 services to collect data and construct the page for you.” Werner Vogels, Amazon.com CTO
  4. 4. INTERNAL SERVICES loads via 4 requests, total time10ms 10ms 4ms 1ms 9ms New For You Recommendations Ad Units Bestsellers
  5. 5. BUT WHY SOA? Isolation (encapsulation) rails application Product Authentication News Search DB
  6. 6. BUT WHY SOA? Isolation news.designerpages.com designerpages.com Sinatra Rails Application Application DB DB
  7. 7. BUT WHY SOA? Benefits of Isolation •Robustness You can upgrade an underlying system without effecting clients •Scalability Each isolated system can scale independently •Organization Isolated systems are easy for teams to work on •Testing An encapsulated system is easier to test, single functionality •Agility You can make gradual improvements to smaller systems
  8. 8. BUT WHY SOA? And some more •Speed Parallel Requests •Interoperability Instant API •Reuse Client wrappers
  9. 9. BUT WHY SOA? And finally, a practical reason
  10. 10. THE RUBY SOA TOOLSET Sinatra - http://www.sinatrarb.com/ Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort: # myapp.rb require 'rubygems' require 'sinatra' get '/' do 'Hello world!' end #=> ruby myapp.rb #=> == Sinatra/1.2.1 has taken the stage on 4567 for development #=> >> Thin web server (v1.2.11 codename Bat-Shit Crazy) #=> >> Maximum connections set to 1024 #=> >> Listening on 0.0.0.0:4567, CTRL+C to stop #=> 127.0.0.1 - - [06/Jul/2011 06:48:25] "GET / HTTP/1.1" 200 12 0.0038 #=> curl http://localhost:4567 #=> Hello world!
  11. 11. THE RUBY SOA TOOLSET httparty - a party in your http A simple module that turns a class into a basic HTTP wrapper. require 'rubygems' require 'httparty' class Twitter include HTTParty base_uri 'search.twitter.com' format :json end Twitter.get('/search.json', :query => {:q => "#rubyonrails"}) ['results'].first['text'] #=> "Who is going to NYC on Rails tonight? http://dsgnr.us/qrdh21 #rubyonrails"
  12. 12. NOW FOR SOME CODE...
  13. 13. THANKS!

Editor's Notes

  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • ×