SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Wednesday, November 18, 2009
Ruby & Duby on
           Google App Engine
           John Woodell
           Ryan Brown
           Nov 17, 2009




             2



Wednesday, November 18, 2009
Google App Engine
             3



Wednesday, November 18, 2009
What is Google App Engine?
           • A cloud-computing platform
           • Run your web apps on Google’s infrastructure
           • We provide the container and services (PaaS)
                 – Hardware, connectivity
                 – Operating system
                 – JVM
                 – Servlet container
                 – Software services




             4



Wednesday, November 18, 2009
Key Features
           • No need to install or maintain your own stack
           • We do the scaling for you
           • Use Google’s scalable services via standard APIs
           • Charge only for actual usage
             – Always free to get started
           • Built-in application management console




             5



Wednesday, November 18, 2009
App Engine Architecture
                                                         Incoming Requests



                   Load                    App Engine     App Engine            App Engine
                  Balancer                  Front End      Front End             Front End




                                           AppServer      AppServer             AppServer



                                                                       Other Google
                           AppServer                                   Infrastructure

                                       API Layer                       - Bigtable

                                                                       - Google Accounts

                                                                       - Memcache
                               App       App       App
                                                                       - Image manipulation


             6



Wednesday, November 18, 2009
Traditional Ruby App Server Strategy
           • Load everything into memory, servers can sit idle
           • The “big box” database strategy, will eventually hit a wall
           • Ruby and C extensions, portability issues, fewer APIs
           • Allocate and administer machines, manage load balancers




             7



Wednesday, November 18, 2009
JRuby on App Engine Strategy
           • Load only what you need for each new instance
           • Distributed persistence layer... simple and scalable
           • JRuby and Java, catch exceptions and use first-class APIs
           • Only worry about your application code in the container




             8



Wednesday, November 18, 2009
WhiteHouse.gov/openforquestions




             9



Wednesday, November 18, 2009
Quotas and Billing
                   Resource        Provided Free      Additional Cost
                         CPU       6.5 hours/day        $0.10/hour


                 Bandwidth In       1GByte/day         $0.10/GByte

              Bandwidth Out         1GByte/day         $0.12/GByte

                 Stored Data           1 GB           $0.005/GB-day

                 Emails sent     2000/day to users    $0.0001/email
                                50000/day to admins

            10



Wednesday, November 18, 2009
JRuby on App Engine
            11



Wednesday, November 18, 2009
Easy to Install

                  sudo gem install google-appengine



                          Everything you need installs as gems


            12



Wednesday, November 18, 2009
Support for JRuby
           • Can outperforms MRI in many cases
           • Gem extensions written in Java (no more segfaults)
           • A wealth of integration options available
           • Already works on App Engine with supported APIs




            13



Wednesday, November 18, 2009
Support for Sinatra Microframework
           • No learning curve... a simple and elegant DSL
           • Some data-driven apps don’t require MVC or ActionView
           • No need to extract the components we can’t use
           • New application instances can spin up quickly




            14



Wednesday, November 18, 2009
Support for Rails3
           • More modular, load only what you need for each request
           • Intelligent gem management and deployment tools
           • First-class integrations with “other” ORMs like DataMapper
           • Better routing and Rack integration
           • Better Javascript integration and options
           • Rails conventions!




            15



Wednesday, November 18, 2009
Support for DataMapper
           • Data mapped in your model, auto-migrations or no migrations
           • Text fields treated like associations, lazy-load by default
           • Create concise queries without using method_missing
           • Supports validations and legacy AR finders
           • Already works with dm-appengine wrapper




            16



Wednesday, November 18, 2009
Support for Servlet 2.5 Spec
           • Everything you need in in the container
           • JRuby-Rack dispatches to Rack
              while providing access to servlet features
           • Access to Google App Engine APIs for Java
              via Ruby APIs that are feature compatible
           • Our tools allow you to develop in the container
              with the ability to integrate Java servlets




            17



Wednesday, November 18, 2009
App Engine JRuby APIs
           • AppEngine::Users
           • AppEngine::Datastore
           • AppEngine::Memcache
           • AppEngine::Mail
           • AppEngine::URLFetch
           • AppEngine::Images
           • AppEngine::Logger
           • AppEngine::Testing
           • AppEngine::XMPP
           • AppEngine::Labs::TaskQueue



            18



Wednesday, November 18, 2009
Dev AppServer
           • Customized Jetty server
           • Local implementation of services
                 – LRU memcache
                 – Disk-backed datastore
                 – HttpClient-backed URLFetch
           • Emulates the production environment
                 – Sandbox restrictions may be inconsistent,
                  so run tests on production servers as well




            19



Wednesday, November 18, 2009
Deployment
           • Your app lives at
             – <app_id>.appspot.com, or
             – Custom domain with Google Apps
           • Deploying uploads
             – Static files
             – Resource files
             – Other metadata (datastore indexes, cron jobs)




            20



Wednesday, November 18, 2009
Administration
           • Admin Console
                 – Invite others to be developers
                 – Browse your datastore & manage indexes
                 – View access data & error logs
                 – Analyze traffic
                 – View the status of scheduled tasks
                 – Test new versions of your app




            21



Wednesday, November 18, 2009
Demo

       run lambda { |env| [200, {}, 'Hello'] }




            22



Wednesday, November 18, 2009
Current Issues with JRuby on App Engine
           • Several seconds to “spin-up” a new JRuby instance
           • Some gems still need their extensions ported to Java
           • Not an officially supported platform




            23



Wednesday, November 18, 2009
Introducing

                                 Duby


Wednesday, November 18, 2009
Duby has Ruby-inspired Syntax

                       def fib(a:int)
                         if a < 2
                           a
                         else
                           fib(a - 1) + fib(a - 2)
                         end
                       end

                       puts fib 10

Wednesday, November 18, 2009
// Generated from examples/Test.duby

           public class Test extends java.lang.Object {

                public static void main(String[] argv) {
                  System.out.println(Test.fib(10));
                }

                public static int fib(int a) {
                  return (a < 2) ?
                      (a) :
                      ((Test.fib((a - 1)) + Test.fib((a - 2))));
                }

           }


Wednesday, November 18, 2009
Duby’s not Ruby
           • Statically typed
           • No Duby runtime
           • Uses Java’s type system




            27



Wednesday, November 18, 2009
A Simple Duby App
             import javax.servlet.http.HttpServlet
             import com.google.appengine.ext.duby.db.Model

             class Post < Model
               def initialize; end

               property title, String
               property body, Text
             end

             class DubyApp < HttpServlet
               def_edb(list, 'com/ribrdb/list.dhtml')

                 def doGet(request, response)
                   @posts = Post.all.run
                   response.getWriter.write(list)
                 end

               def doPost(request, response)
                 post = Post.new
                 post.title = request.getParameter('title')
                 post.body = Text.new(request.getParameter('body'))
                 post.save
                 doGet(request, response)
               end
             end


            28



Wednesday, November 18, 2009
A Simple Duby App
             import javax.servlet.http.HttpServlet
             import com.google.appengine.ext.duby.db.Model

             class Post < Model
               def initialize; end

               property title, String
               property body, Text
             end                                          Types
             class DubyApp < HttpServlet           inferred from parent
               def_edb(list, 'com/ribrdb/list.dhtml')
                                                           class
                 def doGet(request, response)
                   @posts = Post.all.run
                   response.getWriter.write(list)
                 end

               def doPost(request, response)
                 post = Post.new
                 post.title = request.getParameter('title')
                 post.body = Text.new(request.getParameter('body'))
                 post.save
                 doGet(request, response)
               end
             end


            29



Wednesday, November 18, 2009
A Simple Duby App
             import javax.servlet.http.HttpServlet
             import com.google.appengine.ext.duby.db.Model

             class Post < Model
               def initialize; end

               property title, String
               property body, Text
             end
                                                    Plugins
             class DubyApp < HttpServlet
               def_edb(list, 'com/ribrdb/list.dhtml')

                 def doGet(request, response)
                   @posts = Post.all.run
                   response.getWriter.write(list)
                 end

               def doPost(request, response)
                 post = Post.new
                 post.title = request.getParameter('title')
                 post.body = Text.new(request.getParameter('body'))
                 post.save
                 doGet(request, response)
               end
             end


            30



Wednesday, November 18, 2009
Duby Supports Plugins
                Only form of metaprogramming (for now)


            require 'erb'

            Duby::AST.defmacro('def_edb') do |duby, fcall, p|
              name = fcall.args_node.get(0).name
              path = fcall.args_node.get(1).value
              erb = ERB::Compiler.new(nil)
            ...
              src = erb.compile(IO.read(path))
              duby.eval(src, p, “(edb)”)
            end




Wednesday, November 18, 2009
Duby Can Use erb Templates
              <title>Posts</title>
              <body>
                <h1>All Posts:</h1>
                <% for post in @posts %>
                  <h2><%= post.title %></h2>
                  <p><%= post.body.getValue %></p>
                <% end %>
                <hr>
                <h1>New Post:</h1>
                <form method=post>
                  Title: <input type=text name=title><br>
                  Body: <textarea name=body></textarea><br>
                  <input type=submit>
                </form>
              </body>



Wednesday, November 18, 2009
More to Come
           • Open classes
           • Mix ins
           • Blocks
           • More




            33



Wednesday, November 18, 2009
Resources
           • Ryan Brown, ribrdb@google.com
              John Woodell, woodie@google.com
           • Google App Engine for JRuby
                 – http://code.google.com/p/appengine-jruby/
           • Google Group
             – http://groups.google.com/group/appengine-jruby
           • Blog: JRuby on App Engine Blog
             – http://jruby-appengine.blogspot.com/




            34



Wednesday, November 18, 2009
Wednesday, November 18, 2009

Weitere ähnliche Inhalte

Was ist angesagt?

SOA on Rails
SOA on RailsSOA on Rails
SOA on Rails
Avi Flombaum
 
Polyglot Plugin Programming
Polyglot Plugin ProgrammingPolyglot Plugin Programming
Polyglot Plugin Programming
Atlassian
 
Domino OSGi Development
Domino OSGi DevelopmentDomino OSGi Development
Domino OSGi Development
Paul Fiore
 
RESTful Api practices Rails 3
RESTful Api practices Rails 3RESTful Api practices Rails 3
RESTful Api practices Rails 3
Anton Narusberg
 

Was ist angesagt? (11)

Java withrealworldtechnology
Java withrealworldtechnologyJava withrealworldtechnology
Java withrealworldtechnology
 
Padrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraPadrino - the Godfather of Sinatra
Padrino - the Godfather of Sinatra
 
SOA on Rails
SOA on RailsSOA on Rails
SOA on Rails
 
Umbra Ignite 2015: Graham Wihlidal – Adapting a technology stream to ever-evo...
Umbra Ignite 2015: Graham Wihlidal – Adapting a technology stream to ever-evo...Umbra Ignite 2015: Graham Wihlidal – Adapting a technology stream to ever-evo...
Umbra Ignite 2015: Graham Wihlidal – Adapting a technology stream to ever-evo...
 
Polyglot Plugin Programming
Polyglot Plugin ProgrammingPolyglot Plugin Programming
Polyglot Plugin Programming
 
SemeruRuntimesUnderTheCover .pptx
SemeruRuntimesUnderTheCover .pptxSemeruRuntimesUnderTheCover .pptx
SemeruRuntimesUnderTheCover .pptx
 
Domino OSGi Development
Domino OSGi DevelopmentDomino OSGi Development
Domino OSGi Development
 
PHP in the Cloud
PHP in the CloudPHP in the Cloud
PHP in the Cloud
 
Splunk for JMX
Splunk for JMXSplunk for JMX
Splunk for JMX
 
Axceleon Presentation at Siggraph 2009
Axceleon Presentation at Siggraph 2009Axceleon Presentation at Siggraph 2009
Axceleon Presentation at Siggraph 2009
 
RESTful Api practices Rails 3
RESTful Api practices Rails 3RESTful Api practices Rails 3
RESTful Api practices Rails 3
 

Andere mochten auch

Aloha on-rails-2009
Aloha on-rails-2009Aloha on-rails-2009
Aloha on-rails-2009
John Woodell
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
John Woodell
 
Rejectkaigi 2010
Rejectkaigi 2010Rejectkaigi 2010
Rejectkaigi 2010
John Woodell
 

Andere mochten auch (6)

Appengine ja-night-10
Appengine ja-night-10Appengine ja-night-10
Appengine ja-night-10
 
Aloha on-rails-2009
Aloha on-rails-2009Aloha on-rails-2009
Aloha on-rails-2009
 
Jrubykaigi 2010
Jrubykaigi 2010Jrubykaigi 2010
Jrubykaigi 2010
 
Oscon 2010
Oscon 2010Oscon 2010
Oscon 2010
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
Rejectkaigi 2010
Rejectkaigi 2010Rejectkaigi 2010
Rejectkaigi 2010
 

Ähnlich wie Rubypalooza 2009

Don Schwarz App Engine Talk
Don Schwarz App Engine TalkDon Schwarz App Engine Talk
Don Schwarz App Engine Talk
Tech in the Middle
 
We4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshell
We4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshellWe4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshell
We4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshell
We4IT Group
 
Javaedge 2010-cschalk
Javaedge 2010-cschalkJavaedge 2010-cschalk
Javaedge 2010-cschalk
Chris Schalk
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.js
Richard Rodger
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
GR8Conf
 

Ähnlich wie Rubypalooza 2009 (20)

Don Schwarz App Engine Talk
Don Schwarz App Engine TalkDon Schwarz App Engine Talk
Don Schwarz App Engine Talk
 
JRubyConf 2009
JRubyConf 2009JRubyConf 2009
JRubyConf 2009
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
What is Google App Engine?
What is Google App Engine?What is Google App Engine?
What is Google App Engine?
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
App Engine Meetup
App Engine MeetupApp Engine Meetup
App Engine Meetup
 
2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathon2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathon
 
Cloud Computing for Barcamp NOLA 2009
Cloud Computing for Barcamp NOLA 2009Cloud Computing for Barcamp NOLA 2009
Cloud Computing for Barcamp NOLA 2009
 
We4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshell
We4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshellWe4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshell
We4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshell
 
Introduction to Google's Cloud Technologies
Introduction to Google's Cloud TechnologiesIntroduction to Google's Cloud Technologies
Introduction to Google's Cloud Technologies
 
What's new in App Engine and intro to App Engine for Business
What's new in App Engine and intro to App Engine for BusinessWhat's new in App Engine and intro to App Engine for Business
What's new in App Engine and intro to App Engine for Business
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
Introduction to First Commercial Memcached Service for Cloud
Introduction to First Commercial Memcached Service for CloudIntroduction to First Commercial Memcached Service for Cloud
Introduction to First Commercial Memcached Service for Cloud
 
Javaedge 2010-cschalk
Javaedge 2010-cschalkJavaedge 2010-cschalk
Javaedge 2010-cschalk
 
Introduction to Google Cloud Platform Technologies
Introduction to Google Cloud Platform TechnologiesIntroduction to Google Cloud Platform Technologies
Introduction to Google Cloud Platform Technologies
 
Devfest09 App Engine Java
Devfest09  App Engine  JavaDevfest09  App Engine  Java
Devfest09 App Engine Java
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.js
 
Empowering the Social Web with Apache Shindig
Empowering the Social Web with Apache ShindigEmpowering the Social Web with Apache Shindig
Empowering the Social Web with Apache Shindig
 
Google Developer Days Brazil 2009 - Java Appengine
Google Developer Days Brazil 2009 -  Java AppengineGoogle Developer Days Brazil 2009 -  Java Appengine
Google Developer Days Brazil 2009 - Java Appengine
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
 

KĂźrzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

KĂźrzlich hochgeladen (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 

Rubypalooza 2009

  • 2. Ruby & Duby on Google App Engine John Woodell Ryan Brown Nov 17, 2009 2 Wednesday, November 18, 2009
  • 3. Google App Engine 3 Wednesday, November 18, 2009
  • 4. What is Google App Engine? • A cloud-computing platform • Run your web apps on Google’s infrastructure • We provide the container and services (PaaS) – Hardware, connectivity – Operating system – JVM – Servlet container – Software services 4 Wednesday, November 18, 2009
  • 5. Key Features • No need to install or maintain your own stack • We do the scaling for you • Use Google’s scalable services via standard APIs • Charge only for actual usage – Always free to get started • Built-in application management console 5 Wednesday, November 18, 2009
  • 6. App Engine Architecture Incoming Requests Load App Engine App Engine App Engine Balancer Front End Front End Front End AppServer AppServer AppServer Other Google AppServer Infrastructure API Layer - Bigtable - Google Accounts - Memcache App App App - Image manipulation 6 Wednesday, November 18, 2009
  • 7. Traditional Ruby App Server Strategy • Load everything into memory, servers can sit idle • The “big box” database strategy, will eventually hit a wall • Ruby and C extensions, portability issues, fewer APIs • Allocate and administer machines, manage load balancers 7 Wednesday, November 18, 2009
  • 8. JRuby on App Engine Strategy • Load only what you need for each new instance • Distributed persistence layer... simple and scalable • JRuby and Java, catch exceptions and use first-class APIs • Only worry about your application code in the container 8 Wednesday, November 18, 2009
  • 9. WhiteHouse.gov/openforquestions 9 Wednesday, November 18, 2009
  • 10. Quotas and Billing Resource Provided Free Additional Cost CPU 6.5 hours/day $0.10/hour Bandwidth In 1GByte/day $0.10/GByte Bandwidth Out 1GByte/day $0.12/GByte Stored Data 1 GB $0.005/GB-day Emails sent 2000/day to users $0.0001/email 50000/day to admins 10 Wednesday, November 18, 2009
  • 11. JRuby on App Engine 11 Wednesday, November 18, 2009
  • 12. Easy to Install sudo gem install google-appengine Everything you need installs as gems 12 Wednesday, November 18, 2009
  • 13. Support for JRuby • Can outperforms MRI in many cases • Gem extensions written in Java (no more segfaults) • A wealth of integration options available • Already works on App Engine with supported APIs 13 Wednesday, November 18, 2009
  • 14. Support for Sinatra Microframework • No learning curve... a simple and elegant DSL • Some data-driven apps don’t require MVC or ActionView • No need to extract the components we can’t use • New application instances can spin up quickly 14 Wednesday, November 18, 2009
  • 15. Support for Rails3 • More modular, load only what you need for each request • Intelligent gem management and deployment tools • First-class integrations with “other” ORMs like DataMapper • Better routing and Rack integration • Better Javascript integration and options • Rails conventions! 15 Wednesday, November 18, 2009
  • 16. Support for DataMapper • Data mapped in your model, auto-migrations or no migrations • Text fields treated like associations, lazy-load by default • Create concise queries without using method_missing • Supports validations and legacy AR finders • Already works with dm-appengine wrapper 16 Wednesday, November 18, 2009
  • 17. Support for Servlet 2.5 Spec • Everything you need in in the container • JRuby-Rack dispatches to Rack while providing access to servlet features • Access to Google App Engine APIs for Java via Ruby APIs that are feature compatible • Our tools allow you to develop in the container with the ability to integrate Java servlets 17 Wednesday, November 18, 2009
  • 18. App Engine JRuby APIs • AppEngine::Users • AppEngine::Datastore • AppEngine::Memcache • AppEngine::Mail • AppEngine::URLFetch • AppEngine::Images • AppEngine::Logger • AppEngine::Testing • AppEngine::XMPP • AppEngine::Labs::TaskQueue 18 Wednesday, November 18, 2009
  • 19. Dev AppServer • Customized Jetty server • Local implementation of services – LRU memcache – Disk-backed datastore – HttpClient-backed URLFetch • Emulates the production environment – Sandbox restrictions may be inconsistent, so run tests on production servers as well 19 Wednesday, November 18, 2009
  • 20. Deployment • Your app lives at – <app_id>.appspot.com, or – Custom domain with Google Apps • Deploying uploads – Static files – Resource files – Other metadata (datastore indexes, cron jobs) 20 Wednesday, November 18, 2009
  • 21. Administration • Admin Console – Invite others to be developers – Browse your datastore & manage indexes – View access data & error logs – Analyze traffic – View the status of scheduled tasks – Test new versions of your app 21 Wednesday, November 18, 2009
  • 22. Demo run lambda { |env| [200, {}, 'Hello'] } 22 Wednesday, November 18, 2009
  • 23. Current Issues with JRuby on App Engine • Several seconds to “spin-up” a new JRuby instance • Some gems still need their extensions ported to Java • Not an officially supported platform 23 Wednesday, November 18, 2009
  • 24. Introducing Duby Wednesday, November 18, 2009
  • 25. Duby has Ruby-inspired Syntax def fib(a:int) if a < 2 a else fib(a - 1) + fib(a - 2) end end puts fib 10 Wednesday, November 18, 2009
  • 26. // Generated from examples/Test.duby public class Test extends java.lang.Object { public static void main(String[] argv) { System.out.println(Test.fib(10)); } public static int fib(int a) { return (a < 2) ? (a) : ((Test.fib((a - 1)) + Test.fib((a - 2)))); } } Wednesday, November 18, 2009
  • 27. Duby’s not Ruby • Statically typed • No Duby runtime • Uses Java’s type system 27 Wednesday, November 18, 2009
  • 28. A Simple Duby App import javax.servlet.http.HttpServlet import com.google.appengine.ext.duby.db.Model class Post < Model def initialize; end property title, String property body, Text end class DubyApp < HttpServlet def_edb(list, 'com/ribrdb/list.dhtml') def doGet(request, response) @posts = Post.all.run response.getWriter.write(list) end def doPost(request, response) post = Post.new post.title = request.getParameter('title') post.body = Text.new(request.getParameter('body')) post.save doGet(request, response) end end 28 Wednesday, November 18, 2009
  • 29. A Simple Duby App import javax.servlet.http.HttpServlet import com.google.appengine.ext.duby.db.Model class Post < Model def initialize; end property title, String property body, Text end Types class DubyApp < HttpServlet inferred from parent def_edb(list, 'com/ribrdb/list.dhtml') class def doGet(request, response) @posts = Post.all.run response.getWriter.write(list) end def doPost(request, response) post = Post.new post.title = request.getParameter('title') post.body = Text.new(request.getParameter('body')) post.save doGet(request, response) end end 29 Wednesday, November 18, 2009
  • 30. A Simple Duby App import javax.servlet.http.HttpServlet import com.google.appengine.ext.duby.db.Model class Post < Model def initialize; end property title, String property body, Text end Plugins class DubyApp < HttpServlet def_edb(list, 'com/ribrdb/list.dhtml') def doGet(request, response) @posts = Post.all.run response.getWriter.write(list) end def doPost(request, response) post = Post.new post.title = request.getParameter('title') post.body = Text.new(request.getParameter('body')) post.save doGet(request, response) end end 30 Wednesday, November 18, 2009
  • 31. Duby Supports Plugins Only form of metaprogramming (for now) require 'erb' Duby::AST.defmacro('def_edb') do |duby, fcall, p| name = fcall.args_node.get(0).name path = fcall.args_node.get(1).value erb = ERB::Compiler.new(nil) ... src = erb.compile(IO.read(path)) duby.eval(src, p, “(edb)”) end Wednesday, November 18, 2009
  • 32. Duby Can Use erb Templates <title>Posts</title> <body> <h1>All Posts:</h1> <% for post in @posts %> <h2><%= post.title %></h2> <p><%= post.body.getValue %></p> <% end %> <hr> <h1>New Post:</h1> <form method=post> Title: <input type=text name=title><br> Body: <textarea name=body></textarea><br> <input type=submit> </form> </body> Wednesday, November 18, 2009
  • 33. More to Come • Open classes • Mix ins • Blocks • More 33 Wednesday, November 18, 2009
  • 34. Resources • Ryan Brown, ribrdb@google.com John Woodell, woodie@google.com • Google App Engine for JRuby – http://code.google.com/p/appengine-jruby/ • Google Group – http://groups.google.com/group/appengine-jruby • Blog: JRuby on App Engine Blog – http://jruby-appengine.blogspot.com/ 34 Wednesday, November 18, 2009