Sinatra Introduction
Agenda

• Sinatra Introduction
• Real Example
• Rack
• Rails Intergation
• http://twitter.com/xdite
• http://blog.xdite.net
• Rails Developer
Sinatra is ...
• ruby web framework library
• not MVC ( Model-View-Controller )
• DSL for defining RESTful HTTP actions
RAILS LINGO
      ORM , MVC , Testing , Mail ,
Generator, RJS, I18n, Template , Engine .....
SINATRA LINGO
       GET / POST / PUT / DELETE , request
paramenters, response, views , helpers , configure , rack
Single file web-app
Single file web-app
Hello World!
HTTP actions
Routes
Views
Helpers
Filter
Configure
Sinatra Introduction
•   Web Service / API

•   Tiny Web Application

•   Rails Metal
Web Service / API
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
Tiny Web Application
• simple
• cherry pick
• ActiveRecord / Datamapper
• Prototype / jQuery
Sinatra Introduction
twitter   IE6
Sinatra Introduction
• CodeIgniter - PHP framework
•     Twitter API
• LOC : 1000+
• NOT support CJK
require   'rubygems'
require   'sinatra'
require   'twitter_search'
get '/'   do
      @client = TwitterSearch::Client.new 'politweets'
      @results = @client.query :q => '@MrIE6'
      erb :home
end


                                   10           ..
•   ORM
•   Paginate
40
Sinatra Introduction
Rails Metal with Sinatra
Rack provides a minimal interface
 between webservers supporting Ruby and Ruby frameworks



Core Code           Middleware               Mongrel


                             rack          middleware
Sinatra Introduction
Sinatra Introduction
http    Profiling     Security                Caching
       Middleware   Middleware              Middleware




                                 Handler
                                               Core Code
                                 for Rack
$ rake middleware
Scaling Rails - Metal
•      Rack                action
•    Sinatra   Metal app
Performance
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
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
Q &A
Resources

• Scaling Rails : Episode #14 Rack
• RailsCast: Episode #251 Rack Middleware
• Pragprog.com : Classy Web Development
  with Sinata
• Github / xdite : tweesage-message-wall

More Related Content

PPTX
Ruby on Rails All Hands Meeting
PDF
Scala Frameworks for Web Application 2016
KEY
Torquebox rubyhoedown-2012
PDF
Quick dive into Ruby on Rails
PDF
Railsで作るBFFの功罪
PDF
Develop realtime web with Scala and Xitrum
PDF
Building a spa_in_30min
PDF
Shipping & Visualize Your Data With ELK
Ruby on Rails All Hands Meeting
Scala Frameworks for Web Application 2016
Torquebox rubyhoedown-2012
Quick dive into Ruby on Rails
Railsで作るBFFの功罪
Develop realtime web with Scala and Xitrum
Building a spa_in_30min
Shipping & Visualize Your Data With ELK

What's hot (20)

PDF
Apache Jackrabbit
PDF
scalaphx-akka-http
PPTX
Developing distributed applications with Akka and Akka Cluster
PDF
Securing Microservices using Play and Akka HTTP
PPTX
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
KEY
Capybara
PDF
Sanity on Rails
PDF
Realm Presentation
PPTX
I18nize Scala programs à la gettext
PPTX
Oak, the architecture of Apache Jackrabbit 3
PPTX
ASP.NET Developer Roadmap 2021
ODP
An Introduction to Akka http
PDF
How and When to Use FalcorJS
PDF
Xitrum @ Scala Matsuri Tokyo 2014
PPT
Simplify your integrations with Apache Camel
PPTX
Cooking with Chef
PDF
Creating applications with Grails, Angular JS and Spring Security
PDF
Display earthquakes with Akka-http
PDF
Skinny Framework Progress Situation
PDF
"How about no grep and zabbix?". ELK based alerts and metrics.
Apache Jackrabbit
scalaphx-akka-http
Developing distributed applications with Akka and Akka Cluster
Securing Microservices using Play and Akka HTTP
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
Capybara
Sanity on Rails
Realm Presentation
I18nize Scala programs à la gettext
Oak, the architecture of Apache Jackrabbit 3
ASP.NET Developer Roadmap 2021
An Introduction to Akka http
How and When to Use FalcorJS
Xitrum @ Scala Matsuri Tokyo 2014
Simplify your integrations with Apache Camel
Cooking with Chef
Creating applications with Grails, Angular JS and Spring Security
Display earthquakes with Akka-http
Skinny Framework Progress Situation
"How about no grep and zabbix?". ELK based alerts and metrics.
Ad

Viewers also liked (9)

PPTX
[每月一書,以書策展 2] 關於村上,我想說的是...
PDF
Word press基礎建置教學
PPTX
讀松浦彌太郎的生活哲學
PDF
數據化營銷的必備觀念 第二節
PDF
數據化+SEO
PDF
20161208 sem關鍵字廣告專案的執行
PPTX
Paganini Plus 行銷顧問服務簡介
PDF
內容行銷 (for JWT)
PPTX
創業的美麗與哀愁
[每月一書,以書策展 2] 關於村上,我想說的是...
Word press基礎建置教學
讀松浦彌太郎的生活哲學
數據化營銷的必備觀念 第二節
數據化+SEO
20161208 sem關鍵字廣告專案的執行
Paganini Plus 行銷顧問服務簡介
內容行銷 (for JWT)
創業的美麗與哀愁
Ad

