Using App Engine to power your
  native Android applications
             Jason Cooper
      Developer Programs Engineer
       jasonacooper@google.com
What is App Engine?
Spectrum of cloud-based services




 IaaS              Infrastructure as a Service
Spectrum of cloud-based services


 SaaS                  Software as a Service




 IaaS              Infrastructure as a Service
Spectrum of cloud-based services


 SaaS                  Software as a Service



 PaaS                   Platform as a Service



 IaaS              Infrastructure as a Service
Spectrum of cloud-based services


 SaaS                  Software as a Service



 PaaS                 Platform as a Service



 IaaS              Infrastructure as a Service
Sandbox restrictions

Applications cannot currently:
   open a socket or access another host directly
   spawn a sub-process or thread
   make other system calls
   write to the filesystem

Python applications cannot include C extensions or other code
that must be compiled.

Java applications cannot use unapproved JRE classes.
APIs and services
Ensuring portability
Components

                                           Python, JVM


                           Runtimes

     Local                                         Admin
     SDK                                          Console


                             Scalable
                          Infrastructure
  Linux, GFS, Bigtable,
      custom hardware
Components




        Local    Admin
        SDK     Console
Google Plugin for Eclipse
Admin Console

         http://appengine.google.com
System Status

      http://code.google.com/status/appengine
Why App Engine?
Setting up a (scalable) app is hard!
Setting up a (scalable) app is hard!

 Initial setup
      servers
      networking
      load balancers
      software licenses
 Maintenance
      patches
      upgrades
 Forecasting
      traffic
      utilization
 TIME!
 MONEY!
"Run your apps on Google's
  scalable infrastructure"
Easy to use, scale, and manage
Scale dynamically and automatically




                    App       App’s
         Use       Engine    Runtime
          r       Frontend
Scale dynamically and automatically




                    App       App’s
         Use       Engine    Runtime
          r       Frontend
Scale dynamically and automatically


                  Use
     Use           r
      r


                          App       App’s
            Use          Engine    Runtime
             r          Frontend




      Use
       r          Use
                   r
Scale dynamically and automatically


                  Use
                                    App’s
     Use           r
                                   Runtime
      r


                          App       App’s
            Use          Engine    Runtime
             r          Frontend



                                    App’s
                                   Runtime
      Use
       r          Use
                   r
Scale dynamically and automatically



                              Incoming requests


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


                 AppServer       AppServer        AppServer
Free quota

Every App Engine application receives the following at no cost:

   6.5 CPU hours per day
   1.0 GB incoming bandwidth per day
   1.0 GB outgoing bandwidth per day
   1.0 GB storage (data + indexes)
   2,000 emails sent per day
Purchase resources as needed
Demo!
Datastore deep dive
Bigtable
Datastore design

 Distributed
 Bigtable + entity groups
 ACID transactions
 Optimistic concurrency
 Entities + indexes
 Protobuf encoded entities
Datastore properties

  Core value types
      string
      integer
      floating point
      datetime
      boolean
  Composite value types
      users.User
      db.Email
      ...
  Lists (multi-valued)
  Text and binary blobs
  References (keys)
Datastore - what's familiar?

   Indexes
   ACID transactions
   GQL (SQL-like syntax):


db.GqlQuery('''
     SELECT * FROM Story
     WHERE title = 'App Engine Launch'
     AND rating >= 10
     ORDER BY rating, created DESC
''')
Datastore - what's different?

   No inner, outer, or natural joins
   Dense index scans
   Per-entity metadata
   Soft schema (no DDL!)
   Queries as object syntax:

q = Story.all()
q.filter("title =", 'App Engine Launch')
q.filter("rating >=", 10)
q.order("-rating")
q.order("-created")
Bigtable queries

1. Scan rows
2. Pre-generate index tables
3. Each index row "points" to entity
Bigtable queries (contd.)
Bigtable queries (contd.)
Bigtable queries (contd.)
Bigtable queries (contd.)
Bigtable queries (contd.)
Bigtable queries (contd.)
Querying geospatial data

Latitudes and longitudes can't be queried separately in ranges.
More and more solutions use geohashes or geocells to do
geospatial queries. Examples:

   GeoModel
     http://code.google.com/p/geomodel/
     http://code.google.com/p/javageomodel
     Supports both bounding-box and proximity queries
   mutiny
     http://code.google.com/p/mutiny/
     Sample: http://mutiny.appspot.com
   geodatastore
     http://code.google.com/p/geodatastore/
Thanks!


       Jason Cooper
Developer Programs Engineer
 jasonacooper@google.com

App Engine overview (Android meetup 06-10)