The document discusses alternatives for running Ruby on Google App Engine that provide better performance than JRuby. It introduces Mirah, a Ruby-like language that compiles to Java bytecode, and Dubious, a web framework written in Mirah. Dubious aims to provide high performance, lightweight functionality similar to Rails. Examples show how to write a basic contacts management application in Dubious that compiles to Java for the App Engine environment.
6. JRuby on AppEngine
It rocks, but has some limitations.
Friday, September 10, 2010
7. Limitations
• Not as supported as Java & Python
• Long spin up times
• Uses more CPU(more expensive)
• getting more performance requires writing
Java
Friday, September 10, 2010
8. Spin Up
• Rails app instances take a long time to spin
up
• you can’t keep app instances running (yet)
Friday, September 10, 2010
9. Long Spin Up Times
• Rails instances take 16 seconds or more to
spin up
• AppEngine limits requests to 30 seconds
• Users will hit cold instances
Friday, September 10, 2010
10. Spin Up Workarounds
DeferredDispather
• Splits Initialization into three requests(two
redirect back)
• runtime & rack
• require app
• dispatch normally
Friday, September 10, 2010
12. CPU Usage
• On AppEngine CPU == $$$$
• JRuby uses more CPU than Java or Python
Friday, September 10, 2010
13. CPU Usage
• On AppEngine CPU == $$$$
• JRuby uses more CPU than Java or Python
Friday, September 10, 2010
14. JRuby on AppEngine
Optimization
1. Write app in Rails
2. Find parts that are slow/get heavy traffic
3. Rewrite them with Java Servlets
Friday, September 10, 2010
20. Mirah - Ruby in Javanese
Friday, September 10, 2010
21. “Charles Oliver Nutter wanted to create
a language that essentially looked like
Ruby, but was statically typed and
compiled to fast JVM bytecode.
Mirah is the result.”
- mirah.org
Friday, September 10, 2010
22. Mirah
• Uses Ruby syntax+types
• Behaves like Java
• Extensible through macros
Friday, September 10, 2010
39. High Performance,
Light weight,
Rails like
Friday, September 10, 2010
40. import dubious.*
import models.*
class ContactsController < ApplicationController
# GET /contacts
def index
@contacts = Contact.all.run
render index_erb, main_erb
end
# GET /contacts/1
def show
@contact = Contact.get(params.id)
render show_erb, main_erb
end
# GET /contacts/new
def new
@contact = Contact.new
render new_erb, main_erb
end
# GET /contacts/1/edit
def edit
@contact = Contact.get(params.id)
Friday, September 10, 2010
41. import dubious.*
import models.*
class ContactsController < ApplicationController
# GET /contacts
def index
@contacts = Contact.all.run
render index_erb, main_erb
end
# GET /contacts/1
def show
@contact = Contact.get(params.id)
render show_erb, main_erb
end
# GET /contacts/new
def new
@contact = Contact.new
render new_erb, main_erb
end
# GET /contacts/1/edit
def edit
@contact = Contact.get(params.id)
Friday, September 10, 2010
42. import dubious.*
import models.*
class ContactsController < Appli
# GET /contacts
def index
@contacts = Contact.all.run
render index_erb, main_erb
end
Friday, September 10, 2010
43. end
# GET /contacts/new
def new
@contact = Contact.new
render new_erb, main_erb
end
# GET /contacts/1/edit
def edit
@contact = Contact.get(param
render edit_erb, main_erb
end
Friday, September 10, 2010
44. end
# render templates
def_edb(index_erb,
'views/contacts/index.html.erb')
def_edb(show_erb,
'views/contacts/show.html.erb')
def_edb(new_erb,
'views/contacts/new.html.erb')
def_edb(edit_erb,
'views/contacts/edit.html.erb')
def_edb(main_erb,
'views/layouts/contacts.html.erb')
end
Friday, September 10, 2010
45. import com.google.appengine.ext.duby.db.Model
import com.google.appengine.api.datastore.*
import dubious.TimeConversion
import java.util.Date
class Contact < Model
property :title, String
property :birthday, Date
property :url, Link
property :platform, String
property :editor, String
property :summary, Text
property :address, PostalAddress
property :phone, PhoneNumber
property :private, Boolean
# timestamps
property :created_at, Date
property :updated_at, Date
def before_save
@updated_at = Date.new
@created_at = updated_at if @created_at.nil?
end
def coerce_date(o:Object)
TimeConversion.new('jsdate').parse(String(o))
Friday, September 10, 2010 end
46. import com.google.appengine.ext.duby.db.Model
import com.google.appengine.api.datastore.*
import dubious.TimeConversion
import java.util.Date
class Contact < Model
property :title, String
property :birthday, Date
property :url, Link
property :platform, String
property :editor, String
property :summary, Text
property :address, PostalAddress
property :phone, PhoneNumber
property :private, Boolean
# timestamps
property :created_at, Date
property :updated_at, Date
def before_save
@updated_at = Date.new
@created_at = updated_at if @created_at.nil?
end
def coerce_date(o:Object)
TimeConversion.new('jsdate').parse(String(o))
Friday, September 10, 2010 end