ruby on google app engine: upgrade to google app "turbo" engine

33
Ruby on Google App Engine Upgrade to Google App “Turbo” Engine Joseph Ku (Chieh-Fang Ku) [email protected]

Upload: joseph-ku

Post on 15-May-2015

2.780 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Ruby on Google App EngineUpgrade to Google App “Turbo” Engine

Joseph Ku (Chieh-Fang Ku)[email protected]

Page 2: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Outline

What’s Google App Engine?

Why Google App Engine?

Free quotas and limits

Significant features

Be prepared

What’s JRuby

Why Sinatra and why not Rails?

Hack! Hack! Hack!

References

v1.2.0Build 201105111230

Page 3: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Who am I?

Joseph Ku (Chieh-Fang Ku)(@josephku)

Male

Single, but not rich

A Linux user since 1996

Fed by embedded Linux and Android

Ruby lover and Guitar Hero rocker

Page 4: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Before we start...

Don’t take any notes. This slide will be published with CC BY-NC-ND.

Don’t judge my look and shape. It’s cold, and I need Calories.

Don’t play Angry Birds during my presentation

...including Angry Birds Seasons edition

Page 5: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Before we start...

You CAN interrupt me anytime.

You CAN take pictures anytime.

You CAN go to the toilet anytime.

Page 6: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

What’s Google App Engine?

GAE (Google App Engine) lets you run your web apps on Google's infrastructure.

Reliable PaaS (Platform as a Service)

Easy to use, maintain and scale

Almost free!

Page 7: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

What’s Google App Engine?

GAE (Google App Engine) lets you run your web apps on Google's infrastructure.

Typical PaaS (Platform as a Service)

Only supports Python and Java runtime environments

Who did choose GAE?...

Page 8: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Why Google App Engine?

World-class infrastructure

Light-weight PaaS

Booming of Client-Side JavaScript

Obey its limitations

Page 9: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Free quotas and limits

Free Quotas (without enabling billing)

43,200,000 requests per day

45,200 requests per minute

1 GB shared Datastore/Blobstore size

6.5 CPU-hours per day

1 GB shared bandwidth in/out per day

Page 10: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Reduced again and again...and again?

Page 11: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Free quotas and limits

Limits

10 apps for developer account

30 sec per request

10 MB HTTP response size

150 MB app code size

1,000 deployments

200 indexes

Page 12: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Significant features

Schedule tasks

Schedule tasks - Like Cron service

Every minutes!

Up to 20 tasks

Task queues - only support Python

Google account integration

URL fetch

Mail

Memcache

Image manipulation

Page 13: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine
Page 14: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

What’s URL Shortener?

Such as:

TinyURL.com

bit.ly

goo.gl

t.co

fb.me

Page 15: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Create your own URL shortener

I want this: http://mrku.co/j3Rs7k

Base 62 (0-9, a-z, A-Z)

Generated by O(1) algorithm

I want my service fast

I don’t wanna pay

I ♡ Ruby!

Page 16: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Why this happen?

You just said GAE could only support Python and Java...

Mighty JVM

JRuby

DataMapper

appengine-jruby project (John Woodell)

Page 17: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Be Prepared

Java SE Development Kit (JDK)

Ruby

RubyGems

JRuby

(...Wh...Where is GAE?)

Page 18: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Be Prepared

Install all packages we need:

$ gem install google-appengine

(rack, jruby-rack, jruby-jars, appengine-rack, appengine-apis, appengine-sdk, bundler08, rubyzip, appengine-tools, google-appengine)

Page 19: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Be Prepared

Create a GAE app and test it:

$ appcfg.rb generate_app myapp

$ dev_appserver.rb myapp

Go and check http://localhost:8080/

Page 20: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

...That’s all?

Page 21: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Wake up!!This world is NOT

perfect!

Page 22: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Be prepared for the real world

Java SE Development Kit (JDK) 6

Ruby 1.8.7-p330 or 1.8.7-p334

RubyGems 1.3.7

JRuby 1.5.6

Page 23: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Be prepared for the real world

Suggestions:

Use “RVM” to deploy your Ruby environment on Linux or Mac

Use “Pik” to deploy your Ruby environment on Windows

Page 24: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Be prepared for the real world

Install all packages we need:

$ gem install google-appengine

And do some tricks...

$ gem uninstall appengine-sdk

$ gem install appengine-sdk -v "1.4.0"

Page 25: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Be prepared for the real world

Create a GAE app and test it:

$ appcfg.rb generate_app myapp

$ echo “gem 'jruby-rack', '< 1.0.6'” >> myapp/Gemfile

$ dev_appserver.rb myapp

Go and check http://localhost:8080/

Page 26: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

What’s JRuby

100% Java implementation of the Ruby programming language

We could call Ruby MRI, “CRuby.”

Open source, Started in 2001

Always aiming for compatibility with current Ruby version

Latest release: 1.6.1 (update to 2011.05.11)

Page 27: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Why Sinatra and why not Rails

Sinatra is lighter than Rails

Sinatra’s CGI-friendly is more close to GAE

Tons of problems while trying to deploy a Rails app to GAE

Big performance issues in Rails apps on GAE

Besides...

Page 28: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Why Sinatra and why not Rails

There is Heroku!!

$ gem install heroku

$ heroku create myapp

$ git push heroku master

Go and check http://myapp.heroku.com

Page 29: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Hack! Hack! Hack!

Page 31: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

References

DataMapper

http://datamapper.org/

appengine-jruby project

http://code.google.com/p/appengine-jruby/

John Woodell ([email protected])

Page 32: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

References

RVM: Ruby Version Manger

http://rvm.beginrescueend.com/

Pik: Ruby version manager for Windows

https://github.com/vertiginous/pik/

Sinatra

http://www.sinatrarb.com/

Page 33: Ruby on Google App Engine: Upgrade to Google App "Turbo" Engine

Any questions?