Similar to Sinatra Introduction (20)

PDF
Rack
KEY
Wider than rails
PDF
Chirp 2010: Scaling Twitter
PDF
Ruby Conf Preso
PDF
.NET Architects Day - DNAD 2011
PDF
09 - Fábio Akita - Além do rails
PPTX
Sinatra
PPTX
Intro to node and mongodb 1
PDF
遇見 Ruby on Rails
PDF
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
PDF
Ruby on Rails : 簡介與入門
KEY
About Clack
PDF
Keep Calm And Serilog Elasticsearch Kibana on .NET Core
PDF
An Introduction to Twisted
PDF
PPTX
Rails Request & Middlewares
PDF
Instrument Rack to visualize
 Rails requests processing
PDF
Nodejs - Should Ruby Developers Care?
PDF
Sinatra and JSONQuery Web Service
PDF
Deployment de Rails
Rack
Wider than rails
Chirp 2010: Scaling Twitter
Ruby Conf Preso
.NET Architects Day - DNAD 2011
09 - Fábio Akita - Além do rails
Sinatra
Intro to node and mongodb 1
遇見 Ruby on Rails
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
Ruby on Rails : 簡介與入門
About Clack
Keep Calm And Serilog Elasticsearch Kibana on .NET Core
An Introduction to Twisted
Rails Request & Middlewares
Instrument Rack to visualize
 Rails requests processing
Nodejs - Should Ruby Developers Care?
Sinatra and JSONQuery Web Service
Deployment de Rails

More from Yi-Ting Cheng (18)

PDF
2016 01 09 NPS - 63
PDF
2016 01 07-part2
PDF
2016 01 07 part 1
PDF
Intro to Rails Workshop ( TA 須知 )
PDF
農家樂 Agricola
PDF
莫拉克颱風災情支援網
KEY
Rapid development with Rails
PDF
Upgrading to rails3
KEY
Ship It ! with Ruby/ Rails Ecosystem
PDF
Scaling Rails Sites by default
PDF
OSDC 2009 Rails Turtorial
PDF
Ec2onrails
PDF
Rails21v2
PDF
Pp6-xdite
PDF
Very Xd Hw9
PDF
Very Xd
PDF
Happyweb8 Encode
PDF
Happyweb8 Encode
2016 01 09 NPS - 63
2016 01 07-part2
2016 01 07 part 1
Intro to Rails Workshop ( TA 須知 )
農家樂 Agricola
莫拉克颱風災情支援網
Rapid development with Rails
Upgrading to rails3
Ship It ! with Ruby/ Rails Ecosystem
Scaling Rails Sites by default
OSDC 2009 Rails Turtorial
Ec2onrails
Rails21v2
Pp6-xdite
Very Xd Hw9
Very Xd
Happyweb8 Encode
Happyweb8 Encode

Recently uploaded (20)

PDF
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PDF
LMS bot: enhanced learning management systems for improved student learning e...
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PPTX
Microsoft User Copilot Training Slide Deck
PPTX
SGT Report The Beast Plan and Cyberphysical Systems of Control
PDF
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
PPTX
Build automations faster and more reliably with UiPath ScreenPlay
PDF
Electrocardiogram sequences data analytics and classification using unsupervi...
PDF
EIS-Webinar-Regulated-Industries-2025-08.pdf
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
SaaS reusability assessment using machine learning techniques
PDF
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
PDF
Early detection and classification of bone marrow changes in lumbar vertebrae...
PPTX
Training Program for knowledge in solar cell and solar industry
PDF
Connector Corner: Transform Unstructured Documents with Agentic Automation
PDF
Lung cancer patients survival prediction using outlier detection and optimize...
PDF
Build Real-Time ML Apps with Python, Feast & NoSQL
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
Data Virtualization in Action: Scaling APIs and Apps with FME
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
LMS bot: enhanced learning management systems for improved student learning e...
A symptom-driven medical diagnosis support model based on machine learning te...
Microsoft User Copilot Training Slide Deck
SGT Report The Beast Plan and Cyberphysical Systems of Control
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
Build automations faster and more reliably with UiPath ScreenPlay
Electrocardiogram sequences data analytics and classification using unsupervi...
EIS-Webinar-Regulated-Industries-2025-08.pdf
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
giants, standing on the shoulders of - by Daniel Stenberg
SaaS reusability assessment using machine learning techniques
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
Early detection and classification of bone marrow changes in lumbar vertebrae...
Training Program for knowledge in solar cell and solar industry
Connector Corner: Transform Unstructured Documents with Agentic Automation
Lung cancer patients survival prediction using outlier detection and optimize...
Build Real-Time ML Apps with Python, Feast & NoSQL

Sinatra Introduction