Your SlideShare is downloading. ×
0
Ruby on
Google App Engine




                        rug-b 01/07/10
  Ruby, Sinatra & GAE       @jberkel
Google App Engine (“GAE”)




                  The promise:

        “Transparent scaling, monitoring, logging,
everythin...
“transparent scaling”
deploy your code on Google’s own
          infrastructure
but you’re not allowed to
  bring your own food:

    no native code
      no threads
      no sockets
    no writes to FS...
[obligatory architecture slide]
some history

early 2008: “limited preview release”, Python only

  during 2009: JVM support, cron, task queues,
         ...
<3 J
 high quality, fast Ruby implementation

 JVM compilation, JIT+AOT

 real threads (not useful on GAE)

 but has an im...
deployment / dev options

     warbler                  appengine-jruby
 creates a .war file from      toolchain + API wrap...
google-appengine

$ gem install google-appengine
$ appcfg.rb generate_app hello
$ dev_appserver.rb hello
warbler

$   brew install app-engine-java-sdk
$   warble config
$   hack, hack, hack
$   dev_appserver.sh

          more ...
dev environment
based on jetty

simulates sandbox, services & DataStore

CLI tools to view logs, deploy, rollback

web adm...
Parallel versions + rollback
appengine-apis
useful ruby-ish convenience layer for the Java API

   Datastore::Query.new('twitter').
       filter('uid'...
DataStore / BigTable

               schema-less

designed for scalability, not performance
             (or availability)...
JRuby slowness
Plain Java app ~1s
  JRuby > ~10s                     no control over “spin up/down”
30sec limit on a ‘cold...
burn, CPU, burn
btw, quotas / $$$...




$0.10 cpu h / gb xfer
$0.15 / gb data stored   (10 free apps per user)
...so you probably don’t want to use Rails


           Rails 2.3.x / 3β work
           (if you really need it)



      ...
stairway: music hack day
             project, amsterdam ’10

idea: a bot to automate obituaries for
     famous (?) artis...
it got finished 2 months later :)
show me the code...
def announce_dead(e)
 message = "RIP #{e['name']} (#{e['born']} - #{e['died']})"
 message << " #{e['wi...
conclusions
useful for high latency / non realtime apps
      (bots, email / data processing)

benefit from other google se...
...uh oh.
[200, :thanks]


http://code.google.com/p/
     appengine-jruby/
http://github.com/jberkel/stairway
Upcoming SlideShare
Loading in...5
×

Ruby on Google App Engine

5,847

Published on

talk at Ruby user group Berlin (rug-b.de), 01/07/10

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,847
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
39
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

























  • Transcript of "Ruby on Google App Engine"

    1. 1. Ruby on Google App Engine rug-b 01/07/10 Ruby, Sinatra & GAE @jberkel
    2. 2. Google App Engine (“GAE”) The promise: “Transparent scaling, monitoring, logging, everything below your application code is taken care of”
    3. 3. “transparent scaling”
    4. 4. deploy your code on Google’s own infrastructure
    5. 5. but you’re not allowed to bring your own food: no native code no threads no sockets no writes to FS NoSQL (yay?!) 30s / req limit
    6. 6. [obligatory architecture slide]
    7. 7. some history early 2008: “limited preview release”, Python only during 2009: JVM support, cron, task queues, XMPP, incoming email 2010: Google App Engine for Business (SLA etc) announced: reserved instances, background services, built-in OAuth support (consumer+provider)...
    8. 8. <3 J high quality, fast Ruby implementation JVM compilation, JIT+AOT real threads (not useful on GAE) but has an image problem (“J”)
    9. 9. deployment / dev options warbler appengine-jruby creates a .war file from toolchain + API wrappers any rack-based application no special support for GAE datamapper adapter supports bundler (1.0+) Google “supported” (but not officially) ...or just mix’n’match!
    10. 10. google-appengine $ gem install google-appengine $ appcfg.rb generate_app hello $ dev_appserver.rb hello
    11. 11. warbler $ brew install app-engine-java-sdk $ warble config $ hack, hack, hack $ dev_appserver.sh more effort, but very flexible (Rake tasks) + more portable approach
    12. 12. dev environment based on jetty simulates sandbox, services & DataStore CLI tools to view logs, deploy, rollback web admin console
    13. 13. Parallel versions + rollback
    14. 14. appengine-apis useful ruby-ish convenience layer for the Java API Datastore::Query.new('twitter'). filter('uid', '==', ‘1234567’). each { |tweet| ... } TaskQueue.add(nil, :params => {'message' => “hello” }, :url => "/twitter/status”) Net:HTTP.get(‘...’) # just works
    15. 15. DataStore / BigTable schema-less designed for scalability, not performance (or availability) slow writes GQL != SQL (no JOINs) global data is expensive
    16. 16. JRuby slowness Plain Java app ~1s JRuby > ~10s no control over “spin up/down” 30sec limit on a ‘cold’ instance
    17. 17. burn, CPU, burn
    18. 18. btw, quotas / $$$... $0.10 cpu h / gb xfer $0.15 / gb data stored (10 free apps per user)
    19. 19. ...so you probably don’t want to use Rails Rails 2.3.x / 3β work (if you really need it) Sinatra is a good compromise
    20. 20. stairway: music hack day project, amsterdam ’10 idea: a bot to automate obituaries for famous (?) artists on twitter poll freebase, post to twitter w/ OAuth sinatra on GAE, no web interface
    21. 21. it got finished 2 months later :)
    22. 22. show me the code... def announce_dead(e) message = "RIP #{e['name']} (#{e['born']} - #{e['died']})" message << " #{e['wikipedia_url']}" if e['wikipedia_url'] TaskQueue.add(nil, :params=> {'message' => message}, :url => "/task/announce-dead") end post '/task/announce-dead' do Log.info "/task/announce-dead #{params.inspect}" # post to twitter TaskQueue.add(nil, :params => { 'message' => params[:message] }, :url => "/twitter/status") end post '/twitter/status' do Log.info "/twitter/status #{params.inspect}" # post to twitter end
    23. 23. conclusions useful for high latency / non realtime apps (bots, email / data processing) benefit from other google services cron for free, map/reduce easy (task queues) focus on application, not infrastructure consider possible lock-in
    24. 24. ...uh oh.
    25. 25. [200, :thanks] http://code.google.com/p/ appengine-jruby/ http://github.com/jberkel/stairway
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×