Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Sinatra Introduction

4.522 visualizaciones

Publicado el

Ruby Tuesday 6/30 xdite's talk

about Sinatra / Rack / Rails Metal

Publicado en: Tecnología
  • Sé el primero en comentar

Sinatra Introduction

  1. 1. Agenda • Sinatra Introduction • Real Example • Rack • Rails Intergation
  2. 2. • http://twitter.com/xdite • http://blog.xdite.net • Rails Developer
  3. 3. Sinatra is ... • ruby web framework library • not MVC ( Model-View-Controller ) • DSL for defining RESTful HTTP actions
  4. 4. RAILS LINGO ORM , MVC , Testing , Mail , Generator, RJS, I18n, Template , Engine .....
  5. 5. SINATRA LINGO GET / POST / PUT / DELETE , request paramenters, response, views , helpers , configure , rack
  6. 6. Single file web-app
  7. 7. Single file web-app
  8. 8. Hello World!
  9. 9. HTTP actions
  10. 10. Routes
  11. 11. Views
  12. 12. Helpers
  13. 13. Filter
  14. 14. Configure
  15. 15. • Web Service / API • Tiny Web Application • Rails Metal
  16. 16. Web Service / API
  17. 17. Requests per second: 81.09 [#/sec] (mean) Time per request: 12.332 [ms] (mean) Rails action Requests per second:450.56 [#/sec] (mean) Sinatra Time per request: 2.219 [ms] (mean) Ubuntu 8.04, Intel Atom N270 @1.60GHz
  18. 18. Tiny Web Application
  19. 19. • simple • cherry pick • ActiveRecord / Datamapper • Prototype / jQuery
  20. 20. twitter IE6
  21. 21. • CodeIgniter - PHP framework • Twitter API • LOC : 1000+ • NOT support CJK
  22. 22. require 'rubygems' require 'sinatra' require 'twitter_search' get '/' do @client = TwitterSearch::Client.new 'politweets' @results = @client.query :q => '@MrIE6' erb :home end 10 ..
  23. 23. • ORM • Paginate
  24. 24. 40
  25. 25. Rails Metal with Sinatra
  26. 26. Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks Core Code Middleware Mongrel rack middleware
  27. 27. http Profiling Security Caching Middleware Middleware Middleware Handler Core Code for Rack
  28. 28. $ rake middleware
  29. 29. Scaling Rails - Metal • Rack action • Sinatra Metal app
  30. 30. Performance
  31. 31. class OldPollerController < ApplicationController def poller render :text => "Hello World!" end end class Poller < Rails::Rack::Metal def call(env) if env["PATH_INFO"] =~ /^/poller/ [[200], {"Content-Type" => "text/html"}, "Hello, World!"] else [[404], {"Content-Type" => "text/html"}, "Not Found"] end end end 25
  32. 32. Requests per second: 81.09 [#/sec] (mean) Rails action Time per request: 12.332 [x`x] (mean) Requests per second: 163.75 [#/sec] (mean) Metal + Sinatra Time per request: 6.107 [ms] (mean) Ubuntu 8.04, Intel Atom N270 @1.60GHz
  33. 33. Q &A
  34. 34. Resources • Scaling Rails : Episode #14 Rack • RailsCast: Episode #251 Rack Middleware • Pragprog.com : Classy Web Development with Sinata • Github / xdite : tweesage-message-wall

×