Ruby And The Cloud

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Notes on slide 1

    Pre-requisites – you should know Ruby. This is an intermediate level presentation, if you don’t know Ruby it will be hard for you to follow

    Also talk a bit about myself

    as of writing, TinyURL is still the king of the hill in the Twitter micro-market of URL shorteners. In June 2009, lexicographers of Oxford University Press sampled 1.5 million tweets and came up with the 500 most frequently used words on Twitter. With a little bit of further analysis, I extracted the numbers that are related to the various URL shorteners mentioned and came up with the approximate market share of the various URL shorteners in Twitter.

    Do demo here.

    1 Favorite

    Ruby And The Cloud - Presentation Transcript

    1. How to deploy Ruby Sinatra applications to the Heroku and Google AppEngine cloud platforms Ruby and the Cloud Chang Sau Sheong Geekcamp SG 22 Aug 2009
    2. Beginner/Intermediate
    3. What I am going to show here
      • Use Sinatra to write a TinyURL clone (Snip)
      • Deploy Snip to Heroku
      • Deploy Snip to Google AppEngine
      • Disclaimer – No affiliation with Heroku or Google, all opinions are my own
    4. Clone TinyURL in 40 lines of Ruby code
    5. URL Shorteners
      • First successful one was TinyURL, started in 2002
      • Generate a short URL for any URL, going to short URL will redirect to the original
      • Usage exploded with popularity of Twitter
      • Biggest market share today – TinyURL, used to be default for Twitter, second is bit.ly
      • Twitter switched to bit.ly early May 2009
    6.  
    7.  
    8. Sinatra
      • Rack-based minimalist Ruby web application framework
      require ‘rubygems’ require ‘sinatra’ get ‘/hi’ do “ Hello Geekcamp!” end
      • Designed and developed by Blake Mizerany, financial support by Heroku
    9.  
    10. http://github.com/sausheong/snip
    11. Some notes
      • Base 36 conversion to reduce number of characters used
        • Ruby provides conversion with to_i and to_s
      • DataMapper
        • ActiveRecord, Sequel also supported
        • Use DATABASE_URL environment variable
      • Embedded view template with use_in_file_templates!
    12. QUESTIONS? (BEFORE CONTINUING)
    13. Deploying Sinatra apps to Heroku
      • Ruby cloud platform
      • Hosted on Amazon’s Elastic Compute Cloud (EC2)
      • Fully managed, developer only needs to deploy, all else taken care of
      • Full set of command line tools to manage deployment
      • Deploy to your own domain or *.heroku.com
    14. Architecture Nginx Varnish Custom made from Erlang Your code runs here Postgres Memcached
    15. Inside each dyno Debian MRI Rails, Sinatra etc Thin
    16. 6 steps to deploy
      • Install Heroku gem
      • Create a Rackup file (config.ru)
    17. 6 steps to deploy
      • Create empty git repository, add all files and commit the files
    18. 6 steps to deploy
      • Create the Heroku application using the Heroku gem
    19. 6 steps to deploy
      • Push code to git repository
    20. 6 steps to deploy
      • Go into the Heroku console to create the database
      Done!
    21. QUESTIONS? (BEFORE CONTINUING)
    22. Deploying Sinatra apps to Google AppEngine with JRuby
      • Lets you run your web applications on Google's infrastructure
      • Fully managed, only deploy and runs
      • Can use own domain name or *.appspot.com
      • First released April 2008, first language used Python
      • April 2009, Java support released
      Google App Engine
    23. App Engine for Java
      • Java 6 virtual machine (JVM), App Engine SDK supports Java 5 and later
      • Servlet classes, JSPs, static files and data files, deployment descriptor (web.xml), configuration files, in a standard WAR directory structure (not WAR file)
      • Persistence using DataStore with JDO and JPA
      • Caching using App Engine’s memcache with JCache
      • Use Mail service with JavaMail
      • Image service, Google Accounts for authentication
      • JRuby is the Java implementation of the Ruby programming language
      • Tightly integrated with Java, able to call Java classes, Ruby 1.8.6 compatible
      • Is what we’re going to use to deploy Snip to App Engine
    24. First, some code differences http://github.com/sausheong/snip-appengine No base 36 conversion Using Ola Bini’s Bumble DataStore adapter, Using DataStore key instead of id
    25. What we need to deploy
      • JRuby 1.3 RC1 (at least)
        • Need to split into 2 files because of App Engine’s 10MB file size limit
      • Google App Engine for Java SDK
      • Warbler – the JRuby WAR packager
        • Includes JRuby-Rack
    26. Steps to deploy
      • Install necessary gems (remember to use JRuby and not C Ruby)
      • Create a config directory and create the Warbler configuration
    27. Steps to deploy
      • Replace it with this file
      This is important – your app name We can’t use the default full JRuby library it is too large for GAE/J – max 10MB
    28. Steps to deploy
      • Create a lib folder and add the following library files:
        • App Engine Java library - appengine-api-1.0-sdk-1.2.0.jar
        • Split jruby-complete-1.3.0RC1.jar to:
          • jruby-core-1.3.0RC1.jar and
          • jruby-stdlib-1.3.0RC1.jar
        • (JRuby-Rack will be added by Warbler later)
      • Create an appengine-web.xml deployment configuration file
    29. Steps to deploy Remember this? Your app name before You might want to do this for debugging
    30. Steps to deploy
      • Create a Rackup configuration file config.ru
        • Preparation complete!
    31. Steps to deploy
      • Generate the war file and directory using Warble
    32. Steps to deploy
      • Output:
    33. Steps to deploy
      • Go into Sinatra code at tmp/war/WEB-INF/gems/gems/sinatra-0.9.1.1/lib/sinatra.rb and remove use_in_file_templates!
    34. Steps to deploy
      • Deploy to App Engine!
    35. Steps to deploy
    36. QUESTIONS?
    37. http://tinyclone.saush.com
    38.  
    39. [email_address] http://blog.saush.com http://github.com/sausheong

    + Sau Sheong ChangSau Sheong Chang, 5 months ago

    custom

    786 views, 1 favs, 1 embeds more stats

    How to deploy Ruby Sinatra applications on Heroku a more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 786
      • 785 on SlideShare
      • 1 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 3
    Most viewed embeds
    • 1 views on http://yet-another-problem.blogspot.com

    more

    All embeds
    • 1 views on http://yet-another-problem.blogspot.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories