21
Sinatra + Heroku Comfortable ruby way for web service 2009年9月18日星期五

Sinatra + Heroku - read.pudn.comread.pudn.com/downloads199/doc/937609/sinatra-heroku.pdfSinatra + Heroku Comfortable ruby way for web service 2009年9月18日星期五

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Sinatra + HerokuComfortable ruby way for web service

2009年9月18日星期五

Rails or not railsit’s a question

2009年9月18日星期五

• Rails is a full stack, web application framework

• A MVC framework

• DRY - Do not repeat yourself

• Convention over configuration

2009年9月18日星期五

Rails !"#$

C

M

V

%&&'()*+,-./0

Components help you as well as trouble you

2009年9月18日星期五

• Merb: no code is faster than no code [merge with rails]

• Sinatra is a simple DSL which has minimum code

• Some other names: camping,ramaze,waves..

Someone wants simpler and faster

How can you know that, if the code is not written by yourself?

2009年9月18日星期五

Why talk about Sinatra today?

2009年9月18日星期五

Cause it is simple, popular and heroku

developer like it

2009年9月18日星期五

Sinatra app looks like...Choose dbms

ruby model

catch request

provide response

2009年9月18日星期五

Say goodbye to environment setup

Linux system setup

Web server configuration

Reverse proxy

scaling

2009年9月18日星期五

Just throw it up to heroku

2009年9月18日星期五

• write a config.ru file:

• git init

• git add .

• git commit -m “whatever you want to mark”

• sudo gem install heroku

• heroku create your-app-name

• git push heroku master

require "blog.rb"run Sinatra::Application

2009年9月18日星期五

Why heroku?

2009年9月18日星期五

• Easy deploy

• A free plan for demo

• Easy scaling

• Use your domain name freely

• Customization for ruby

• GAE is native for python and support java

2009年9月18日星期五

How heroku performs?

2009年9月18日星期五

A benchmarking...against free plan

2009年9月18日星期五

Requests per second: 11.44 [#/sec] (mean)Time per request: 873.761 [ms] (mean)Time per request: 87.376 [ms]

ab -n 100 -c 10 http://msg.dazhe.me/

Concurrency Level: 10Time taken for tests: 8.738 secondsComplete requests: 100

A simple blog system

2009年9月18日星期五

Some experience and tips

2009年9月18日星期五

• Google Map API need a domain name

• loc2ip.dazhe.me

• heroku create your-app-name

• The auto-generated name with mass you mind in no time

• A credit card is needed for enable the customized domain function

• not reasonable because it is free

2009年9月18日星期五

• Add gems?

• write a .gems file

• Use other DB servers

• 5M space is not big enough

rspec --version 1.2.7radiant --version 0.7.1

2009年9月18日星期五

• References

• docs.heroku.com

• www.sinatrarb.com

• Lightweight Webservices with Sinatra and RestClient: http://u.dazhe.me/6

2009年9月18日星期五